Ejemplo n.º 1
0
 public void SetShortKey(ShortKey key, bool newShortKey)
 {
     cbxCategory.DataSource           = ShortKeyConfiguration.GetCategories();
     shortKeyBindingSource.DataSource = key;
     cbxCategory.Text    = key.Category;
     cbxCategory.Enabled = newShortKey;
 }
Ejemplo n.º 2
0
 private static ShortKey FindShortKey(ShortKey key)
 {
     if (key != null)
     {
         return(CapturedShortKeys[key.Category].FirstOrDefault(o => o.Id == key.Id));
     }
     return(null);
 }
Ejemplo n.º 3
0
 public static async Task RemoveShortKey(ShortKey key)
 {
     if (key != null)
     {
         var shortKey = FindShortKey(key);
         if (shortKey != null)
         {
             CapturedShortKeys[key.Category].Remove(shortKey);
             await Save();
         }
     }
 }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 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();
     }
 }
Ejemplo n.º 7
0
 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();
     }
 }