Ejemplo n.º 1
0
        private static bool OnPaste()
        {
            if (VisualExtension.IsInputFocused())
            {
                return(false);
            }

            try {
                if (Clipboard.ContainsData(DataFormats.FileDrop))
                {
                    var data = Clipboard.GetFileDropList().OfType <string>().ToList();
                    ActionExtension.InvokeInMainThreadAsync(() => ProcessArguments(data, true));
                    return(true);
                }

                if (Clipboard.ContainsData(DataFormats.UnicodeText))
                {
                    var list = Clipboard.GetText().ToLines();
                    if (list.Length > 0 && list.All(x => !string.IsNullOrWhiteSpace(x)))
                    {
                        ActionExtension.InvokeInMainThreadAsync(() => ProcessArguments(list, true));
                        return(true);
                    }
                }
            } catch (Exception e) {
                Logging.Warning(e);
            }

            return(false);
        }
Ejemplo n.º 2
0
 public NavigateCommand(MainWindow window, Uri uri) : base(true, false)
 {
     if (VisualExtension.IsInputFocused() && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
     {
         return;
     }
     _window = window;
     _uri    = uri;
 }
Ejemplo n.º 3
0
 private void OnContentInstallationTaskAdded(object o, EventArgs eventArgs)
 {
     _openDownloadsListBusy.Yield(() => {
         if (IsVisible && !VisualExtension.IsInputFocused() &&
             AppAppearanceManager.Instance.DownloadsInSeparatePage &&
             AppAppearanceManager.Instance.DownloadsPageAutoOpen)
         {
             NavigateTo(new Uri("/Pages/Miscellaneous/DownloadsList.xaml", UriKind.Relative));
         }
     });
 }
Ejemplo n.º 4
0
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers != ModifierKeys.Alt && Keyboard.Modifiers != (ModifierKeys.Alt | ModifierKeys.Shift) ||
                !SettingsHolder.Drive.QuickSwitches || VisualExtension.IsInputFocused())
            {
                return;
            }

            switch (e.SystemKey)
            {
            case Key.OemTilde:
                ToggleQuickSwitches();
                break;

            default:
                var k = e.SystemKey - Key.D1;
                if (k < 0 || k > 9)
                {
                    return;
                }

                InitializePopup();
                var child = GetQuickSwitches().ElementAtOrDefault(k);
                if (child == null)
                {
                    break;
                }

                QuickSwitchesNotification.SetValue(TextBlock.ForegroundProperty, child.GetValue(TextBlock.ForegroundProperty));

                if (child is ModernToggleButton toggle)
                {
                    toggle.IsChecked = !toggle.IsChecked;
                    ShowQuickSwitchesPopup(toggle.IconData, $@"{toggle.Content}: {toggle.IsChecked.ToReadableBoolean()}", child.ToolTip);
                    break;
                }

                if (child is ModernButton button)
                {
                    button.Command?.Execute(null);
                    ShowQuickSwitchesPopup(button.IconData, button.Content?.ToString(), child.ToolTip);
                    break;
                }

                if (child is QuickSwitchPresetsControl presets)
                {
                    if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
                    {
                        presets.SwitchToPrevious();
                    }
                    else
                    {
                        presets.SwitchToNext();
                    }
                    ShowQuickSwitchesPopup(presets.IconData, $@"{presets.CurrentUserPreset.DisplayName}", child.ToolTip);
                    break;
                }

                if (child is QuickSwitchComboBox combo && combo.Items.Count > 1)
                {
                    var index = combo.SelectedIndex;
                    combo.SelectedItem = combo.Items[(index + (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) ? -1 : 1) +
                                                      combo.Items.Count) % combo.Items.Count];
                    ShowQuickSwitchesPopup(combo.IconData, $@"{combo.SelectedItem}", child.ToolTip);
                    break;
                }

                if (child is QuickSwitchSlider slider)
                {
                    var step     = (slider.Maximum - slider.Minimum) / 6d;
                    var position = (((slider.Value - slider.Minimum) / step - 1).Clamp(0, 4).Round() +
                                    (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) ? -1 : 1) + 5) % 5;
                    slider.Value = slider.Minimum + (position + 1) * step;
                    ShowQuickSwitchesPopup(slider.IconData, $@"{slider.Content}: {slider.DisplayValue}", child.ToolTip);
                }

                // special case for controls presets
                if (child is DockPanel dock)
                {
                    if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
                    {
                        ControlsPresets.Instance.SwitchToPrevious();
                    }
                    else
                    {
                        ControlsPresets.Instance.SwitchToNext();
                    }

                    ShowQuickSwitchesPopup(dock.FindLogicalChild <Path>()?.Data, $@"{AcSettingsHolder.Controls.CurrentPresetName}", child.ToolTip);
                }

                break;
            }

            e.Handled = true;
        }