From 17b10e327bb7f2f418ba65f8622b15abe570b371 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Tue, 1 Oct 2019 17:51:21 -0400 Subject: [PATCH 01/18] Initial setup in VSCode of c# program for project --- .gitattributes | 63 +++++ .gitignore | 261 ++++++++++++++++++ .../OnScreenKeyboardApplication.sln | 25 ++ .../OnScreenKeyboardApplication/App.config | 6 + .../Form1.Designer.cs | 40 +++ .../OnScreenKeyboardApplication/Form1.cs | 20 ++ .../KeyboardConverter.cs | 10 + .../OnScreenKeyboard.cs | 93 +++++++ .../OnScreenKeyboardApplication.csproj | 80 ++++++ .../Properties/AssemblyInfo.cs | 36 +++ .../Properties/Resources.Designer.cs | 71 +++++ .../Properties/Resources.resx | 117 ++++++++ .../Properties/Settings.Designer.cs | 30 ++ .../Properties/Settings.settings | 7 + sample data/text.txt | 3 + 15 files changed, 862 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication.sln create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/App.config create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.Designer.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/AssemblyInfo.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.Designer.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.resx create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.Designer.cs create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.settings create mode 100644 sample data/text.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication.sln b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication.sln new file mode 100644 index 0000000..c667c21 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2019 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnScreenKeyboardApplication", "OnScreenKeyboardApplication\OnScreenKeyboardApplication.csproj", "{39368AF1-5727-40F9-8DFA-F94B2F83E0E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39368AF1-5727-40F9-8DFA-F94B2F83E0E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39368AF1-5727-40F9-8DFA-F94B2F83E0E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39368AF1-5727-40F9-8DFA-F94B2F83E0E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39368AF1-5727-40F9-8DFA-F94B2F83E0E5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6BFAA8D1-9EF3-40DB-BCE5-CB2A5A05A3DC} + EndGlobalSection +EndGlobal diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/App.config b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.Designer.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.Designer.cs new file mode 100644 index 0000000..ee112c6 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace OnScreenKeyboardApplication +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.cs new file mode 100644 index 0000000..0a1015a --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OnScreenKeyboardApplication +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs new file mode 100644 index 0000000..5e83947 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -0,0 +1,10 @@ +namespace OnScreenKeyboardApplication +{ + class KeyboardConverter + { + public string ConvertLine(string currentLine) + { + return currentLine; + } + } +} diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs new file mode 100644 index 0000000..2ef3477 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs @@ -0,0 +1,93 @@ +using System; +using System.IO; +using System.Windows.Forms; + +namespace OnScreenKeyboardApplication +{ + public class OnScreenKeyboard + { + private static OpenFileDialog openFileDialog; + private static StreamReader inputReader; + private static StreamWriter convertedInputWriter; + private static string currentLine; + private static KeyboardConverter converter; + + [STAThread] + static void Main() + { + CreateOpenFileDialogObject(); + + SetDialogAttributes(); + + while (!OpenFileSuccess()) ; + + SetupFileReader(); + + ReadInputLine(); + + CreateKeyboardConverterObject(); + + CreateOutputWriter(); + + while (currentLine != null) + { + WriteConvertedLine(); + ReadInputLine(); + } + } + + private static void CreateOpenFileDialogObject() + { + openFileDialog = new OpenFileDialog(); + } + + private static void SetDialogAttributes() + { + openFileDialog.Title = "Select a text file to convert"; + + SetDialogSelectableFileTypes(); + + openFileDialog.CheckFileExists = true; + openFileDialog.CheckPathExists = true; + } + + private static void SetDialogSelectableFileTypes() + { + openFileDialog.DefaultExt = "txt"; + openFileDialog.Filter = "txt files (*.txt)|*.txt"; + } + + private static bool OpenFileSuccess() + { + return openFileDialog.ShowDialog() == DialogResult.OK; + } + + private static void SetupFileReader() + { + var inputFileStream = openFileDialog.OpenFile(); + + inputReader = new StreamReader(inputFileStream); + } + + private static void ReadInputLine() + { + currentLine = inputReader.ReadLine(); + } + + private static void CreateKeyboardConverterObject() + { + converter = new KeyboardConverter(); + } + + private static void CreateOutputWriter() + { + convertedInputWriter = new StreamWriter("ConvertedText.txt"); + } + + private static void WriteConvertedLine() + { + string convertedLine = converter.ConvertLine(currentLine); + convertedInputWriter.WriteLine(convertedLine); + } + } +} \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj new file mode 100644 index 0000000..ea7425d --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {39368AF1-5727-40F9-8DFA-F94B2F83E0E5} + WinExe + OnScreenKeyboardApplication + OnScreenKeyboardApplication + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/AssemblyInfo.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..00e6865 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/AssemblyInfo.cs @@ -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("OnScreenKeyboardApplication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OnScreenKeyboardApplication")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[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("39368af1-5727-40f9-8dfa-f94b2f83e0e5")] + +// 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")] diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.Designer.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4bef075 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace OnScreenKeyboardApplication.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OnScreenKeyboardApplication.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.resx b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.Designer.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.Designer.cs new file mode 100644 index 0000000..33ce115 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace OnScreenKeyboardApplication.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.settings b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sample data/text.txt b/sample data/text.txt new file mode 100644 index 0000000..2570ac8 --- /dev/null +++ b/sample data/text.txt @@ -0,0 +1,3 @@ +test +test1 +test2 \ No newline at end of file From c5b02accdffd3968ba7584da3631793c93d7f4fc Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Tue, 1 Oct 2019 18:30:02 -0400 Subject: [PATCH 02/18] Main class established for processing input text and outputting converted lines --- .../OnScreenKeyboard.cs | 15 +++++++-------- .../OnScreenKeyboardApplication.csproj | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs index 2ef3477..566f93a 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs @@ -8,7 +8,6 @@ public class OnScreenKeyboard { private static OpenFileDialog openFileDialog; private static StreamReader inputReader; - private static StreamWriter convertedInputWriter; private static string currentLine; private static KeyboardConverter converter; @@ -27,13 +26,13 @@ static void Main() CreateKeyboardConverterObject(); - CreateOutputWriter(); - while (currentLine != null) { WriteConvertedLine(); ReadInputLine(); } + + CloseReaderStream(); } private static void CreateOpenFileDialogObject() @@ -79,15 +78,15 @@ private static void CreateKeyboardConverterObject() converter = new KeyboardConverter(); } - private static void CreateOutputWriter() + private static void WriteConvertedLine() { - convertedInputWriter = new StreamWriter("ConvertedText.txt"); + string convertedLine = converter.ConvertLine(currentLine); + Console.WriteLine(convertedLine); } - private static void WriteConvertedLine() + private static void CloseReaderStream() { - string convertedLine = converter.ConvertLine(currentLine); - convertedInputWriter.WriteLine(convertedLine); + inputReader.Close(); } } } \ No newline at end of file diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj index ea7425d..7cdd086 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj @@ -52,6 +52,7 @@ Form1.cs + From 401487557b8fbbd24d5a0102daa4ba149717d65f Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Tue, 1 Oct 2019 18:44:34 -0400 Subject: [PATCH 03/18] Corrected file IO to read and write all at once, to avoid lots of reads and writes to the file --- .../KeyboardConverter.cs | 14 +++++++--- .../OnScreenKeyboard.cs | 27 ++++++++++--------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index 5e83947..b447a38 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -1,10 +1,18 @@ -namespace OnScreenKeyboardApplication +using System; + +namespace OnScreenKeyboardApplication { class KeyboardConverter { - public string ConvertLine(string currentLine) + public string ConvertLines(string inputLines) { - return currentLine; + string[] splitInputLines = inputLines.Split(new[] { Environment.NewLine }, StringSplitOptions.None); + + foreach (string inputLine in splitInputLines) + { + + } + return splitInputLines[0]; } } } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs index 566f93a..c410d7f 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs @@ -8,8 +8,9 @@ public class OnScreenKeyboard { private static OpenFileDialog openFileDialog; private static StreamReader inputReader; - private static string currentLine; + private static string inputLines; private static KeyboardConverter converter; + private static string convertedLines; [STAThread] static void Main() @@ -22,15 +23,13 @@ static void Main() SetupFileReader(); - ReadInputLine(); + ReadInputLines(); CreateKeyboardConverterObject(); - while (currentLine != null) - { - WriteConvertedLine(); - ReadInputLine(); - } + ConvertInputTextToKeyboard(); + + WriteConvertedLines(); CloseReaderStream(); } @@ -68,9 +67,9 @@ private static void SetupFileReader() inputReader = new StreamReader(inputFileStream); } - private static void ReadInputLine() + private static void ReadInputLines() { - currentLine = inputReader.ReadLine(); + inputLines = inputReader.ReadToEnd(); } private static void CreateKeyboardConverterObject() @@ -78,10 +77,14 @@ private static void CreateKeyboardConverterObject() converter = new KeyboardConverter(); } - private static void WriteConvertedLine() + private static void ConvertInputTextToKeyboard() + { + convertedLines = converter.ConvertLines(inputLines); + } + + private static void WriteConvertedLines() { - string convertedLine = converter.ConvertLine(currentLine); - Console.WriteLine(convertedLine); + Console.WriteLine(convertedLines); } private static void CloseReaderStream() From 02c89033783fdde9103cd2ef0673c1dcc36d782c Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Tue, 1 Oct 2019 19:41:51 -0400 Subject: [PATCH 04/18] Methods establishes for handling of converted input lines to DVR keyboard --- .../OnScreenKeyboardApplication/KeyboardConverter.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index b447a38..24dccf5 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -8,11 +8,18 @@ public string ConvertLines(string inputLines) { string[] splitInputLines = inputLines.Split(new[] { Environment.NewLine }, StringSplitOptions.None); + string convertedLines = ""; + foreach (string inputLine in splitInputLines) { - + convertedLines += ChangeToKeyboardMovements(inputLine) + "\n"; } - return splitInputLines[0]; + return convertedLines; + } + + private string ChangeToKeyboardMovements(string inputLine) + { + return inputLine; } } } From ece423943c5e4ef7a06a3bf38d180828fc1498b6 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Tue, 1 Oct 2019 20:16:38 -0400 Subject: [PATCH 05/18] Setup for keyboard mapping methods, just need implementations --- .../KeyboardConverter.cs | 74 ++++++++++++++++++- .../KeyboardMapping.cs | 36 +++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index 24dccf5..ada2f52 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -4,6 +4,9 @@ namespace OnScreenKeyboardApplication { class KeyboardConverter { + private string keyboardMovementsLine; + private KeyboardMapping currentMapping; + public string ConvertLines(string inputLines) { string[] splitInputLines = inputLines.Split(new[] { Environment.NewLine }, StringSplitOptions.None); @@ -19,7 +22,76 @@ public string ConvertLines(string inputLines) private string ChangeToKeyboardMovements(string inputLine) { - return inputLine; + keyboardMovementsLine = ""; + + currentMapping = new KeyboardMapping(); + + foreach (char inputCharacter in inputLine) + { + if (currentMapping.SpaceCharacter(inputCharacter)) + { + keyboardMovementsLine += "S" + ","; + } + else + { + AddKeyboardPositionMovements(inputCharacter); + } + + AddSelectCharacter(); + } + + RemoveFinalComma(); + + return keyboardMovementsLine; + } + + private void RemoveFinalComma() + { + keyboardMovementsLine.Remove(keyboardMovementsLine.Length - 1); + } + + private void AddKeyboardPositionMovements(char inputCharacter) + { + int verticalMoves = currentMapping.FindVerticalMovement(inputCharacter); + int horizontalMoves = currentMapping.FindHorizontalMovement(inputCharacter); + + AddVerticalMovement(verticalMoves); + AddHorizontalMovement(horizontalMoves); + } + + private void AddVerticalMovement(int verticalMoves) + { + for (int i = 0; i < Math.Abs(verticalMoves); i++) + { + if (verticalMoves < 0) + { + keyboardMovementsLine += "U" + ","; + } + else + { + keyboardMovementsLine += "D" + ","; + } + } + } + + private void AddHorizontalMovement(int horizontalMoves) + { + for (int i = 0; i < Math.Abs(horizontalMoves); i++) + { + if (horizontalMoves < 0) + { + keyboardMovementsLine += "L" + ","; + } + else + { + keyboardMovementsLine += "R" + ","; + } + } + } + + private void AddSelectCharacter() + { + keyboardMovementsLine += "#" + ","; } } } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs new file mode 100644 index 0000000..3d8e315 --- /dev/null +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OnScreenKeyboardApplication +{ + class KeyboardMapping + { + private int currentXPosition; + private int currentYPosition; + + public KeyboardMapping() + { + currentXPosition = 0; + currentYPosition = 0; + } + + public bool SpaceCharacter(char inputCharacter) + { + // Implement + return false; + } + + public int FindVerticalMovement(char inputCharacter) + { + return 0; + } + + public int FindHorizontalMovement(char inputCharacter) + { + return 0; + } + } +} From f8335709b25e95f7c10234b1989b82b15363498c Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 10:32:07 -0400 Subject: [PATCH 06/18] Ready to add mapping algorithm --- .../OnScreenKeyboardApplication.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj index 7cdd086..369cfd4 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboardApplication.csproj @@ -53,6 +53,7 @@ Form1.cs + From 43b2668a7ebdeaa0ef098073bff2e351ae2e01b7 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 10:51:40 -0400 Subject: [PATCH 07/18] Minor adjustments to check for errors in keyboard converter class and onscreenkeyboard class --- .../KeyboardConverter.cs | 23 +++++++++---------- .../KeyboardMapping.cs | 15 ++++++++---- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index ada2f52..ebfffad 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -5,7 +5,7 @@ namespace OnScreenKeyboardApplication class KeyboardConverter { private string keyboardMovementsLine; - private KeyboardMapping currentMapping; + private KeyboardMapping keyboardMap; public string ConvertLines(string inputLines) { @@ -15,20 +15,20 @@ public string ConvertLines(string inputLines) foreach (string inputLine in splitInputLines) { - convertedLines += ChangeToKeyboardMovements(inputLine) + "\n"; + convertedLines += ConvertToKeyboardMovements(inputLine) + "\n"; } return convertedLines; } - private string ChangeToKeyboardMovements(string inputLine) + private string ConvertToKeyboardMovements(string inputLine) { keyboardMovementsLine = ""; - currentMapping = new KeyboardMapping(); + keyboardMap = new KeyboardMapping(); foreach (char inputCharacter in inputLine) { - if (currentMapping.SpaceCharacter(inputCharacter)) + if (keyboardMap.IsSpaceCharacter(inputCharacter)) { keyboardMovementsLine += "S" + ","; } @@ -36,24 +36,23 @@ private string ChangeToKeyboardMovements(string inputLine) { AddKeyboardPositionMovements(inputCharacter); } - AddSelectCharacter(); } - RemoveFinalComma(); + keyboardMovementsLine = RemoveFinalCommaFromMovement(); return keyboardMovementsLine; } - private void RemoveFinalComma() + private string RemoveFinalCommaFromMovement() { - keyboardMovementsLine.Remove(keyboardMovementsLine.Length - 1); + return keyboardMovementsLine.Remove(keyboardMovementsLine.Length - 1); } private void AddKeyboardPositionMovements(char inputCharacter) { - int verticalMoves = currentMapping.FindVerticalMovement(inputCharacter); - int horizontalMoves = currentMapping.FindHorizontalMovement(inputCharacter); + int verticalMoves = keyboardMap.FindVerticalMovement(inputCharacter); + int horizontalMoves = keyboardMap.FindHorizontalMovement(inputCharacter); AddVerticalMovement(verticalMoves); AddHorizontalMovement(horizontalMoves); @@ -91,7 +90,7 @@ private void AddHorizontalMovement(int horizontalMoves) private void AddSelectCharacter() { - keyboardMovementsLine += "#" + ","; + keyboardMovementsLine += "#," + ","; } } } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index 3d8e315..d25a553 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -17,20 +17,25 @@ public KeyboardMapping() currentYPosition = 0; } - public bool SpaceCharacter(char inputCharacter) + public bool IsSpaceCharacter(char inputCharacter) { - // Implement - return false; + return Char.IsWhiteSpace(inputCharacter); } public int FindVerticalMovement(char inputCharacter) { - return 0; + int newYPosition = 0; + + + return newYPosition - currentYPosition; } public int FindHorizontalMovement(char inputCharacter) { - return 0; + int newXPosition = 0; + + + return newXPosition - currentXPosition; } } } From c7281267381ad5316eb2ea598fb34cf02da01d3b Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:20:31 -0400 Subject: [PATCH 08/18] Initial setup of conversion --- .../KeyboardConverter.cs | 2 +- .../KeyboardMapping.cs | 89 ++++++++++++++++++- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index ebfffad..ae67ac7 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -34,7 +34,7 @@ private string ConvertToKeyboardMovements(string inputLine) } else { - AddKeyboardPositionMovements(inputCharacter); + AddKeyboardPositionMovements(char.ToUpper(inputCharacter)); } AddSelectCharacter(); } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index d25a553..86e5a99 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -24,18 +24,99 @@ public bool IsSpaceCharacter(char inputCharacter) public int FindVerticalMovement(char inputCharacter) { - int newYPosition = 0; + int characterValue = ConvertCharacterToInt(inputCharacter); + int newYPosition = FindNewYPosition(characterValue); - return newYPosition - currentYPosition; + int verticalMovement = newYPosition - currentYPosition; + + currentYPosition = newYPosition; + + return verticalMovement; } public int FindHorizontalMovement(char inputCharacter) { - int newXPosition = 0; + int characterValue = ConvertCharacterToInt(inputCharacter); + + int newXPosition = FindNewXPosition(characterValue); + + int horizontalMovement = newXPosition - currentXPosition; + currentXPosition = newXPosition; - return newXPosition - currentXPosition; + return horizontalMovement; + } + + public int ConvertCharacterToInt(char inputCharacter) + { + return Convert.ToInt32(inputCharacter); + } + + public int FindNewYPosition(int characterValue) + { + int convertedYPosition = 0; + + if (IsLetter(characterValue)) + { + convertedYPosition = (characterValue - 65) / 6; + } + else if(IsNumber(characterValue)) + { + convertedYPosition = ConvertNumberValueToY(characterValue); + } + + return convertedYPosition; + } + + public int FindNewXPosition(int characterValue) + { + int convertedXPosition = 0; + + if (IsLetter(characterValue)) + { + convertedXPosition = (characterValue - 65) % 6; + } + else if (IsNumber(characterValue)) + { + convertedXPosition = ConvertNumberValueToX(characterValue); + } + + return convertedXPosition; + } + + public bool IsLetter(int characterValue) + { + return characterValue > 64 && characterValue < 91; + } + + public bool IsNumber(int characterValue) + { + return characterValue > 47 && characterValue < 58; + } + + public int ConvertNumberValueToY(int characterValue) + { + if(characterValue == 48) + { + return 5; + } + else + { + return (characterValue - 23) / 6; + } + } + + public int ConvertNumberValueToX(int characterValue) + { + if (characterValue == 48) + { + return 5; + } + else + { + return (characterValue - 23) % 6; + } } } } From e1933d4a4df9215ad1b8e69bed4c5740ee152539 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:23:32 -0400 Subject: [PATCH 09/18] Initial testing of conversions --- .../KeyboardMapping.cs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index 86e5a99..35d335b 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -63,7 +63,7 @@ public int FindNewYPosition(int characterValue) } else if(IsNumber(characterValue)) { - convertedYPosition = ConvertNumberValueToY(characterValue); + convertedYPosition = ConvertNumberValue(characterValue) / 6; } return convertedYPosition; @@ -79,7 +79,7 @@ public int FindNewXPosition(int characterValue) } else if (IsNumber(characterValue)) { - convertedXPosition = ConvertNumberValueToX(characterValue); + convertedXPosition = ConvertNumberValue(characterValue) % 6; } return convertedXPosition; @@ -95,7 +95,7 @@ public bool IsNumber(int characterValue) return characterValue > 47 && characterValue < 58; } - public int ConvertNumberValueToY(int characterValue) + public int ConvertNumberValue(int characterValue) { if(characterValue == 48) { @@ -103,19 +103,7 @@ public int ConvertNumberValueToY(int characterValue) } else { - return (characterValue - 23) / 6; - } - } - - public int ConvertNumberValueToX(int characterValue) - { - if (characterValue == 48) - { - return 5; - } - else - { - return (characterValue - 23) % 6; + return characterValue - 23; } } } From d70a51ad8f6dc7f7bf7e894cdabbf251101ad8f9 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:25:40 -0400 Subject: [PATCH 10/18] Small bug fix where extra comma was in strings --- .../OnScreenKeyboardApplication/KeyboardConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index ae67ac7..6e94c8f 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -90,7 +90,7 @@ private void AddHorizontalMovement(int horizontalMoves) private void AddSelectCharacter() { - keyboardMovementsLine += "#," + ","; + keyboardMovementsLine += "#" + ","; } } } From 539eee6a77a7ef46c8faf0a53b87654461a7ac4b Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:29:02 -0400 Subject: [PATCH 11/18] New sample data and fix so space character doesn't require select --- .../OnScreenKeyboardApplication/KeyboardConverter.cs | 2 +- sample data/text.txt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index 6e94c8f..f42e0a0 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -35,8 +35,8 @@ private string ConvertToKeyboardMovements(string inputLine) else { AddKeyboardPositionMovements(char.ToUpper(inputCharacter)); + AddSelectCharacter(); } - AddSelectCharacter(); } keyboardMovementsLine = RemoveFinalCommaFromMovement(); diff --git a/sample data/text.txt b/sample data/text.txt index 2570ac8..f760f7d 100644 --- a/sample data/text.txt +++ b/sample data/text.txt @@ -1,3 +1 @@ -test -test1 -test2 \ No newline at end of file +IT Crowd \ No newline at end of file From d4b0820ff2aaafc94c58e2dd0641bb796a6b288b Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:30:25 -0400 Subject: [PATCH 12/18] Removing unncessary imports --- .../OnScreenKeyboardApplication/KeyboardMapping.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index 35d335b..5d763f3 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace OnScreenKeyboardApplication { From e7ca92fbf7f465fbb8faa2706c9f87568d572105 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:46:08 -0400 Subject: [PATCH 13/18] Fix for finding position of 0 --- .../KeyboardMapping.cs | 25 ++++++++++--------- sample data/text.txt | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index 5d763f3..25002a5 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -59,7 +59,11 @@ public int FindNewYPosition(int characterValue) } else if(IsNumber(characterValue)) { - convertedYPosition = ConvertNumberValue(characterValue) / 6; + convertedYPosition = (characterValue - 23) / 6; + } + else if (IsZero(characterValue)) + { + convertedYPosition = 5; } return convertedYPosition; @@ -75,7 +79,11 @@ public int FindNewXPosition(int characterValue) } else if (IsNumber(characterValue)) { - convertedXPosition = ConvertNumberValue(characterValue) % 6; + convertedXPosition = (characterValue - 23) % 6; + } + else if (IsZero(characterValue)) + { + convertedXPosition = 5; } return convertedXPosition; @@ -88,19 +96,12 @@ public bool IsLetter(int characterValue) public bool IsNumber(int characterValue) { - return characterValue > 47 && characterValue < 58; + return characterValue > 48 && characterValue < 58; } - public int ConvertNumberValue(int characterValue) + public bool IsZero(int characterValue) { - if(characterValue == 48) - { - return 5; - } - else - { - return characterValue - 23; - } + return characterValue == 48; } } } diff --git a/sample data/text.txt b/sample data/text.txt index f760f7d..36bc15e 100644 --- a/sample data/text.txt +++ b/sample data/text.txt @@ -1 +1,2 @@ -IT Crowd \ No newline at end of file +c0b9a3 +oO9o0A \ No newline at end of file From 4930163bf4c44e3f80db1187e1e6952d8e917baf Mon Sep 17 00:00:00 2001 From: Justin Kramer <32302157+kjustin2@users.noreply.github.com> Date: Wed, 2 Oct 2019 14:53:17 -0400 Subject: [PATCH 14/18] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2c16e5c..50cf3ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ On Screen Keyboard ================== +# Notes For The Reviewer + + The Problem ----------- On screen keyboards are the bane of DVR users. To help alleviate the pain, one local company is asking you to implement part of a voice to text search for their DVR by developing an algorithm to script the on screen keyboard. From e1f3ced0c7016b9884e9b9e1d3b60da4c7c279c3 Mon Sep 17 00:00:00 2001 From: Justin Kramer <32302157+kjustin2@users.noreply.github.com> Date: Wed, 2 Oct 2019 14:56:19 -0400 Subject: [PATCH 15/18] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 50cf3ec..82a374a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ On Screen Keyboard # Notes For The Reviewer +- This is my first time using C# in a project ever. +- I chose to use C# since it fits into the .NET framework very well. +- To run my program: + - Open solution file in Visual Studio Code. + - Start the OnScreenKeyboard file. +- My program assumes a user wants to select a text file to read with a GUI display and has a text file ready to select. +- My program outputs to the console, but this output is a string that could be returned anywhere in the software. + The Problem ----------- From c2ed070086536839a2e1df020e9bdbe8ce961614 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 14:57:37 -0400 Subject: [PATCH 16/18] Adding sample data code and ability to leave program if no text file selected to use --- .../OnScreenKeyboard.cs | 17 +++++++++-------- sample data/match_sample_test.txt | 1 + sample data/multiple_line_test.txt | 2 ++ sample data/random_text_test.txt | 1 + sample data/text.txt | 2 -- 5 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 sample data/match_sample_test.txt create mode 100644 sample data/multiple_line_test.txt create mode 100644 sample data/random_text_test.txt delete mode 100644 sample data/text.txt diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs index c410d7f..c80dc49 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs @@ -19,19 +19,20 @@ static void Main() SetDialogAttributes(); - while (!OpenFileSuccess()) ; + if (OpenFileSuccess()) + { + SetupFileReader(); - SetupFileReader(); + ReadInputLines(); - ReadInputLines(); + CreateKeyboardConverterObject(); - CreateKeyboardConverterObject(); + ConvertInputTextToKeyboard(); - ConvertInputTextToKeyboard(); + WriteConvertedLines(); - WriteConvertedLines(); - - CloseReaderStream(); + CloseReaderStream(); + } } private static void CreateOpenFileDialogObject() diff --git a/sample data/match_sample_test.txt b/sample data/match_sample_test.txt new file mode 100644 index 0000000..f760f7d --- /dev/null +++ b/sample data/match_sample_test.txt @@ -0,0 +1 @@ +IT Crowd \ No newline at end of file diff --git a/sample data/multiple_line_test.txt b/sample data/multiple_line_test.txt new file mode 100644 index 0000000..1c4120d --- /dev/null +++ b/sample data/multiple_line_test.txt @@ -0,0 +1,2 @@ +ab d +d49D \ No newline at end of file diff --git a/sample data/random_text_test.txt b/sample data/random_text_test.txt new file mode 100644 index 0000000..a1588be --- /dev/null +++ b/sample data/random_text_test.txt @@ -0,0 +1 @@ +0OoC3 \ No newline at end of file diff --git a/sample data/text.txt b/sample data/text.txt deleted file mode 100644 index 36bc15e..0000000 --- a/sample data/text.txt +++ /dev/null @@ -1,2 +0,0 @@ -c0b9a3 -oO9o0A \ No newline at end of file From 98f80e4e55a4627482913c6889becf37e3b5aae1 Mon Sep 17 00:00:00 2001 From: Justin Kramer Date: Wed, 2 Oct 2019 16:37:33 -0400 Subject: [PATCH 17/18] Comments on code to clarify ideas --- .../OnScreenKeyboardApplication/KeyboardConverter.cs | 8 ++++++-- .../OnScreenKeyboardApplication/KeyboardMapping.cs | 8 ++++++++ .../OnScreenKeyboardApplication/OnScreenKeyboard.cs | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs index f42e0a0..088ce63 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardConverter.cs @@ -13,10 +13,12 @@ public string ConvertLines(string inputLines) string convertedLines = ""; + // Convert each separate line of the text file into keyboard movements foreach (string inputLine in splitInputLines) { convertedLines += ConvertToKeyboardMovements(inputLine) + "\n"; } + return convertedLines; } @@ -24,6 +26,7 @@ private string ConvertToKeyboardMovements(string inputLine) { keyboardMovementsLine = ""; + // Our keyboard mapping can convert characters into keyboard movements keyboardMap = new KeyboardMapping(); foreach (char inputCharacter in inputLine) @@ -34,17 +37,18 @@ private string ConvertToKeyboardMovements(string inputLine) } else { + // Ensure all characters are uppercase to avoid confusion in handling them AddKeyboardPositionMovements(char.ToUpper(inputCharacter)); AddSelectCharacter(); } } - keyboardMovementsLine = RemoveFinalCommaFromMovement(); + keyboardMovementsLine = RemoveFinalCommaFromMovements(); return keyboardMovementsLine; } - private string RemoveFinalCommaFromMovement() + private string RemoveFinalCommaFromMovements() { return keyboardMovementsLine.Remove(keyboardMovementsLine.Length - 1); } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs index 25002a5..85d391d 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/KeyboardMapping.cs @@ -24,6 +24,7 @@ public int FindVerticalMovement(char inputCharacter) int newYPosition = FindNewYPosition(characterValue); + // Change in position of characters across keyboard int verticalMovement = newYPosition - currentYPosition; currentYPosition = newYPosition; @@ -46,6 +47,7 @@ public int FindHorizontalMovement(char inputCharacter) public int ConvertCharacterToInt(char inputCharacter) { + // Standard system of converting characters to integer values return Convert.ToInt32(inputCharacter); } @@ -55,14 +57,17 @@ public int FindNewYPosition(int characterValue) if (IsLetter(characterValue)) { + // Letters begin at a value of 65 with 'A', so now we start them at index 0 of essentially a keyboard array convertedYPosition = (characterValue - 65) / 6; } else if(IsNumber(characterValue)) { + // Numbers begin at a value of 49 with '1', so we now start them at 26, right after our letters in the keyboard convertedYPosition = (characterValue - 23) / 6; } else if (IsZero(characterValue)) { + // 0 is at the fifth position of our keyboard array convertedYPosition = 5; } @@ -91,16 +96,19 @@ public int FindNewXPosition(int characterValue) public bool IsLetter(int characterValue) { + // Converted values for uppercase letters from characters return characterValue > 64 && characterValue < 91; } public bool IsNumber(int characterValue) { + // Converted values for numbers from characters return characterValue > 48 && characterValue < 58; } public bool IsZero(int characterValue) { + // Character converted value of 0 return characterValue == 48; } } diff --git a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs index c80dc49..4041f0f 100644 --- a/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs +++ b/code/OnScreenKeyboardApplication/OnScreenKeyboardApplication/OnScreenKeyboard.cs @@ -19,6 +19,7 @@ static void Main() SetDialogAttributes(); + // Only convert text file if one is successfully selected if (OpenFileSuccess()) { SetupFileReader(); @@ -52,6 +53,7 @@ private static void SetDialogAttributes() private static void SetDialogSelectableFileTypes() { + // Ensure that only text files are selected openFileDialog.DefaultExt = "txt"; openFileDialog.Filter = "txt files (*.txt)|*.txt"; } @@ -70,6 +72,7 @@ private static void SetupFileReader() private static void ReadInputLines() { + // Read all input at once to avoid slowness of multiple reads inputLines = inputReader.ReadToEnd(); } @@ -85,6 +88,7 @@ private static void ConvertInputTextToKeyboard() private static void WriteConvertedLines() { + // Write all lines at once to avoid slowness of multiple writes Console.WriteLine(convertedLines); } From 7444bd293df4d3ffb513cf6a4ae9a373800b9057 Mon Sep 17 00:00:00 2001 From: Justin Kramer <32302157+kjustin2@users.noreply.github.com> Date: Wed, 2 Oct 2019 16:39:48 -0400 Subject: [PATCH 18/18] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 82a374a..fc99888 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ On Screen Keyboard - Start the OnScreenKeyboard file. - My program assumes a user wants to select a text file to read with a GUI display and has a text file ready to select. - My program outputs to the console, but this output is a string that could be returned anywhere in the software. +- My code is the following: + - OnScreenKeyboard.cs + - KeyboardConverter.cs + - KeyboardMapping.cs + - All other code is part of the VS Code generation that allows the program to run The Problem