public void SetShortKey(ShortKey key, bool newShortKey) { cbxCategory.DataSource = ShortKeyConfiguration.GetCategories(); shortKeyBindingSource.DataSource = key; cbxCategory.Text = key.Category; cbxCategory.Enabled = newShortKey; }
private static ShortKey FindShortKey(ShortKey key) { if (key != null) { return(CapturedShortKeys[key.Category].FirstOrDefault(o => o.Id == key.Id)); } return(null); }
public static async Task RemoveShortKey(ShortKey key) { if (key != null) { var shortKey = FindShortKey(key); if (shortKey != null) { CapturedShortKeys[key.Category].Remove(shortKey); await Save(); } } }
private void SaveCursorPosition() { if (chkSaveRepalcementKeyCursorPosition.Checked) { ShortKey key = GetShortKey(); string guid = Guid.NewGuid().ToString("N"); string replacementKey = key.ReplacementKey; replacementKey = replacementKey.Insert(txtReplacementKey.SelectionStart, guid); replacementKey = Keylogger.PerformNewLineFix(replacementKey); int index = replacementKey.IndexOf(guid); key.CursorLeftCount = replacementKey.Length - index - guid.Length; } }
private bool ValidateParams() { ShortKey key = GetShortKey(); try { key.Validate(); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "validation failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return(false); } }
public static async Task AddShortKey(ShortKey key) { if (key != null) { if (CapturedShortKeys.ContainsKey(key.Category)) { CapturedShortKeys[key.Category].Add(key); } else { CapturedShortKeys.Add(key.Category, new List <ShortKey>() { key }); } await Save(); } }
public static async Task UpdateShortKey(ShortKey key) { if (key != null) { if (!CapturedShortKeys.ContainsKey(key.Category)) { CapturedShortKeys.Add(key.Category, new List <ShortKey>()); } var shortKey = FindShortKey(key); if (shortKey != null) { foreach (PropertyInfo prop in typeof(ShortKey).GetProperties()) { if (prop.Name != "Id" && prop.Name != "Category") { prop.SetValue(shortKey, prop.GetValue(key)); } } } await Save(); } }