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
25 changes: 25 additions & 0 deletions OnScreenKeyboardConsole/OnScreenKeyboardConsole.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2006
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnScreenKeyboardConsole", "OnScreenKeyboardConsole\OnScreenKeyboardConsole.csproj", "{BCA5B6D6-B343-4B9B-B2CB-07973379806D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BCA5B6D6-B343-4B9B-B2CB-07973379806D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCA5B6D6-B343-4B9B-B2CB-07973379806D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCA5B6D6-B343-4B9B-B2CB-07973379806D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCA5B6D6-B343-4B9B-B2CB-07973379806D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {40F94535-1C55-44A2-9554-B7A72A1B138C}
EndGlobalSection
EndGlobal
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.0</TargetFramework>
</PropertyGroup>

</Project>
158 changes: 158 additions & 0 deletions OnScreenKeyboardConsole/OnScreenKeyboardConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OnScreenKeyboardConsole
{
class Program
{
static void Main(string[] args)
{
string line;
KeyBoardTranslator kb = new KeyBoardTranslator();
var tup = Tuple.Create(0, 0);
while ((line = Console.ReadLine()) != null)
{
var outputchars = kb.GenerateString(ref tup, line);
Console.WriteLine(string.Join(',',outputchars)); // Write to console.

//outputs results cursor stays on last character entered if you want to go back to A add this line
//tup = Tuple.Create(0, 0);
}
}
}

public class KeyBoardTranslator
{
//col0 col5
//ABCDEF row1
//GHIJKL
//MNOPQR
//STUVWX
//YZ1234
//567890 row 6

public int GetColumn(char input)
{
int column = -1;
var num = ((int)input);

if (num >= 48)
{
if (num == 48)
column = 5;
else if (num <= 57)
column = (num - 47) % 6;
else if (num >= 65 && num <= 90)
num += 32;

if (num >= 97 && num <= 122)
column = (num - 97) % 6;
}
if (column != -1) return column;
throw new IndexOutOfRangeException($"Character '{input}' in not a valid entry.");
}

public int GetRow(char input)
{
int row = -1;
var num = ((int)input);

if (num >= 48 && num <= 57)
{

if (num > 48 && num <= 52)
row = 4;
else
row = 5;
}
//a-z
else if (num >= 65 && num <= 70)
row = 0;
else if (num >= 71 && num <= 76)
row = 1;
else if (num >= 77 && num <= 82)
row = 2;
else if (num >= 83 && num <= 88)
row = 3;
else if (num >= 89 && num <= 90)
row = 4;
//A-Z
else if (num >= 97 && num <= 102)
row = 0;
else if (num >= 103 && num <= 108)
row = 1;
else if (num >= 109 && num <= 114)
row = 2;
else if (num >= 115 && num <= 120)
row = 3;
else if (num >= 121 && num <= 122)
row = 4;

if(row != -1) return row;
throw new IndexOutOfRangeException($"Character '{input}' in not a valid entry.");
}


public List<char> GenerateString(ref Tuple<int,int> StatingLocation, string input, char invalidCharacterSymbol = '?')
{
List<char> output = new List<char>();
foreach(char c in input)
{
if (c == ' ')
{
output.Add('S');
continue;
}
int col, row;
try
{

col = GetColumn(c);
row = GetRow(c);
}
catch (Exception)
{
//this is where the main functionality can be changed, how we want to handle an invalid input would significantly change
//the program, right now I just have it return a ? but we could just as easily have it boil up an exception
// or do something else
output.Add(invalidCharacterSymbol);
continue;
//throw;
}

var c1 = StatingLocation.Item1 - col;
var r1 = StatingLocation.Item2 - row;

while (r1 < 0)
{
output.Add('D');
r1++;
}
while (r1 > 0)
{
output.Add('U');
r1--;
}

while (c1 < 0)
{
output.Add('R');
c1++;
}
while (c1 > 0)
{
output.Add('L');
c1--;
}
output.Add('#');

StatingLocation = Tuple.Create(col, row);
}

return output;


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.0",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.0": {
"OnScreenKeyboardConsole/1.0.0": {
"runtime": {
"OnScreenKeyboardConsole.dll": {}
}
}
}
},
"libraries": {
"OnScreenKeyboardConsole/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\\gkerb\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\gkerb\\.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.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("OnScreenKeyboardConsole")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("OnScreenKeyboardConsole")]
[assembly: System.Reflection.AssemblyTitleAttribute("OnScreenKeyboardConsole")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7c4ca390ccfff8528c75def5e34ed40afa39e8a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a6c8494cc9e63f935b24c2daae529fb264222853
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\bin\Debug\netcoreapp2.0\OnScreenKeyboardConsole.deps.json
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\bin\Debug\netcoreapp2.0\OnScreenKeyboardConsole.runtimeconfig.json
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\bin\Debug\netcoreapp2.0\OnScreenKeyboardConsole.runtimeconfig.dev.json
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\bin\Debug\netcoreapp2.0\OnScreenKeyboardConsole.dll
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\bin\Debug\netcoreapp2.0\OnScreenKeyboardConsole.pdb
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.csprojResolveAssemblyReference.cache
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.csproj.CoreCompileInputs.cache
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.AssemblyInfoInputs.cache
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.AssemblyInfo.cs
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.dll
C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\Debug\netcoreapp2.0\OnScreenKeyboardConsole.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"dgSpecHash": "6/tCak3adQE48h4UGBtk1FgcqWFQ9eEQ8nEBe7+MOdHdlRAmsjSdyIiyJQBGSsSzCo8uvlVYnI18SZnR60o7vg==",
"success": true
}
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)' == '' ">C:\Users\gkerb\Source\Repos\OnScreenKeyboard\OnScreenKeyboardConsole\OnScreenKeyboardConsole\obj\project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\gkerb\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.4.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.0.0\build\netcoreapp2.0\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\build\netcoreapp2.0\Microsoft.NETCore.App.props')" />
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.0\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.0\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\build\netcoreapp2.0\Microsoft.NETCore.App.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\build\netcoreapp2.0\Microsoft.NETCore.App.targets')" />
</ImportGroup>
</Project>
Loading