コード例 #1
0
ファイル: Application.xaml.cs プロジェクト: sk8tz/SylphyHorn
        private void RegisterActions()
        {
            var settings = Settings.ShortcutKey;

            this.HookService
            .Register(settings.MoveLeft.ToShortcutKey(), hWnd => hWnd.MoveToLeft(this.VdmHelper))
            .AddTo(this);

            this.HookService
            .Register(settings.MoveLeftAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToLeft(this.VdmHelper)?.Switch())
            .AddTo(this);

            this.HookService
            .Register(settings.MoveRight.ToShortcutKey(), hWnd => hWnd.MoveToRight(this.VdmHelper))
            .AddTo(this);

            this.HookService
            .Register(settings.MoveRightAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToRight(this.VdmHelper)?.Switch())
            .AddTo(this);

            this.HookService
            .Register(settings.MoveNew.ToShortcutKey(), hWnd => hWnd.MoveToNew(this.VdmHelper))
            .AddTo(this);

            this.HookService
            .Register(settings.MoveNewAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToNew(this.VdmHelper)?.Switch())
            .AddTo(this);

            this.HookService
            .Register(
                settings.SwitchToLeft.ToShortcutKey(),
                _ => VirtualDesktopService.GetLeft()?.Switch(),
                () => Settings.General.OverrideWindowsDefaultKeyCombination || Settings.General.ChangeBackgroundEachDesktop)
            .AddTo(this);

            this.HookService
            .Register(
                settings.SwitchToRight.ToShortcutKey(),
                _ => VirtualDesktopService.GetRight()?.Switch(),
                () => Settings.General.OverrideWindowsDefaultKeyCombination || Settings.General.ChangeBackgroundEachDesktop)
            .AddTo(this);

            this.HookService
            .Register(settings.Pin.ToShortcutKey(), hWnd => hWnd.Pin())
            .AddTo(this);

            this.HookService
            .Register(settings.Unpin.ToShortcutKey(), hWnd => hWnd.Unpin())
            .AddTo(this);

            this.HookService
            .Register(settings.TogglePin.ToShortcutKey(), hWnd => hWnd.TogglePin())
            .AddTo(this);
        }
コード例 #2
0
        public void RegisterActions()
        {
            var settings = Settings.ShortcutKey;

            this._hookService
            .Register(() => settings.SwapDesktopLeft.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveLeft())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwapDesktopRight.ToShortcutKey(), hWnd => VirtualDesktopMoveService.MoveRight())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveLeft.ToShortcutKey(), hWnd => hWnd.MoveToLeft())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveLeftAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToLeft()?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveRight.ToShortcutKey(), hWnd => hWnd.MoveToRight())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveRightAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToRight()?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveNew.ToShortcutKey(), hWnd => hWnd.MoveToNew())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveNewAndSwitch.ToShortcutKey(), hWnd => hWnd.MoveToNew()?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(
                () => settings.SwitchToLeft.ToShortcutKey(), _ => VirtualDesktopService.GetLeft()?.Switch(),
                (ShortcutKeyPressedEventArgs args) => {
                if (Settings.General.SkipDefaultAnimation || Settings.General.ChangeBackgroundEachDesktop)
                {
                    return(true);
                }
                if (Settings.General.LoopDesktop && VirtualDesktopService.CachedNumber == 1)
                {
                    return(true);
                }
                if (IsDefaultLeft(args.ShortcutKey))
                {
                    return(false);
                }
                return(true);
            })
            .AddTo(this._disposable);

            this._hookService
            .Register(
                () => settings.SwitchToRight.ToShortcutKey(), _ => VirtualDesktopService.GetRight()?.Switch(),
                (ShortcutKeyPressedEventArgs args) => {
                if (Settings.General.SkipDefaultAnimation || Settings.General.ChangeBackgroundEachDesktop)
                {
                    return(true);
                }
                if (Settings.General.LoopDesktop && VirtualDesktopService.CachedNumber == VirtualDesktopService.CachedCount)
                {
                    return(true);
                }
                if (IsDefaultRight(args.ShortcutKey))
                {
                    return(false);
                }
                return(true);
            })
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchToPrevious.ToShortcutKey(), _ => VirtualDesktopService.SwitchToPrevious())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.CloseAndSwitchLeft.ToShortcutKey(), _ => VirtualDesktopService.CloseAndSwitchLeft())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.CloseAndSwitchRight.ToShortcutKey(), _ => VirtualDesktopService.CloseAndSwitchRight())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.Pin.ToShortcutKey(), hWnd => hWnd.Pin())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.Unpin.ToShortcutKey(), hWnd => hWnd.Unpin())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.TogglePin.ToShortcutKey(), hWnd => hWnd.TogglePin())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.PinApp.ToShortcutKey(), hWnd => hWnd.PinApp())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.UnpinApp.ToShortcutKey(), hWnd => hWnd.UnpinApp())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.TogglePinApp.ToShortcutKey(), hWnd => hWnd.TogglePinApp())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.RenameCurrent.ToShortcutKey(), _ => VirtualDesktopService.RaiseRenameEvent())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo1.ToShortcutKey(), _ => VirtualDesktopService.Get(1)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo2.ToShortcutKey(), _ => VirtualDesktopService.Get(2)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo3.ToShortcutKey(), _ => VirtualDesktopService.Get(3)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo4.ToShortcutKey(), _ => VirtualDesktopService.Get(4)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo5.ToShortcutKey(), _ => VirtualDesktopService.Get(5)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo6.ToShortcutKey(), _ => VirtualDesktopService.Get(6)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo7.ToShortcutKey(), _ => VirtualDesktopService.Get(7)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo8.ToShortcutKey(), _ => VirtualDesktopService.Get(8)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo9.ToShortcutKey(), _ => VirtualDesktopService.Get(9)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.SwitchTo10.ToShortcutKey(), _ => VirtualDesktopService.Get(10)?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo1.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(1)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo2.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(2)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo3.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(3)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo4.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(4)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo5.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(5)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo6.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(6)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo7.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(7)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo8.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(8)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo9.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(9)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveTo10.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(10)))
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo1.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(1))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo2.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(2))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo3.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(3))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo4.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(4))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo5.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(5))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo6.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(6))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo7.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(7))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo8.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(8))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo9.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(9))?.Switch())
            .AddTo(this._disposable);

            this._hookService
            .Register(() => settings.MoveAndSwitchTo10.ToShortcutKey(), hWnd => hWnd.MoveTo(VirtualDesktopService.Get(10))?.Switch())
            .AddTo(this._disposable);
        }