Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            StartTime.SelectedDate = DateTime.Now.AddDays(-1);
            EndTime.SelectedDate   = DateTime.Now.AddDays(1);

            Monitor = new WindowMonitor("config.json");
            ana     = new Analyzer();
            RefreshData();
            RefreshButton.ToolTip = "Reload data analysis";
            DataContext           = this;

            /////////////
            // Asserts //
            /////////////

            int total             = 0;
            var hoy_mas_cambiados = ana.MostSwitchedProcess(DateTime.Now.AddHours(-1), DateTime.Now);

            foreach (Tuple <string, int> t in hoy_mas_cambiados)
            {
                Console.WriteLine(t);
                total += t.Item2;
            }
            Console.WriteLine("total: " + total);
            Debug.Assert(total == ana.CountSince(DateTime.Now.AddHours(-1)));
        }
Exemple #2
0
 public ProfileManager(WindowMonitor windowMonitor,
                       AudioSwitcher audioSwitcher,
                       IAudioDeviceLister activeDeviceLister,
                       ShowError showError)
 {
     _windowMonitor      = windowMonitor;
     _audioSwitcher      = audioSwitcher;
     _activeDeviceLister = activeDeviceLister;
     _showError          = showError;
 }
Exemple #3
0
        protected override void WndProc(ref Message m)
        {
            //Check for shutdown message from windows
            switch (m.Msg)
            {
            case WM_QUERYENDSESSION:
                var closingEvent = new RestartManagerEvent(RestartManagerEventType.Query);
                RestartManagerTriggered?.Invoke(this, closingEvent);
                m.Result = closingEvent.Result;
                Log.Information($"Received WM_QUERYENDSESSION responded {m.Result}");
                break;

            case WM_ENDSESSION:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.EndSession));
                Log.Information("Received WM_ENDSESSION");
                break;

            case WM_CLOSE:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.ForceClose));
                Log.Information("Received WM_CLOSE");
                break;

            case WM_DEVICECHANGE:
                DeviceChanged?.Invoke(this, new DeviceChangeEvent());
                break;

            case WM_HOTKEY:
                ProcessHotKeyEvent(m);
                break;
            }

            if (WindowDestroyed != null && m.Msg == _msgNotifyShell)
            {
                // Receive shell messages
                switch ((Interop.ShellEvents)m.WParam.ToInt32())
                {
                case Interop.ShellEvents.HSHELL_WINDOWDESTROYED:
                    var hwnd = User32.NativeMethods.HWND.Cast(m.LParam);
                    var(_, windowText, windowClass) = WindowMonitor.ProcessWindowInformation(hwnd);
                    Task.Factory.StartNew(() =>
                    {
                        WindowDestroyed?.Invoke(this, new WindowDestroyedEvent(hwnd));
                    });
                    break;
                }
            }

            base.WndProc(ref m);
        }
Exemple #4
0
        /// <summary>
        /// Initialises the plugin.
        /// </summary>
        /// <param name="host">The plugin host.</param>
        /// <returns>True if the plugin started successfully.</returns>
        public override bool Initialize(IPluginHost host)
        {
            // Start the window monitor so that we can modify new password entry windows.
            this.windowMonitor = new WindowMonitor(host);

            // Create the run as context menu item.
            ContextMenuStrip contextMenu = host.MainWindow.EntryContextMenu;

            contextMenu.Items.Add(new ToolStripSeparator());

            RunAsMenuItem runAsMenuItem = new RunAsMenuItem(host.MainWindow);

            runAsMenuItem.AddToContextMenu(host.MainWindow.EntryContextMenu);
            UIUtil.AssignShortcut(runAsMenuItem, Keys.Control | Keys.E);

            // Return true for a successful startup.
            return(true);
        }