mirror of
https://github.com/tiennm99/time-mocker-csharp.git
synced 2026-06-06 08:12:39 +00:00
feat: undo auto refresh
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using TimeMocker.UI.Core;
|
||||
|
||||
@@ -59,9 +58,9 @@ namespace TimeMocker.UI.Forms
|
||||
|
||||
// -- Process tab
|
||||
private DataGridView dgvProcesses;
|
||||
private Button btnRefresh;
|
||||
private TextBox txtProcSearch;
|
||||
private Label lblProcSearch;
|
||||
private System.Timers.Timer _refreshTimer;
|
||||
|
||||
// -- Time panel (shared)
|
||||
private GroupBox grpTime;
|
||||
@@ -119,11 +118,6 @@ namespace TimeMocker.UI.Forms
|
||||
RefreshProcessList();
|
||||
UpdateTimePreview();
|
||||
ApplyTime(); // Initialize with current time
|
||||
|
||||
// Start auto-refresh timer (1 second interval)
|
||||
_refreshTimer = new System.Timers.Timer(1000);
|
||||
_refreshTimer.Elapsed += (s, e) => BeginInvoke((Action)(RefreshProcessList));
|
||||
_refreshTimer.Start();
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
@@ -243,7 +237,11 @@ namespace TimeMocker.UI.Forms
|
||||
txtProcSearch = new TextBox { Width = 180, Margin = new Padding(0, 6, 8, 0) };
|
||||
txtProcSearch.TextChanged += (s, e) => FilterProcessList();
|
||||
|
||||
toolbar.Controls.AddRange(new Control[] { lblProcSearch, txtProcSearch });
|
||||
btnRefresh = MakeButton("⟳ Refresh", 90, Color.FromArgb(100, 110, 120));
|
||||
btnRefresh.Margin = new Padding(0, 6, 4, 0);
|
||||
btnRefresh.Click += (s, e) => RefreshProcessList();
|
||||
|
||||
toolbar.Controls.AddRange(new Control[] { lblProcSearch, txtProcSearch, btnRefresh });
|
||||
toolbar.BackColor = Color.FromArgb(55, 62, 74);
|
||||
|
||||
// Single process list with Inject checkbox
|
||||
@@ -681,10 +679,6 @@ namespace TimeMocker.UI.Forms
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
// Stop auto-refresh timer
|
||||
_refreshTimer?.Stop();
|
||||
_refreshTimer?.Dispose();
|
||||
|
||||
// Save config
|
||||
_config.AutoInjectEnabled = chkWatcherEnabled.Checked;
|
||||
_config.Patterns.Clear();
|
||||
|
||||
Reference in New Issue
Block a user