Skip to content

Commit

Permalink
Merge pull request #1 from vzyrianov/dev
Browse files Browse the repository at this point in the history
Merge Dev into Master
  • Loading branch information
vzyrianov committed Apr 13, 2019
2 parents 3d6f0e5 + 38ebda3 commit b51aa4e
Show file tree
Hide file tree
Showing 34 changed files with 816 additions and 661 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,6 @@ FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
ModelManifest.xml

.vs/
17 changes: 10 additions & 7 deletions src/Bukva/Bukva.sln → Bukva/Bukva.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bukva", "Bukva\Bukva.csproj", "{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bukva", "Bukva\Bukva.csproj", "{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}.Release|Any CPU.Build.0 = Release|Any CPU
{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4A6B472-489B-4112-8CF7-8D9A5E95325E}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion src/Bukva/Bukva/App.config → Bukva/Bukva/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions Bukva/Bukva/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="Bukva.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Bukva"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions Bukva/Bukva/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Bukva
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
85 changes: 50 additions & 35 deletions src/Bukva/Bukva/Bukva.csproj → Bukva/Bukva/Bukva.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{C539DDE6-B1AA-49C5-87A0-4C68A1DFDB8B}</ProjectGuid>
<ProjectGuid>{C39F5059-D81E-4068-8E4E-87A5DC7F05F1}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Bukva</RootNamespace>
<AssemblyName>Bukva</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -33,56 +36,68 @@
</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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="FixedLengthQueue.cs" />
<Compile Include="KeyPressListener.cs" />
<Compile Include="KeyTranslator.cs" />
<Compile Include="LetterTable.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
49 changes: 49 additions & 0 deletions Bukva/Bukva/FixedLengthQueue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace Bukva
{
class FixedLengthQueue<Type>
{
private readonly int length;
private int position;

Type[] buffer;

public FixedLengthQueue(int length)
{
this.length = length;
buffer = new Type[length];
position = 0;
}

public Type At(int index)
{
return buffer[(index + position) % length];
}

public void Insert(Type s)
{
buffer[position] = s;
position += 1;

if(position >= length)
{
position = 0;
}
}

public void Clear()
{
buffer = new Type[length];
position = 0;
}

public void Clear(Type clearVar)
{
position = 0;

for(int i = 0; i < length; ++i)
{
buffer[i] = clearVar;
}
}
}
}
87 changes: 87 additions & 0 deletions Bukva/Bukva/KeyPressListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace Bukva
{
class KeyPressListener
{
public bool Listen { get; set; }
public event EventHandler<KeyPressedEventArgs> OnKeyPressed;

[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(int vKey);
private Thread keyPressListenerThread;

public KeyPressListener()
{
keyPressListenerThread = new Thread(new ThreadStart(() =>
{
while (true)
{
if(Listen)
{
ReadKeyPresses();
Thread.Sleep(10);
}
else
{
Thread.Sleep(200);
}
}
}));

keyPressListenerThread.IsBackground = true;
keyPressListenerThread.Start();
}

void ReadKeyPresses()
{
foreach (int i in Enum.GetValues(typeof(Keys)))
{
if (GetAsyncKeyState(i) == -32767)
{
string key;

if(Control.ModifierKeys.HasFlag(Keys.Shift))
{
key = Enum.GetName(typeof(Keys), i).ToUpper();
}
else
{
key = Enum.GetName(typeof(Keys), i).ToLower();
}

if (key.ToUpper() == "OEMPERIOD")
{
key = ".";
}

OnKeyPressed(this, new KeyPressedEventArgs(key));
}
}
}

public void DeleteLastKeyPressed()
{
SendKeys.SendWait("{BACKSPACE}");
}

public void EmitBackspace()
{
SendKeys.SendWait("{BACKSPACE}");
}
}

public class KeyPressedEventArgs : EventArgs
{
public string KeyPressed { get; private set; }

public KeyPressedEventArgs(string key)
{
KeyPressed = key;
}
}
}
Loading

0 comments on commit b51aa4e

Please sign in to comment.