Ejemplo n.º 1
0
        public void Process()
        {
            HotKeysView = HotKeysMapping.ToView();

            LightTheme = !DarkTheme;

            TrayIcon.SetIcon(DarkTheme ? AppResources.tray_icon : AppResources.tray_icon_black);
            MultiClip.Config.MaxHistoryDepth = MaxHistoryItems;
            Operations.ConfigAppStartup(StartWithWindows);
        }
Ejemplo n.º 2
0
 public SettingsViewModel()
 {
     HotKeysView             = HotKeysMapping.ToView();
     MaxHistoryItems         = 40;
     DarkTheme               = true;
     LightTheme              = false;
     RestoreHistoryAtStartup = true;
     PasteAfterSelection     = true;
     StartWithWindows        = true;
 }
Ejemplo n.º 3
0
        public void Run()
        {
            bool justCreated = SettingsView.EnsureDefaults();

            bool clearAtStartup = !SettingsViewModel.Load().RestoreHistoryAtStartup;

            ClipboardMonitor.Start(clearAtStartup);

            TrayIcon.ShowHistory  = (s, a) => HistoryView.Popup();
            TrayIcon.ShowSettings = (s, a) => SettingsView.Popup();
            TrayIcon.Rehook       = (s, a) => { ClipboardMonitor.Restart(); TrayIcon.RefreshIcon(); };
            TrayIcon.Test         = (s, a) => ClipboardMonitor.Test();
            TrayIcon.Exit         = (s, a) => this.Close();
            TrayIcon.Init();

            hotKeys.Start();

            HotKeysMapping.EmbeddedHandlers[HistoryView.PopupActionName]            = HistoryView.Popup;
            HotKeysMapping.EmbeddedHandlers[ClipboardMonitor.ToPlainTextActionName] = ClipboardMonitor.ToPlainText;
            HotKeysMapping.EmbeddedHandlers[HotKeysView.PopupActionName]            = HotKeysView.Popup;
            HotKeysMapping.EmbeddedHandlers[ClipboardMonitor.RestartActionName]     = ClipboardMonitor.Restart;

            HotKeysMapping.Bind(hotKeys, TrayIcon.InvokeMenu);

            var timer     = new System.Windows.Threading.DispatcherTimer();
            var lastCheck = DateTime.Now;

            timer.Tick += (s, e) =>
            {
                ClipboardMonitor.Test();

                if ((DateTime.Now - lastCheck) > TimeSpan.FromMinutes(5)) // to ensure that after a long sleep we are restarting
                {
                    ClipboardMonitor.Restart();
                }

                lastCheck = DateTime.Now;

                // refreshing works but I am not convinced it is beneficial enough to be released
                // it also creates a short flickering effect every minute.
                // TrayIcon.RefreshIcon();
            };

            timer.Interval = TimeSpan.FromMinutes(1);

            timer.Start();

            var test2 = "The quick brown fox jumps over a lazy dog" + DateTime.Now;

            if (justCreated)
            {
                SettingsView.Popup(); //can pop it up without any side effect only after all messaging is initialized
            }
            SystemEvents.PowerModeChanged += OnPowerChange;
        }
Ejemplo n.º 4
0
        public static void Popup()
        {
            if (activeView == null)
            {
                try
                {
                    HotKeys.Instance.UnregisterAll();

                    (activeView = new SettingsView()).ShowDialog();
                }
                catch { }
                finally
                {
                    activeView = null;

                    HotKeysMapping.Bind(HotKeys.Instance, TrayIcon.InvokeMenu);
                }
            }
        }
Ejemplo n.º 5
0
 void HotKeyEditorHide_Click(object sender, RoutedEventArgs e)
 {
     HotKeyEditor.viewModel.UpdateCurrentSelection(); //to capture changes if any
     HotKeysMapping.Save(HotKeyEditor.viewModel.HotKeys);
     viewModel.RefreshHotKeysView();
 }
Ejemplo n.º 6
0
 void Window_Closed(object sender, EventArgs e)
 {
     viewModel.Process();
     viewModel.Save();
     HotKeysMapping.Save(HotKeyEditor.viewModel.HotKeys);
 }
Ejemplo n.º 7
0
 public void RefreshHotKeysView()
 {
     HotKeysView = HotKeysMapping.ToView();
 }