Beispiel #1
0
 private void TogglePane()
 {
     if (!parent.IsPaneOpen.Value || parent.IsPaneFixed.Value)
     {
         if (this.IsTopBarOpen.Value)
         {
             if (!this.IsTopBarFixed.Value)
             {
                 this.IsTopBarOpen.Value = false;
             }
         }
         else
         {
             this.IsTopBarOpen.Value = true;
         }
     }
     if (!parent.IsPaneFixed.Value)
     {
         parent.ToggleInformationPane();
     }
 }
        /// <summary>
        /// キーボード操作を登録
        /// </summary>
        /// <param name="keyReceiver"></param>
        /// <param name="client"></param>
        private void RegisterKeyReceiver(ClientWindowViewModel parent)
        {
            var keyReceiver = parent.KeyReceiver;

            var pageFilter = keyReceiver.AddPreFilter(x =>
                                                      (client.SelectedPage.Value == PageType.Catalog));

            var cursorFilter = keyReceiver.AddPreFilter(x =>
            {
                if (client.SelectedPage.Value != PageType.Catalog)
                {
                    return(false);
                }
                return(!(x.FocusedControl is TextBox));
            });

            var buttonFilter = keyReceiver.AddPreFilter(x =>
            {
                if (client.SelectedPage.Value != PageType.Catalog)
                {
                    return(false);
                }
                return(!(x.FocusedControl is ButtonBase) && !(x.FocusedControl is TextBox));
            });


            keyReceiver.Register(Key.PageUp, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, -0.8)),
                                 pageFilter, isPreview: true);
            keyReceiver.Register(Key.PageDown, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, 0.8)),
                                 pageFilter, isPreview: true);

            keyReceiver.Register(Key.Up, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, -0.2)),
                                 pageFilter, isPreview: true);
            keyReceiver.Register(Key.Down, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, 0.2)),
                                 pageFilter, isPreview: true);

            keyReceiver.Register(Key.Home, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, double.NegativeInfinity)),
                                 pageFilter, isPreview: true);
            keyReceiver.Register(Key.End, (t, key)
                                 => this.RequestScrollAction?.Invoke(new Vector(0, double.PositiveInfinity)),
                                 pageFilter, isPreview: true);



            keyReceiver.Register(Key.A, (t, key) =>
            {
                if (this.SelectedItems.Count != this.client.Length.Value)
                {
                    this.client.SelectAllAsync().FireAndForget();
                }
                else
                {
                    this.SelectedItems.Clear();
                }
            }, pageFilter, modifier: ModifierKeys.Control);


            keyReceiver.Register(Key.N, (t, key) => this.SelectedItems.Clear(),
                                 pageFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(Key.C,
                                 (t, key) => this.parent.Core.CopySelectedItemsPath(this.SelectedItems),
                                 pageFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(Key.T, (t, key) => this.parent.ShowTagSelector(null),
                                 cursorFilter, modifier: ModifierKeys.Control);


            keyReceiver.Register(Key.Apps, (t, key) =>
            {
                if (!parent.IsPaneFixed.Value)
                {
                    parent.ToggleInformationPane();
                }
            }, cursorFilter);

            keyReceiver.Register(k => k >= Key.A && k <= Key.Z,
                                 (t, key) => this.SetTag(((char)(key - Key.A + 'a')).ToString()),
                                 cursorFilter);


            keyReceiver.Register(Key.Delete,
                                 async(t, key) => await this.client.DeleteSelectedFiles(false),
                                 cursorFilter);

            keyReceiver.Register(Key.Delete,
                                 async(t, key) => await this.client.DeleteSelectedFiles(true),
                                 cursorFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(Key.F5, (t, key) => this.client.Refresh(), cursorFilter);
        }