private void copyButton_Click(object sender, RoutedEventArgs e)
 {
     SharePathOperation.CopyPath(this.Source?.FullPath);
     this.HideFileOperationDialog();
 }
Exemple #2
0
        /// <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.Viewer));

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

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


            //var scrollDelta = 100;
            var zoom = 1.2;
            var shiftOrControlKey = new[] { ModifierKeys.Shift, ModifierKeys.Control };

            shiftOrControlKey.ForEach(m =>
            {
                keyReceiver.Register(
                    new[] { Key.Up, Key.Down, Key.Right, Key.Left },
                    (t, key) => this.ReceiveCursorKey(key, !this.CursorKeyForMove, zoom),
                    cursorFilter, isPreview: true, modifier: m);
            });


            keyReceiver.Register(
                new Key[] { Key.Up, Key.Down, Key.Right, Key.Left },
                (t, key) => this.ReceiveCursorKey(key, this.CursorKeyForMove, zoom),
                cursorFilter, isPreview: true);



            keyReceiver.Register(new[] { Key.Add, Key.OemPlus },
                                 (t, key) => this.ZoomImage(zoom), cursorFilter, modifier: ModifierKeys.Control);
            //keyReceiver.Register(k => (int)k == 187, (t, key) => this.ZoomImage(zoom),
            //    pageFilter, false, ModifierKeys.Control);

            keyReceiver.Register(new[] { Key.Subtract, Key.OemMinus },
                                 (t, key) => this.ZoomImage(1.0 / zoom), cursorFilter, modifier: ModifierKeys.Control);
            //keyReceiver.Register(k => (int)k == 189, (t, key) => this.ZoomImage(1.0 / zoom),
            //    pageFilter, false, ModifierKeys.Control);



            keyReceiver.Register(Key.PageUp, (t, key) => this.MovePrev(), pageFilter, isPreview: true);
            keyReceiver.Register(Key.PageDown, (t, key) => this.MoveNext(), pageFilter, isPreview: true);


            keyReceiver.Register(Key.Home, (t, key) => this.client.ViewerIndex.Value = 0,
                                 cursorFilter, isPreview: true);
            keyReceiver.Register(Key.End, (t, key) => this.client.ViewerIndex.Value = this.Length.Value - 1,
                                 cursorFilter, isPreview: true);


            keyReceiver.Register(Key.Escape, (t, key) =>
            {
                if (!this.IsTopBarOpen.Value && !this.parent.IsPaneOpen.Value)
                {
                    this.parent.IsFullScreen.Value = false;
                }
                else
                {
                    this.IsTopBarOpen.Value = false;
                }
            }, cursorFilter);


            keyReceiver.Register(new[] { Key.Space, Key.Enter },
                                 (t, key) => this.StartAutoScaling(), buttonFilter);
            //keyReceiver.Register(k => (int)k == 190, (t, key) => this.StartAutoScaling(), pageFilter);

            keyReceiver.Register(new[] { Key.Decimal, Key.OemPeriod },
                                 (t, key) => this.StartAutoScaling(), cursorFilter);


            keyReceiver.Register(new[] { Key.Space, Key.Enter },
                                 (t, key) => this.IsSlideshowPlaying.Toggle(), buttonFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(new[] { Key.Decimal, Key.OemPeriod },
                                 (t, key) => this.IsSlideshowPlaying.Toggle(), cursorFilter, modifier: ModifierKeys.Control);
            //keyReceiver.Register(k => (int)k == 190, (t, key) => this.StartSlideShow(),
            //    pageFilter, false, ModifierKeys.Control);



            keyReceiver.Register(new[] { Key.Add, Key.OemPlus },
                                 (t, key) => this.SetRating(true), cursorFilter);
            keyReceiver.Register(new[] { Key.Subtract, Key.OemMinus },
                                 (t, key) => this.SetRating(false), cursorFilter);
            //keyReceiver.Register(k => (int)k == 187, (t, key) => this.SetRating(true), pageFilter);
            //keyReceiver.Register(k => (int)k == 189, (t, key) => this.SetRating(false), pageFilter);

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


            keyReceiver.Register(Key.H, (t, key) => this.HorizontalMirror(),
                                 cursorFilter, modifier: ModifierKeys.Control);
            keyReceiver.Register(Key.V, (t, key) => this.VerticalMirror(),
                                 cursorFilter, modifier: ModifierKeys.Control);
            keyReceiver.Register(Key.E, (t, key) => this.Rotate(-1),
                                 cursorFilter, modifier: ModifierKeys.Control);
            keyReceiver.Register(Key.R, (t, key) => this.Rotate(1),
                                 cursorFilter, modifier: ModifierKeys.Control);

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

            keyReceiver.Register(Key.P, (t, key) =>
            {
                if (!parent.IsPaneFixed.Value)
                {
                    parent.TogglePane(OptionPaneType.ItemInfo);
                }
            }, cursorFilter, modifier: ModifierKeys.Control);



            keyReceiver.Register(Key.S, (t, key) => this.IsRandom.Toggle(),
                                 cursorFilter, modifier: ModifierKeys.Control);


            keyReceiver.Register(Key.L, (t, key) =>
            {
                SharePathOperation.OpenExplorer(this.Record.Value?.FullPath);
            }, cursorFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(Key.C, (t, key) =>
            {
                SharePathOperation.CopyPath(this.Record.Value?.FullPath);
            }, cursorFilter, modifier: ModifierKeys.Control);

            keyReceiver.Register(Key.Apps, (t, key) => this.TogglePane(), cursorFilter);


            keyReceiver.Register(Key.G, (t, key) => this.client.DisplayGroup(0),
                                 cursorFilter, modifier: ModifierKeys.Control);


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

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



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

            keyReceiver.Register(Key.F11, (t, key) => this.parent.IsFullScreen.Toggle(), cursorFilter);

#if DEBUG
            keyReceiver.Register(Key.Divide, async(t, key) =>
            {
                var index = await this.client.FindIndexFromDatabaseAsync(this.Record.Value);
                MessageBox.Show((index + 1).ToString());
            }, cursorFilter);
#endif
        }