misu

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ HEAD  →  ?path2? @ 1
/trunk/misu/BindKeyForm.cs
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Configuration;
using Gma.System.MouseKeyHook;
using misu.Properties;
 
namespace misu
{
@@ -17,6 +16,12 @@
 
#endregion
 
#region Public Enums, Properties and Fields
 
public Settings Settings { get; set; }
 
#endregion
 
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
 
private IKeyboardMouseEvents GlobalHook { get; }
@@ -37,6 +42,11 @@
GlobalHook = globalHook;
}
 
public BindKeyForm(IKeyboardMouseEvents globalHook, Settings settings) : this(globalHook)
{
Settings = settings;
}
 
#endregion
 
#region Event Handlers
@@ -51,16 +61,14 @@
e.Handled = true;
e.SuppressKeyPress = true;
 
Settings.Default.Keys = new StringCollection();
foreach (var key in BoundKeys.Distinct())
{
Settings.Default.Keys.Add(key.ToString());
}
var distinct = new List<Keys>(BoundKeys.Distinct());
 
this.Execute(() => { textBox1.Text = string.Join(" ", Settings.Default.Keys.OfType<string>()); });
Settings.Binding.Keys = distinct;
 
KeyBound?.Invoke(this, new KeyBoundEventArgs());
this.Execute(() => { textBox1.Text = Settings.Binding.ToString(); });
 
KeyBound?.Invoke(this, new KeyBoundEventArgs(Settings.Binding));
 
BoundKeys.Clear();
}
 
@@ -87,10 +95,7 @@
 
private void OnFormLoad(object sender, EventArgs e)
{
if (Settings.Default.Keys != null)
{
textBox1.Text = string.Join(" ", Settings.Default.Keys.OfType<string>());
}
textBox1.Text = Settings.Binding.ToString();
}
 
#endregion