Esempio n. 1
0
 private void RegisterHotKeys()
 {
     if (LazySettings.SetupUseHotkeys && !_hotKeysLoaded)
     {
         _f10 = new Hotkey();
         _f10.KeyCode = Keys.F10;
         _f10.Windows = false;
         _f10.Pressed += delegate { PauseBot(); };
         try
         {
             if (!_f10.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F10 as hotkey");
             }
             else
             {
                 _f10.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F10 as hotkey");
         }
         _f9 = new Hotkey();
         _f9.KeyCode = Keys.F9;
         _f9.Windows = false;
         _f9.Pressed += delegate { StartStopBotting(); };
         try
         {
             if (!_f9.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F9 as hotkey");
             }
             else
             {
                 _f9.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F9 as hotkey");
         }
         _hotKeysLoaded = true;
     }
 }
Esempio n. 2
0
        // Récupération du raccourci de la hotkey
        private void registerHotkey(String raccourci, ref Hotkey hotkey, HotkeyMethodDelegate callback)
        {
            //Récupération et ajout des touches spéciales
            if (raccourci.Contains("CTRL"))
                hotkey.Control = true;
            if (raccourci.Contains("ALT"))
                hotkey.Alt = true;
            if (raccourci.Contains("MAJ"))
                hotkey.Shift = true;
            if (raccourci.Contains("WIN"))
                hotkey.Windows = true;

            //Récupération de la lettre
            String lettre = raccourci.Substring(raccourci.LastIndexOf("+") + 1);

            //Si lettre reconnue, ajout de celle-ci et enregistrement de la combinaison
            if (!Enum.IsDefined(typeof(Keys), lettre))
                afficheMessage("Hotkey", "Erreur de formatage du fichier de config");
            else
            {
                hotkey.KeyCode = (Keys)Enum.Parse(typeof(Keys), lettre, false);
                hotkey.Pressed += new System.ComponentModel.HandledEventHandler(callback);

                if (!hotkey.GetCanRegister(invokeControl))
                    afficheMessage("Hotkey", "Impossible d'enregistrer le raccourci");
                else
                    hotkey.Register(invokeControl);
            }
        }
Esempio n. 3
0
 private void Start()
 {
     if (_firstTime)
     {
         LoadFirstTime();
         _firstTime = false;
     }
     if (File.Exists(OurDirectory + "\\Rotations\\" + RotationSettings.LoadedRotationManager + ".xml"))
     {
         RotationManagerController = new RotationManagerController();
         RotationManagerController.Load(OurDirectory + "\\Rotations\\" + RotationSettings.LoadedRotationManager +
                                        ".xml");
     }
     foreach (Rotation rotation in RotationManagerController.Rotations.Where(r => r.Active))
     {
         try
         {
             CheckBuffAndKeys(rotation.Rules.GetRules);
             var hotkey = new Hotkey();
             hotkey.Windows = rotation.Windows;
             hotkey.Shift = rotation.Shift;
             hotkey.Alt = rotation.Alt;
             hotkey.Control = rotation.Ctrl;
             Rotation rotation1 = rotation;
             hotkey.KeyCode = (Keys) RotationSettings.KeysList.FirstOrDefault(k => k.Text == rotation1.Key).Code;
             hotkey.Pressed += delegate { StartRotation(rotation1.Name); };
             if (!hotkey.GetCanRegister(this))
             {
                 Logging.Write("Cannot register {0} as hotkey", rotation.Key);
             }
             else
             {
                 hotkey.Register(this);
                 _hotKeys.Add(hotkey);
             }
         }
         catch
         {
             Logging.Write("Cannot register {0} as hotkey", rotation.Key);
         }
     }
 }
Esempio n. 4
0
 ///<summary>
 ///  Call first
 ///</summary>
 public PathControl(PathProfile pathProfile)
 {
     InitializeComponent();
     DoubleBuffered = true;
     GraphView.BringToFront();
     _pathProfile = pathProfile;
     _pathLoadedThread = new Thread(LoadPath) {IsBackground = true};
     _pathLoadedThread.Start();
     if (LazySettings.SetupUseHotkeys)
     {
         _f7 = new Hotkey();
         _f7.KeyCode = Keys.F7;
         _f7.Windows = false;
         _f7.Pressed += delegate { AddSpot(); };
         try
         {
             if (!_f7.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F7 as hotkey");
             }
             else
             {
                 _f7.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F7 as hotkey");
         }
         _f8 = new Hotkey();
         _f8.KeyCode = Keys.F8;
         _f8.Windows = false;
         _f8.Pressed += delegate { AddNode(); };
         try
         {
             if (!_f8.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F8 as hotkey");
             }
             else
             {
                 _f8.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F8 as hotkey");
         }
     }
 }
Esempio n. 5
0
        private Hotkey SetHotKey(Keys keys, bool shift, bool control, bool alt, bool windows, ClipboardInfo selectedInfo)
        {
            try
            {
                int index = selectedInfo.INDEX;

                Hotkey hk = new Hotkey();
                hk.KeyCode = keys;
                hk.Shift = shift;
                hk.Control = control;
                hk.Alt = alt;
                hk.Windows = windows;

                switch (index)
                {
                    case 1:
                        hk.Pressed += new HandledEventHandler(hk_Pressed1);
                        break;
                    case 2:
                        hk.Pressed += new HandledEventHandler(hk_Pressed2);
                        break;
                    case 3:
                        hk.Pressed += new HandledEventHandler(hk_Pressed3);
                        break;
                    case 4:
                        hk.Pressed += new HandledEventHandler(hk_Pressed4);
                        break;
                    case 5:
                        hk.Pressed += new HandledEventHandler(hk_Pressed5);
                        break;
                    case 6:
                        hk.Pressed += new HandledEventHandler(hk_Pressed6);
                        break;
                    case 7:
                        hk.Pressed += new HandledEventHandler(hk_Pressed7);
                        break;
                    case 8:
                        hk.Pressed += new HandledEventHandler(hk_Pressed8);
                        break;
                    case 9:
                        hk.Pressed += new HandledEventHandler(hk_Pressed9);
                        break;
                    case 10:
                        hk.Pressed += new HandledEventHandler(hk_Pressed0);
                        break;
                    default:
                        break;
                }

                if (hk.GetCanRegister(this))
                {
                    hk.Register(this);
                    return hk;
                }

                return null;
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return null;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Activate CtrlCVMaster Shortcut Key
        /// </summary>
        public void ActivateShortcutKey(Keys keys, bool shift, bool control, bool alt, bool windows)
        {
            try
            {
                if (this.activateKey != null)
                    this.activateKey.Unregister();

                this.activateKey = new Hotkey();

                activateKey.KeyCode = keys;
                activateKey.Shift = shift;
                activateKey.Control = control;
                activateKey.Alt = alt;
                activateKey.Windows = windows;

                activateKey.Pressed += new HandledEventHandler(activateHk_Pressed);

                if (activateKey.GetCanRegister(this)) activateKey.Register(this);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }