Skip to content

Commit

Permalink
Settings Dialog and Registry Saving of Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Phaiax committed Jan 22, 2015
1 parent 360fda4 commit c682bee
Show file tree
Hide file tree
Showing 14 changed files with 1,210 additions and 264 deletions.
2 changes: 2 additions & 0 deletions PxKeystrokesTests/PxKeystrokesTests.csproj
Expand Up @@ -36,6 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<Choose>
Expand All @@ -52,6 +53,7 @@
</Choose>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsStoreTest.cs" />
<Compile Include="VirtualKeyParserTest.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
43 changes: 43 additions & 0 deletions PxKeystrokesTests/SettingsStoreTest.cs
@@ -0,0 +1,43 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PxKeystrokesUi;
using System.Drawing;


namespace PxKeystrokesTests
{
[TestClass]
public class SettingsStoreTest
{
[TestMethod]
public void TestSavingAndLoadingInt()
{
SettingsStore s1 = new SettingsStore();
s1.LoadAll();
s1.LabelAnimation = Style.NoAnimation;
s1.WindowSize = new Size(200, 211);
s1.WindowLocation = new Point(233, 234);
s1.SaveAll();

SettingsStore s2 = new SettingsStore();
s2.LoadAll();
Assert.AreEqual(s2.LabelAnimation, Style.NoAnimation);
Assert.AreEqual(s2.WindowSize.Width, 200);
Assert.AreEqual(s2.WindowSize.Height, 211);
Assert.AreEqual(s2.WindowLocation.X, 233);
Assert.AreEqual(s2.WindowLocation.Y, 234);
s2.LabelAnimation = Style.Slide;
s2.WindowSize = new Size(201, 212);
s2.WindowLocation = new Point(234, 235);
s2.SaveAll();

s1.LoadAll();
Assert.AreEqual(s1.LabelAnimation, Style.Slide);
Assert.AreEqual(s1.WindowSize.Width, 201);
Assert.AreEqual(s1.WindowSize.Height, 212);
Assert.AreEqual(s1.WindowLocation.X, 234);
Assert.AreEqual(s1.WindowLocation.Y, 235);
}

}
}
4 changes: 2 additions & 2 deletions PxKeystrokesUi/KeyboardHook.cs
Expand Up @@ -102,10 +102,10 @@ private void UnregisterKeyboardHook()
OnKeyEvent(e);
}

System.Diagnostics.Debug.WriteLine(
/*System.Diagnostics.Debug.WriteLine(
String.Format("Key: sc {0} vk {1} ext {2} fl {3}, {4}", lParam.scanCode,
lParam.vkCode, lParam.dwExtraInfo, lParam.flags, e.Method));

*/
}
//Pass key to next application
return NativeMethodsKeyboard.CallNextHookEx(hookID, nCode, wParam, ref lParam);
Expand Down
2 changes: 1 addition & 1 deletion PxKeystrokesUi/KeyboardRawEvent.cs
Expand Up @@ -49,7 +49,7 @@ public KeyboardRawEventArgs(NativeMethodsKeyboard.KBDLLHOOKSTRUCT Kbdllhookstruc
}
}

public delegate void KeyboardRawEventHandler(KeyboardRawEventArgs e);
public delegate void KeyboardRawEventHandler(KeyboardRawEventArgs e);

interface IKeyboardRawEventProvider : IDisposable
{
Expand Down
5 changes: 2 additions & 3 deletions PxKeystrokesUi/KeystrokeParser.cs
Expand Up @@ -98,9 +98,7 @@ void hook_KeyEvent(KeyboardRawEventArgs raw_e)
else if (!e.NoModifiers && !e.OnlyShiftOrCaps) // Special Char with Strg + Alt
// or shortcut else
{
System.Diagnostics.Debug.WriteLine(
String.Format("HERE"));


// could be something like the german @ (Ctrl + Alt + Q)
// Temporary disabled because ToUnicode returns more often values than it should
e.KeyString = "";// KeyboardLayoutParser.ParseViaToUnicode(e);
Expand Down Expand Up @@ -158,6 +156,7 @@ private void ParseTexttViaSpecialkeysParser(KeystrokeEventArgs e)
e.KeyString = SpecialkeysParser.ToString(e.Key);
e.ShouldBeDisplayed = true;
e.StrokeType = KeystrokeType.Text;
e.RequiresNewLineAfterwards = (Keys)e.vkCode == Keys.Return;
}
catch (NotImplementedException)
{
Expand Down
251 changes: 69 additions & 182 deletions PxKeystrokesUi/KeystrokesDisplay.Designer.cs

Large diffs are not rendered by default.

0 comments on commit c682bee

Please sign in to comment.