private void BackWardHotKey_OnHotKey(Keys key)
 {
     try
     {
         foreach (var it in HotKeyDic)
         {
             if (it.Value.Item1.Key == (uint)key)
             {
                 var Model = from models in HotKeyCollect where models.AxisName == it.Key select models;
                 if (Model != null && Model.Count() > 0)
                 {
                     HotKeyModel hotkeyModel = Model.First();
                     var         motion      = MotionMgr.Instance.FindMotionCardByAxisIndex(hotkeyModel.AxisNo);
                     var         arg         = motion.AxisArgsList[hotkeyModel.AxisNo - motion.MIN_AXIS].MoveArgs;
                     MotionMgr.Instance.MoveRel(hotkeyModel.AxisNo, 100, arg.Speed, -Math.Abs(arg.Distance / arg.Unit.Factor));
                 }
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Messenger.Default.Send <string>(ex.Message, "Error");
     }
 }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            var model = new HotKeyModel()
            {
                Shopee = _apiService.GetShopeeHotSearch().Adapt <ShopeeHotSearchModel>(),
                Tiki   = _apiService.GetTikiHotSearch().Adapt <TikiHotSearchModel>(),
                Sendo  = _apiService.GetSendoHotSearch().Adapt <SendoHotSearchModel>()
            };

            return(View(model));
        }
Exemplo n.º 3
0
 private ProgramData()
 {
     //            Instance = new ProgramData();
     Datas                    = new ObservableCollection <WindowsData>();
     IsWindowTopMost          = false;
     IsStartUpWithSystem      = false;
     Datas.CollectionChanged += Datas_CollectionChanged;
     CurrenTheme              = Themes.Blue;
     ShowAllHotKey            = new HotKeyModel()
     {
         IsSelectAlt = false, IsSelectCtrl = true, IsSelectShift = false, IsUsable = true, SelectKey = EKey.Q, Name = EHotKeySetting.ShowAllWindow.ToString()
     };
 }
        public SettingViewModel(SettingWindow win)
        {
            SettingWin = win;
            Datas      = ProgramData.Instance;
//            ShowAllHotKey = ProgramData.Instance.ShowAllHotKey;
            ShowAllHotKey = new HotKeyModel()
            {
                Name         = EHotKeySetting.ShowAllWindow.ToString(), SelectKey = EKey.Q, IsSelectAlt = false,
                IsSelectCtrl = true, IsSelectShift = false, IsUsable = true
            };

            IsTopMostChangedCommand           = new RelayCommand <bool>(IsTopMostChangedMethod);
            IsStartUpWithSystemChangedCommand = new RelayCommand <bool>(IsStartUpWithSystemChangedMethod);
            SelectionChangedCommand           = new RelayCommand <SelectionChangedEventArgs>(SelectionChangedMethod);
            ShowAllHotKeyChangedCommand       = new RelayCommand <KeyEventArgs>(ShowAllShortCutChangedMethod);
        }
Exemplo n.º 5
0
 private ProgramData()
 {
     //            Instance = new ProgramData();
     Datas                    = new ObservableCollection <WindowsData>();
     HideWindowData           = new ObservableCollection <WindowsData>();
     IsWindowTopMost          = false;
     IsStartUpWithSystem      = false;
     IsAutoCheckUpdate        = false;
     Datas.CollectionChanged += Datas_CollectionChanged;
     BaseTheme                = "Light";
     Language                 = Language.English;
     CurrentTheme             = "Blue";
     ShowAllHotKey            = new HotKeyModel()
     {
         IsSelectAlt = false, IsSelectCtrl = true, IsSelectShift = false, IsUsable = true, SelectKey = EKey.Q, Name = EHotKeySetting.ShowAllWindow.ToString()
     };
 }
Exemplo n.º 6
0
        /// <summary>
        /// 注册或替换快捷键
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="key"></param>
        /// <param name="modifierKeys"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool RegisterOrReplace(string identity, Key key, ModifierKeys modifierKeys, Action action)
        {
            lock (_lock)
            {
                try
                {
                    Remove(identity);

                    var hotKeyIdentity = new HotKeyIdentity(key, modifierKeys);

                    if (_hotKeyCache.ContainsKey(hotKeyIdentity))
                    {
                        _hotKeyCache[hotKeyIdentity].LinkedEventHandler(action, identity);
                    }
                    else
                    {
                        var hotKeyModel = new HotKeyModel(hotKeyIdentity);
                        hotKeyModel.RemoveAllLinkedEvent += HotKeyModelOnRemoveAllLinkedEvent;
                        hotKeyModel.LinkedEventHandler(action, identity);

                        _hotKeyCache.Add(hotKeyIdentity, hotKeyModel);
                    }

                    if (!string.IsNullOrEmpty(identity))
                    {
                        _identityCache.Add(identity, hotKeyIdentity);
                    }

                    return(true);
                }
                catch (HotkeyAlreadyRegisteredException hotkeyAlreadyRegisteredException)
                {
                    WindowsApi.WriteLog($"Hot key {hotkeyAlreadyRegisteredException.Name} already register");
                    HotkeyAlreadyRegistered?.Invoke(HotkeyManager.Current,
                                                    new HotkeyAlreadyRegisteredEventArgs(hotkeyAlreadyRegisteredException.Name));
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        private void ShowAllShortCutChangedMethod(KeyEventArgs e)
        {
            bool useCtrl  = false; //(e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            bool useAlt   = false; //(e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            bool useShift = false; //(e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;

            //            EKey useKey = EKey.Q;
            foreach (int v in Enum.GetValues(typeof(EKey)))
            {
                string keyName = Enum.GetName(typeof(EKey), v);
                if (e.Key.ToString() == keyName)
                {
                    var useKey = (EKey)v;
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        useCtrl = true;
                    }
                    if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                    {
                        useShift = true;
                    }
                    if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                    {
                        useAlt = true;
                    }
                    var oldHotKey = new HotKeyModel();
                    oldHotKey.IsSelectAlt   = ShowAllHotKey.IsSelectAlt;
                    oldHotKey.IsSelectCtrl  = ShowAllHotKey.IsSelectCtrl;
                    oldHotKey.IsSelectShift = ShowAllHotKey.IsSelectShift;
                    oldHotKey.Name          = ShowAllHotKey.Name;
                    oldHotKey.IsUsable      = ShowAllHotKey.IsUsable;
                    oldHotKey.SelectKey     = ShowAllHotKey.SelectKey;

                    ShowAllHotKey.IsSelectAlt   = useAlt;
                    ShowAllHotKey.IsSelectCtrl  = useCtrl;
                    ShowAllHotKey.IsSelectShift = useShift;
                    ShowAllHotKey.SelectKey     = useKey;
                    if (!useCtrl && !useAlt && !useShift)
                    {
                        return;
                    }
                    var hotKeyList = new ObservableCollection <HotKeyModel>
                    {
                        ShowAllHotKey
                    };
                    HotKeySettingsManager.Instance.IsShowAllWindowHotKeyNeedChanged = true;
                    if (!HotKeySettingsManager.Instance.RegisterGlobalHotKey(hotKeyList))
                    {
                        //todo
                        MessageBox.Show("快捷键注册失败,可能系统或其它软件存在冲突");
                        ShowAllHotKey = oldHotKey;
                    }
                    else
                    {
                        ProgramData.Instance.ShowAllHotKey = ShowAllHotKey;
                        HotKeyStr = ShowAllHotKey.ToString();
                        //this.SettingWin.ShowAllTB.Text = ShowAllHotKey.ToString();
                    }

                    return;
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 初始化注册快捷键
 /// </summary>
 /// <param name="hotKeyModelList">待注册热键的项</param>
 /// <returns>true:保存快捷键的值;false:弹出设置窗体</returns>
 private bool InitHotKey(HotKeyModel hotKeyModel = null)
 {
     // 注册全局快捷键
     return(HotKeyHelper.RegisterHotKey(hotKeyModel, m_Hwnd));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 通知注册系统快捷键事件处理函数
 /// </summary>
 /// <param name="hotKeyModelList"></param>
 /// <returns></returns>
 private bool Instance_RegisterGlobalHotKeyEvent(HotKeyModel hotKeyModel)
 {
     return(InitHotKey(hotKeyModel));
 }
Exemplo n.º 10
0
        private void ShowAllShortCutChangedMethod(KeyEventArgs e)
        {
            if (e.Key == Key.LeftAlt || e.Key == Key.RightAlt)
            {
                return;
            }

            if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                return;
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                return;
            }

            bool useCtrl  = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            bool useAlt   = (e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            bool useShift = (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
            EKey useKey   = EKey.Q;

            foreach (int v in Enum.GetValues(typeof(EKey)))
            {
                string keyName = Enum.GetName(typeof(EKey), v);
                if (e.Key.ToString() == keyName)
                {
                    useKey = (EKey)v;
                }
            }

            var         OldHotKey = ShowAllHotKey;
            HotKeyModel newModel  = ShowAllHotKey;

            newModel.IsSelectAlt               = useAlt;
            newModel.IsSelectCtrl              = useCtrl;
            newModel.IsSelectShift             = useShift;
            newModel.SelectKey                 = useKey;
            ProgramData.Instance.ShowAllHotKey = ShowAllHotKey;
            var hotKeyList = new ObservableCollection <HotKeyModel>
            {
                ShowAllHotKey
            };

            if (!HotKeySettingsManager.Instance.RegisterGlobalHotKey(hotKeyList))
            {
                MessageBox.Show("快捷键注册失败,可能与其他软件存在冲突");
                ShowAllHotKey = OldHotKey;
            }


            //清楚当前快捷键
            //todo
            //检测输入的快捷键是否可用
            //todo
            //将更新的快捷键输入文本框



            IsTopMostChangedCommand           = new RelayCommand <bool>(IsTopMostChangedMethod);
            IsStartUpWithSystemChangedCommand = new RelayCommand <bool>(IsStartUpWithSystemChangedMethod);
            SelectionChangedCommand           = new RelayCommand <SelectionChangedEventArgs>(SelectionChangedMethod);
            ShowAllHotKeyChangedCommand       = new RelayCommand <KeyEventArgs>(ShowAllShortCutChangedMethod);
        }