Пример #1
0
        private void WidgetView_OnClosing(object sender, CancelEventArgs e)
        {
            try
            {
                IsClosed = true;

                _introTimer?.Stop();
                _introTimer = null;

                _mouseChecker?.Dispose();

                HotkeyStore.RemoveHotkey(Id.Guid);

                ViewModel?.OnClose();
                ViewModel = null;

                SaveScrollPosition();

                if (_currentAppBarEdge != ABEdge.None)
                {
                    SetAsAppBar(ABEdge.None);
                }
            }
            catch
            {
                // ignored
            }

            App.WidgetViews.Remove(this);

            CloseAction?.Invoke();
        }
Пример #2
0
        public static void InitializeExtra()
        {
            WidgetHelper.LoadWidgetViews(App.Arguments.Contains("-systemstartup"));

            if (!App.Arguments.Contains("-systemstartup") && App.WidgetsSettingsStore.Widgets.Count == 0)
            {
                new ManageWidgets().Show();
            }

            CheckForUpdatesDelayed();

            foreach (var eventPair in App.WidgetsSettingsStore.EventActionPairs)
            {
                if (eventPair.Event is LaunchEvent evnt)
                {
                    if ((!evnt.SystemStartup || App.Arguments.Contains("-systemstartup")) &&
                        (evnt.Parameters.Count == 0 || !evnt.Parameters.Except(App.Arguments).Any()))
                    {
                        eventPair.Action.Execute();
                    }
                }

                if (eventPair.Event is HotkeyEvent hotkeyEvent)
                {
                    HotkeyStore.RegisterHotkey(hotkeyEvent.Hotkey, eventPair.Action.Execute);
                }
            }

            if (App.Arguments.Contains("show-backup-help"))
            {
                Popup.Show(
                    $"Backups may be available in {SettingsHelper.AppDocumentsDirectory}.\n\n" +
                    $"Restore them through \"Import\" in Options.");
            }
        }
Пример #3
0
 private static void Refresh(this EventActionPair pair)
 {
     if (pair.Event is HotkeyEvent hotkeyEvent)
     {
         hotkeyEvent.Hotkey.Disabled = pair.Disabled;
         HotkeyStore.RegisterHotkey(hotkeyEvent.Hotkey, pair.Action.Execute);
     }
 }
Пример #4
0
 public static void Remove(this ViewModel viewModel, Shortcut shortcut, bool msg = false)
 {
     if (msg &&
         Popup.Show($"Are you sure you want to remove \"{GetName(shortcut)}\"?",
                    MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.No)
     {
         return;
     }
     viewModel.Settings.Shortcuts.Remove(shortcut);
     if (shortcut.Hotkey.Key != Key.None)
     {
         HotkeyStore.RemoveHotkey(shortcut.Hotkey.Guid);
     }
 }
Пример #5
0
 public static void Remove(this EventActionId id)
 {
     if (Popup.Show("Are you sure you want to delete this event and action pair?", MessageBoxButton.YesNo,
                    MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.No)
     {
         return;
     }
     foreach (var pair in App.WidgetsSettingsStore.EventActionPairs.Where(x => x.Identifier.Guid == id.Guid).ToList())
     {
         App.WidgetsSettingsStore.EventActionPairs.Remove(pair);
         if (pair.Event is HotkeyEvent hotkeyEvent)
         {
             HotkeyStore.RemoveHotkey(hotkeyEvent.Hotkey);
         }
     }
 }
Пример #6
0
 public void ReloadShortcutHotKey(Shortcut shortcut)
 {
     HotkeyStore.RegisterHotkey(shortcut.Hotkey,
                                delegate { this.Execute(shortcut); });
 }