Ejemplo n.º 1
0
 /// <summary>
 /// The constructor for the history MenuItem
 /// </summary>
 /// <param name="dopyContextMenuTranslations"></param>
 public RestoreMenuItem(IDopyTranslations dopyContextMenuTranslations)
 {
     // automatically update the DisplayName
     dopyContextMenuTranslations.CreateDisplayNameBinding(this, nameof(IDopyTranslations.Restore));
     Id   = "A_Restore";
     Icon = new PackIconMaterial
     {
         Kind = PackIconMaterialKind.Restore
     };
 }
Ejemplo n.º 2
0
 /// <summary>
 /// The constructor for the history MenuItem
 /// </summary>
 /// <param name="dopyContextMenuTranslations"></param>
 public TitleMenuItem(IDopyTranslations dopyContextMenuTranslations)
 {
     // automatically update the DisplayName
     dopyContextMenuTranslations.CreateDisplayNameBinding(this, nameof(IDopyTranslations.Process));
     Id    = "_Title";
     Style = MenuItemStyles.Title;
     Icon  = new PackIconMaterial
     {
         Kind = PackIconMaterialKind.Clipboard
     };
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 public FormatsViewModel(
     IDopyTranslations dopyTranslations,
     IDopyConfiguration dopyConfiguration)
 {
     DopyTranslations  = dopyTranslations;
     DopyConfiguration = dopyConfiguration;
     dopyTranslations.CreateDisplayNameBinding(this, nameof(IDopyTranslations.FormatsConfigTitle));
     Id = "F_Formats";
     SelectedFormats = new ObservableCollection <string>(DopyConfiguration.IncludeFormats);
     using var clipboardAccessToken = ClipboardNative.Access();
     AvailableFormats = new ObservableCollection <string>(clipboardAccessToken.AvailableFormats());
 }
Ejemplo n.º 4
0
 /// <summary>
 /// The constructor for the history MenuItem
 /// </summary>
 /// <param name="dopyContextMenuTranslations"></param>
 /// <param name="clipRepository">IClipRepository to perform actions on</param>
 public DeleteMenuItem(IDopyTranslations dopyContextMenuTranslations,
                       IClipRepository clipRepository)
 {
     _clipRepository = clipRepository;
     // automatically update the DisplayName
     dopyContextMenuTranslations.CreateDisplayNameBinding(this, nameof(IDopyTranslations.Delete));
     Id   = "B_Delete";
     Icon = new PackIconMaterial
     {
         Kind = PackIconMaterialKind.Delete
     };
 }
Ejemplo n.º 5
0
        /// <summary>
        /// The constructor for the history MenuItem
        /// </summary>
        /// <param name="dopyContextMenuTranslations"></param>
        /// <param name="windowManager"></param>
        /// <param name="historyViewModelFactory"></param>
        public HistoryMenuItem(
            IDopyTranslations dopyContextMenuTranslations,
            IWindowManager windowManager,
            Func <Owned <HistoryViewModel> > historyViewModelFactory
            )
        {
            // automatically update the DisplayName
            dopyContextMenuTranslations.CreateDisplayNameBinding(this, nameof(IDopyTranslations.History));
            Id   = "Y_History";
            Icon = new PackIconMaterial
            {
                Kind = PackIconMaterialKind.History
            };

            // Key to react to
            var controlShiftPasteKey = new KeyCombinationHandler(VirtualKeyCode.Control, VirtualKeyCode.Shift, VirtualKeyCode.KeyV);

            KeyboardHook.KeyboardEvents
            // The hotkey to listen do
            .Where(controlShiftPasteKey)
#if !NETCOREAPP3_1
// TODO: What about dotnet core 3.0?
            // Make sure it's on the dispatcher
            .SubscribeOnDispatcher()
#endif
            // What to do
            .Subscribe(args =>
            {
                if (IsEnabled)
                {
                    Click(this);
                }
                args.Handled = true;
            });

            HotKeyHint  = "Ctrl + Shift + V";
            ClickAction = clickedItem =>
            {
                IsEnabled = false;

                try
                {
                    using var historyViewModel = historyViewModelFactory();
                    windowManager.ShowDialog(historyViewModel.Value);
                }
                finally
                {
                    IsEnabled = true;
                }
            };
        }