コード例 #1
0
        private static void OnMouse(int button, int wheel)
        {
            MouseOptions mouse = MouseOptions.None;

            if (button > 0)
            {
                mouse = SDLKeys.MouseButtonToMouseOptions(button);
            }

            if (wheel != 0)
            {
                mouse = wheel < 0 ? MouseOptions.MouseWheelDown : MouseOptions.MouseWheelUp;

                if (Options.CurrentOptions.LimitMouseWheelTrigger)
                {
                    TimeSpan diff = DateTime.Now - _lastMouseAction[(int)mouse];

                    if (diff <
                        TimeSpan.FromMilliseconds(Options.CurrentOptions.LimitMouseWheelTriggerMS))
                    {
                        return;
                    }
                }

                _lastMouseAction[(int)mouse] = DateTime.Now;
            }

            HotkeyManager.GetInstance().OnMouseAction(mouse);
        }
コード例 #2
0
ファイル: VMMain.cs プロジェクト: meteorsnows/SecondDesktop
        public VMMain()
        {
            Model = new MMain();
            AppWindowVisibility = Visibility.Hidden;
            MainWindowWidth     = SDSystem.WindowWidth;

            HotkeyManager.GetInstance().RegisterHotKey("ShowWindow", LKey.None, RKey.F2, ShowWindow);

            Swatches = new SwatchesProvider().Swatches;

            Window             win          = Application.Current.MainWindow;
            PresentationSource source       = PresentationSource.FromVisual(win);
            Matrix             matrix       = source.CompositionTarget.TransformFromDevice;
            double             widthRatio   = matrix.M11;
            double             heightRatio  = matrix.M22;
            double             screenWidth  = SystemParameters.PrimaryScreenWidth * widthRatio;
            double             screenHeight = SystemParameters.PrimaryScreenHeight * heightRatio;

            MainWindowHeight = SystemParameters.WorkArea.Size.Height * heightRatio;
            MainWindowLeft   = screenWidth - MainWindowWidth;

            MessageBoxMessage = "Are you sure delete this desktop page?";

            DesktopWindowManager.GetInstance().ThemeDark  = DesktopWindowManager.GetInstance().ThemeDark;
            DesktopWindowManager.GetInstance().ThemeColor = DesktopWindowManager.GetInstance().ThemeColor;
            IsThemeDark = DesktopWindowManager.GetInstance().ThemeDark;
        }
コード例 #3
0
        public static void Hotkeys(string onOff = "toggle")
        {
            HotkeyManager manager = HotkeyManager.GetInstance();

            switch (onOff.Trim().ToLower())
            {
            case "on":
            {
                manager.Enabled = true;
                break;
            }

            case "off":
            {
                manager.Enabled = false;
                break;
            }

            default:
            {
                manager.Enabled = !manager.Enabled;
                break;
            }
            }

            UOC.SystemMessage(manager.Enabled ? Strings.Hotkeys_enabled___ : Strings.Hotkeys_disabled___,
                              manager.Enabled ? 0x3F : 36);
        }
コード例 #4
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     ViewModel        = new VMMain();
     this.DataContext = ViewModel;
     AppManager.GetInstance().SelectAppNotify += SelectApp;
     HotkeyManager.GetInstance().StartListen();
 }
コード例 #5
0
        private static bool OnHotkeyPressed(int key, int mod, bool pressed)
        {
            Key keys = SDLKeys.SDLKeyToKeys(key);

            bool pass = HotkeyManager.GetInstance().OnHotkeyPressed(keys);

            return(!pass);
        }
コード例 #6
0
        public static void Hotkeys()
        {
            HotkeyManager manager = HotkeyManager.GetInstance();

            manager.Enabled = !manager.Enabled;

            UOC.SystemMessage(manager.Enabled ? Strings.Hotkeys_enabled___ : Strings.Hotkeys_disabled___, 0x3F);
        }
コード例 #7
0
        protected HotkeySettableViewModel(string name)
        {
            _name     = name;
            _category = new HotkeyEntry(_name, true);

            HotkeyManager hotkey = HotkeyManager.GetInstance();

            hotkey.AddCategory(_category);

            Items.CollectionChanged += OnCollectionChanged;

            _category.Children = new ObservableCollectionEx <HotkeySettable>();
        }
コード例 #8
0
        public void WontDuplicateSkillsCategory()
        {
            AppDomain appDomain = AppDomain.CreateDomain("WontThrowExceptionOnDeserializeNullConfig",
                                                         AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);

            appDomain.DoCallBack(() =>
            {
                const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

                if (!Directory.Exists(localPath))
                {
                    Debug.WriteLine("Not running test, requires Cliloc.enu");
                    return;
                }

                SkillsTabViewModel vm = new SkillsTabViewModel();

                Options options = Options.CurrentOptions;

                Skills.Initialize(localPath);

                JObject json = new JObject
                {
                    {
                        "Skills",
                        new JArray
                        {
                            new JObject
                            {
                                { "Name", "Hiding" },
                                {
                                    "Keys", new JObject {
                                        { "Keys", 94 }, { "SDLModifier", 0 }, { "Mouse", 7 }
                                    }
                                },
                                { "PassToUO", false }
                            }
                        }
                    }
                };

                vm.Deserialize(json, options);
                vm.Deserialize(json, options);

                HotkeyManager hotkeys = HotkeyManager.GetInstance();

                int count = hotkeys.Items.Count(hk => hk.IsCategory && hk.Name == Strings.Skills);

                Assert.AreEqual(1, count);
            });
        }
コード例 #9
0
        protected HotkeyEntryViewModel(string name)
        {
            _category = new HotkeyCommand {
                Name = name, IsCategory = true
            };

            HotkeyManager hotkey = HotkeyManager.GetInstance();

            hotkey.AddCategory(_category);

            Items.CollectionChanged += OnCollectionChanged;

            _category.Children = new ObservableCollectionEx <HotkeyEntry>();
        }
コード例 #10
0
        private static bool OnHotkeyPressed(int key, int mod, bool pressed)
        {
            Key keys = SDLKeyToKeys(key);

            if (pressed)
            {
                HotkeyPressedEvent?.Invoke(key, mod, keys, IntToModKey(mod));

                bool pass = HotkeyManager.GetInstance().OnHotkeyPressed(keys, IntToModKey(mod));

                return(!pass);
            }

            return(true);
        }
コード例 #11
0
 public HotkeysTabViewModel()
 {
     _hotkeyManager = HotkeyManager.GetInstance();
     _hotkeyManager.ClearAllHotkeys = ClearAllHotkeys;
 }
コード例 #12
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     HotkeyManager.GetInstance().RegisterHotKey("Test", LKey.Ctrl, RKey.D0, HotKey);
 }
コード例 #13
0
 public HotkeysTabViewModel()
 {
     _hotkeyManager = HotkeyManager.GetInstance();
 }