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 ConsoleApp1/ConsoleApp1.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.27703.2018
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9B7246D5-3845-46C9-AEE5-422C06105617}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions ConsoleApp1/ConsoleApp1/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
52 changes: 52 additions & 0 deletions ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{35454DFA-FDC6-47EB-8FE5-208B819BC4C5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="OnScreenKeyboardMD.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
209 changes: 209 additions & 0 deletions ConsoleApp1/ConsoleApp1/OnScreenKeyboardMD.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class OnSreenKeyboard
{
/* Author Comment Date
* Mark Dinkel Created Visual C# 2017 5/28/2018
*
* Purpose: Translate input text string into arrow key-presses on a matrix keyboard
*
*/

//Create Key Map X-Y coordinate hashtables
static private Hashtable keyMapX = new Hashtable();
static private Hashtable keyMapY = new Hashtable();

static private void OnScreenKeyboard()
{
// class initializer
// Add elements to the key map hash tables - X and Y coordinates
// The Start is the letter A at (1,1) is the number 0 at (6,6)
keyMapX.Add("A", "1"); keyMapY.Add("A", "1");
keyMapX.Add("B", "2"); keyMapY.Add("B", "1");
keyMapX.Add("C", "3"); keyMapY.Add("C", "1");
keyMapX.Add("D", "4"); keyMapY.Add("D", "1");
keyMapX.Add("E", "5"); keyMapY.Add("E", "1");
keyMapX.Add("F", "6"); keyMapY.Add("F", "1");
keyMapX.Add("G", "1"); keyMapY.Add("G", "2");
keyMapX.Add("H", "2"); keyMapY.Add("H", "2");
keyMapX.Add("I", "3"); keyMapY.Add("I", "2");
keyMapX.Add("J", "4"); keyMapY.Add("J", "2");
keyMapX.Add("K", "5"); keyMapY.Add("K", "2");
keyMapX.Add("L", "6"); keyMapY.Add("L", "2");
keyMapX.Add("M", "1"); keyMapY.Add("M", "3");
keyMapX.Add("N", "2"); keyMapY.Add("N", "3");
keyMapX.Add("O", "3"); keyMapY.Add("O", "3");
keyMapX.Add("P", "4"); keyMapY.Add("P", "3");
keyMapX.Add("Q", "5"); keyMapY.Add("Q", "3");
keyMapX.Add("R", "6"); keyMapY.Add("R", "3");
keyMapX.Add("S", "1"); keyMapY.Add("S", "4");
keyMapX.Add("T", "2"); keyMapY.Add("T", "4");
keyMapX.Add("U", "3"); keyMapY.Add("U", "4");
keyMapX.Add("V", "4"); keyMapY.Add("V", "4");
keyMapX.Add("W", "5"); keyMapY.Add("W", "4");
keyMapX.Add("X", "6"); keyMapY.Add("X", "4");
keyMapX.Add("Y", "1"); keyMapY.Add("Y", "5");
keyMapX.Add("Z", "2"); keyMapY.Add("Z", "5");
keyMapX.Add("1", "3"); keyMapY.Add("1", "5");
keyMapX.Add("2", "4"); keyMapY.Add("2", "5");
keyMapX.Add("3", "5"); keyMapY.Add("3", "5");
keyMapX.Add("4", "6"); keyMapY.Add("4", "5");
keyMapX.Add("5", "1"); keyMapY.Add("5", "6");
keyMapX.Add("6", "2"); keyMapY.Add("6", "6");
keyMapX.Add("7", "3"); keyMapY.Add("7", "6");
keyMapX.Add("8", "4"); keyMapY.Add("8", "6");
keyMapX.Add("9", "5"); keyMapY.Add("9", "6");
keyMapX.Add("0", "6"); keyMapY.Add("0", "6");

}

private static string XYToKeys(int currX, int currY, int nextX, int nextY)
{
// Private method to translate the arrow key presses from the current key to
// the next key using (U)p, (D)own, (L)eft and (R)ight
int moveX, moveY, strPos = 0;
char[] keys = new char[512];

moveX = nextX - currX;
moveY = nextY - currY;

if (moveY > 0)
{
for (int i = 0; i < moveY; i++)
{
keys[strPos++] = 'D';
keys[strPos++] = ',';
}
}
else
{
for (int i = 0; i > moveY; i--)
{
keys[strPos++] = 'U';
keys[strPos++] = ',';
}
}
if (moveX > 0)
{
for (int i=0;i<moveX;i++)
{
keys[strPos++] = 'R';
keys[strPos++] = ',';
}
}
else
{
for (int i = 0; i > moveX; i--)
{
keys[strPos++] = 'L';
keys[strPos++] = ',';
}
}

keys[strPos++] = '#';
keys[strPos++] = ',';

String retStr = new String(keys);

return retStr;

}

static void Main(string[] args)
{
string currKey = "A", currStr = "", upStr;
int currX = 1, currY = 1, nextX, nextY;

object objNextX, objNextY;
string nextKey;

string keyDirections;
string allKeyDirections = "";

// class initializer
OnScreenKeyboard();

// This can be updated to any filestream
string inFile = @"C:\Users\mark\Documents\Data\inData.txt";
try
{
using (FileStream fsRead = new FileStream(inFile, FileMode.Open, FileAccess.Read))
{
using (StreamReader srRead = new StreamReader(fsRead))
{
// This can be updated to any file stream
string outFile = @"C:\Users\mark\Documents\Data\outData.txt";
using (FileStream fsWrite = new FileStream(outFile, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter srWrite = new StreamWriter(fsWrite))
{

while (!srRead.EndOfStream)
{
currStr = srRead.ReadLine();
upStr = currStr.ToUpper();

// Reset to the starting key position
currKey = "A"; currX = 1; currY = 1;

foreach (char c in upStr)
{
if (!char.IsWhiteSpace(c))
{
nextKey = c.ToString(); // The char for the key-press
objNextX = keyMapX[nextKey]; // X coordinate of the char
objNextY = keyMapY[nextKey]; // Y coordinate of the char

// X-Y location of the key-press
nextX = int.Parse(string.Format("{0}", objNextX));
nextY = int.Parse(string.Format("{0}", objNextY));

// Get the key-presses from the current char to the next char
keyDirections = XYToKeys(currX, currY, nextX, nextY);
allKeyDirections += keyDirections; // add to final string

// Update the current char to the next char
currKey = c.ToString();
currX = nextX;
currY = nextY;
}
else
{
allKeyDirections += "S,"; // (S)pace

}

}
// Replace nul characters in the final string and write
allKeyDirections = allKeyDirections.Replace(Convert.ToChar(0x0).ToString(), "");
// Remove the last comma added to the final string
allKeyDirections = allKeyDirections.Remove(allKeyDirections.Length - 1);
// Add a newline after each line that is written to the output file
allKeyDirections += Environment.NewLine;
}
srWrite.Write(allKeyDirections);
}
}
}
}
}
catch (Exception ex)
{
// Execute the application using Ctrl+F5 to see the exception messages
Console.WriteLine(ex.Message);
}

}


}


}
15 changes: 15 additions & 0 deletions ConsoleApp1/ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
}
}
}
36 changes: 36 additions & 0 deletions ConsoleApp1/ConsoleApp1/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("ConsoleApp1")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("35454dfa-fdc6-47eb-8fe5-208b819bc4c5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
6 changes: 6 additions & 0 deletions ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Binary file added ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7a876511b7e9abd6db48b815b9e2ae512dc68cac
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.pdb
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csprojAssemblyReference.cache
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.exe
C:\Users\mark\source\repos\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.pdb
Binary file not shown.
Binary file not shown.
Binary file added ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.pdb
Binary file not shown.
Binary file not shown.