Exemplo n.º 1
0
        protected override void InitializeCore()
        {
            // get the theme from the current application
            var theme = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent(AppConfig.AccentColor),
                                        ThemeManager.GetAppTheme(AppConfig.AppTheme));

            _explorerCleaner          = new ExplorerCleaner(AppConfig);
            _explorerCleaner.Cleaned += (sender, args) => OnCleaned(args);
            _actionExecuter           =
                new ActionExecuter <ExplorerWindowCleanerClientOperator>(new ExplorerWindowCleanerClientOperator(this,
                                                                                                                 _explorerCleaner));
            DisposableCollection.Add(_actionExecuter);
            ResetBackgroundWorker(AppConfig.Interval, new BackgroundAction[] { new CleanerAction(this) });

            if (AppConfig.IsMouseHook)
            {
                RestoreClipboardHistories();

                MonitoringClipboard();

                CreateShortcutContextMenu();
                CreateClipboardContextMenu();

                _globalMouseHook              = new GlobalMouseHook();
                _globalMouseHook.MouseHooked += (sender, args) =>
                {
                    if (args.MouseButton == MouseButtons.Left)
                    {
                        _contextMenuClipboardHistories.Close(ToolStripDropDownCloseReason.AppFocusChange);
                        _contextMenuShortcuts.Close(ToolStripDropDownCloseReason.AppFocusChange);
                    }

                    if (args.IsDoubleClick)
                    {
                        if (args.MouseButton == MouseButtons.Right)
                        {
                            _contextMenuClipboardHistories.Tag = GetForegroundWindow();
                            _contextMenuClipboardHistories.Show(args.Point);
                        }
                        else if (args.MouseButton == MouseButtons.Left && args.IsDesktop)
                        {
                            _contextMenuShortcuts.Show(args.Point);
                            Debug.WriteLine($"Show Shortcut Menu. {args.Point}");
                        }
                        Debug.WriteLine("DoubleClick Mouse.");
                    }
                };
            }
        }
Exemplo n.º 2
0
 public ExplorerWindowCleanerClientOperator(ExplorerWindowCleanerClient explorerWindowCleanerClient, ExplorerCleaner explorerCleaner)
 {
     Client          = explorerWindowCleanerClient;
     ExplorerCleaner = explorerCleaner;
 }