private void OnProcessesMonitorUpdate(object sender, EventArgs e) { AvailableProcesses.SetObjects(ProcessHandler.CachedProcesses.Keys, true); this.LblInbound.Text = $"{ProxyRouter.InboundTotal.SizeSuffix()}"; this.LblOutbound.Text = $"{ProxyRouter.OutboundTotal.SizeSuffix()}"; }
/// <summary>Constructor.</summary> public ProcessSelectionDialog() { InitializeComponent(); // Hide the caret on the filter text box (by setting it to a transparent brush) m_defaultFilterTextBoxBrush = m_txtFilter.CaretBrush; m_txtFilter.CaretBrush = TRANSPARENT_BRUSH; // Use a custom sorting algorithm for the list of processes view ProcessComparer processComparer = new ProcessComparer(); ListCollectionView processesListCollectionView = (ListCollectionView)m_lstProcesses.ItemsSource; processesListCollectionView.CustomSort = processComparer; // Configure the Timer used to update the list of processes Action updateProcessesListAction = () => { Process selectedProcess = (Process)m_lstProcesses.SelectedItem; AvailableProcesses.Clear(); foreach (Process curProc in Process.GetProcesses()) { AvailableProcesses.Add(curProc); if (selectedProcess != null && curProc.Id == selectedProcess.Id) { m_lstProcesses.SelectedItem = curProc; } } }; m_processesListUpdateTimer.Elapsed += (sender, args) => { // Use the dispatcher to update the list of processes in the same Thread that // created the dialog this.Dispatcher.Invoke(updateProcessesListAction); }; // Manually fire the method that updates the list of processes, so that the list gets updated immediatelly // when the dialog is opened updateProcessesListAction(); m_processesListUpdateTimer.Start(); }
private void AvailableProcesses_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Space) { if (AvailableProcesses.SelectedObjects != null) { foreach (var selectedObject in AvailableProcesses.SelectedObjects.OfType <string>()) { if (ProcessHandler.CachedProcesses.ContainsKey(selectedObject)) { foreach (var child in ProcessHandler.CachedProcesses[selectedObject]) { child.Value.RoutingEnabled = !child.Value.RoutingEnabled; } } AvailableProcesses.RefreshObject(selectedObject); } } e.Handled = true; } }