Пример #1
0
        public static async Task Start()
        {
            if (GetDefaultConfigurationDirectory().Length == 0)
            {
                await Save();
            }
            Default = await Storage.ReadData <DefaultConfig>(null, DefaultConfigurationFileName);

            if (GetDefaultConfigurationDirectory().Length > 0)
            {
                foreach (var file in Directory.GetFiles(GetDefaultConfigurationDirectory(), $"*{CategoryFileExtension}", SearchOption.TopDirectoryOnly))
                {
                    List <ShortKey> shortKeys = await Storage.ReadData <List <ShortKey> >(null, Path.GetFileName(file));

                    if (shortKeys.Count > 0)
                    {
                        if (CapturedShortKeys.ContainsKey(shortKeys[0].Category))
                        {
                            CapturedShortKeys[shortKeys[0].Category].AddRange(shortKeys);
                        }
                        else
                        {
                            CapturedShortKeys.Add(shortKeys[0].Category, shortKeys);
                        }
                    }
                }
            }
            Keylogger.WatchedShortKeys = GetShortKeys();
            keylogger               = new Keylogger(Path.Combine(GetDefaultConfigurationDirectory(), "keys.log"), true);
            keylogger.Enabled       = true;
            keylogger.FlushInterval = 60000;
        }
Пример #2
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();
     }
 }
Пример #3
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();
     }
 }