Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/ConsoleApp1/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file added .vs/OSK/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file added .vs/OSK/v16/.suo
Binary file not shown.
Empty file.
Binary file added .vs/OSK/v16/Server/sqlite3/storage.ide
Binary file not shown.
Binary file added .vs/OSK/v16/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file added .vs/OSK/v16/Server/sqlite3/storage.ide-wal
Binary file not shown.
Binary file added .vs/OnScreenKeyboard/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file added .vs/OnScreenKeyboard/v16/.suo
Binary file not shown.
76 changes: 76 additions & 0 deletions ConsoleApp1/Keyboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OnScreenKeyboard
{
public class Keyboard
{
public Keyboard()
{
this.DesiredPosX = 1;
this.DesiredPosY = 0;
this.CurrentPosX = 1;
this.CurrentPosY = 0;
}
public string Output { get; set; }
public int DesiredPosX { get; set; }
public int DesiredPosY { get; set; }
public int CurrentPosX { get; set; }
public int CurrentPosY { get; set; }

public Dictionary<int, string[]> keys = new Dictionary<int, string[]>()
{
{ 1, new string[]{ "A", "B", "C", "D", "E", "F"} },
{ 2, new string[]{ "G", "H", "I", "J", "K", "L"} },
{ 3, new string[]{ "M", "N", "O", "P", "Q", "R"} },
{ 4, new string[]{ "S", "T", "U", "V", "W", "X"} },
{ 5, new string[]{ "Y", "Z", "1", "2", "3", "4"} },
{ 6, new string[]{ "5", "6", "7", "8", "9", "0"} }
};

public (string output, int currentposx) Up()
{
if (this.CurrentPosX > 1)
{
this.Output += "U";
this.CurrentPosX--;
}
return (this.Output, this.CurrentPosX);
}
public (string output, int currentposx) Down()
{
if (this.CurrentPosX < 6)
{
this.Output += "D";
this.CurrentPosX++;
}
return (this.Output, this.CurrentPosX);
}
public (string output, int currentposy) Right()
{
if(this.CurrentPosY < 5)
{
this.Output += "R";
this.CurrentPosY++;
}
return (this.Output, this.CurrentPosY);
}
public (string output, int currentposy) Left()
{
if (this.CurrentPosY > 0)
{
this.Output += "L";
this.CurrentPosY--;
}
return (this.Output, this.CurrentPosY);
}

public string Select()
{
this.Output += "#";
return this.Output;
}

}
}
8 changes: 8 additions & 0 deletions ConsoleApp1/OnScreenKeyboard.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
26 changes: 26 additions & 0 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using OnScreenKeyboard;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace OnScreenKeyboard
{
class Program
{
static void Main(string[] args)
{
ProgramMethods pm = new ProgramMethods();


while (true)
{
Console.WriteLine("Please create a text file on your desktop and write the file name or type exit to leave!");
var filename = Console.ReadLine();
if (filename.ToLower().Equals("exit")) pm.Exit();
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), filename);
if (File.Exists(path) && Path.GetExtension(path).Equals(".txt")) pm.Write(path); else Console.WriteLine("file does not exist! Try again!");
}
}
}
}
99 changes: 99 additions & 0 deletions ConsoleApp1/ProgramMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace OnScreenKeyboard
{
public class ProgramMethods
{

//locate the desired letter and set the position in the model, return the position as a string
public (bool letterExists, int x, int y) SetDesiredPosition(string letter, Keyboard kb)
{
bool found = false;
int x = 0;
int y = 0;
foreach (KeyValuePair<int, string[]> kv in kb.keys)
{
for (var i = 0; i < kv.Value.Length; i++)
{
if (kv.Value[i].Equals(letter))
{
x = kb.DesiredPosX = kv.Key;
y = kb.DesiredPosY = i;
found = true;
break;
}
}
if (found) break;
}
return (found, x, y);
}

//Follow path and call the methods that add to the output
public bool TrackPathAndSelect(Keyboard kb)
{
while (kb.CurrentPosX > kb.DesiredPosX) kb.Up();
while (kb.CurrentPosX < kb.DesiredPosX) kb.Down();
while (kb.CurrentPosY > kb.DesiredPosY) kb.Left();
while (kb.CurrentPosY < kb.DesiredPosY) kb.Right();
kb.Select();
return (kb.CurrentPosX == kb.DesiredPosX) &&
(kb.CurrentPosY == kb.DesiredPosY);
}

public void Exit()
{
Console.WriteLine("Have a Nice Day!");
Thread.Sleep(3000);
Environment.Exit(0);
}
//run the program for each letter in the file
//Todo each lines output is to be stored seperately, maybe by creating a list

public string LineOutput(string line, Keyboard kb)
{
try
{
var upperline = line.ToUpper().Select(x => x.ToString());
foreach (string letter in upperline)
{
if (letter.Equals(" ")) kb.Output += "S";
else
{
var found = SetDesiredPosition(letter, kb);
if (found.letterExists) TrackPathAndSelect(kb);
}
}
return String.Join(",", kb.Output.ToCharArray());
}
catch(Exception x)
{
Console.WriteLine("no valid members on line");
}
return "";
}

public List<string> Output(string textfile)
{
List<string> LineOutputs = new List<string>();
foreach (string line in File.ReadAllLines(textfile))
{
Keyboard keyboard = new Keyboard();
LineOutputs.Add(LineOutput(line, keyboard));
}
return LineOutputs;
}

public void Write(string textfile)
{
foreach (string output in Output(textfile))
{
Console.WriteLine(output);
}
}
}
}
23 changes: 23 additions & 0 deletions ConsoleApp1/bin/Debug/netcoreapp2.2/ConsoleApp1.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.2",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.2": {
"ConsoleApp1/1.0.0": {
"runtime": {
"ConsoleApp1.dll": {}
}
}
}
},
"libraries": {
"ConsoleApp1/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\Raizel Seliger\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\Raizel Seliger\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp2.2",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.2.0"
}
}
}
23 changes: 23 additions & 0 deletions ConsoleApp1/bin/Debug/netcoreapp2.2/OnScreenKeyboard.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.2",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.2": {
"OnScreenKeyboard/1.0.0": {
"runtime": {
"OnScreenKeyboard.dll": {}
}
}
}
},
"libraries": {
"OnScreenKeyboard/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\Raizel Seliger\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\Raizel Seliger\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp2.2",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.2.0"
}
}
}
5 changes: 5 additions & 0 deletions ConsoleApp1/obj/ConsoleApp1.csproj.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"dgSpecHash": "7PQO6PArE5Nld9TIYHpGW8R3MA+p4m5IAJZYGu4MPuJyj9aFe5YmCvQvjyYepv4YbLB+iYQoOpSge6CUmCg0Pg==",
"success": true
}
60 changes: 60 additions & 0 deletions ConsoleApp1/obj/ConsoleApp1.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"format": 1,
"restore": {
"C:\\Users\\Raizel Seliger\\source\\repos\\OnScreenKeyboard\\ConsoleApp1\\ConsoleApp1.csproj": {}
},
"projects": {
"C:\\Users\\Raizel Seliger\\source\\repos\\OnScreenKeyboard\\ConsoleApp1\\ConsoleApp1.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Raizel Seliger\\source\\repos\\OnScreenKeyboard\\ConsoleApp1\\ConsoleApp1.csproj",
"projectName": "ConsoleApp1",
"projectPath": "C:\\Users\\Raizel Seliger\\source\\repos\\OnScreenKeyboard\\ConsoleApp1\\ConsoleApp1.csproj",
"packagesPath": "C:\\Users\\Raizel Seliger\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Raizel Seliger\\source\\repos\\OnScreenKeyboard\\ConsoleApp1\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\Raizel Seliger\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp2.2"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp2.2": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp2.2": {
"dependencies": {
"Microsoft.NETCore.App": {
"suppressParent": "All",
"target": "Package",
"version": "[2.2.0, )",
"autoReferenced": true
}
},
"imports": [
"net461"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
18 changes: 18 additions & 0 deletions ConsoleApp1/obj/ConsoleApp1.csproj.nuget.g.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Raizel Seliger\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.1.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props')" />
</ImportGroup>
</Project>
Loading