From 8e2a92ad2e5fdd7e3083714575e81bd6f237734f Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 2 Jul 2026 11:58:15 +0200 Subject: [PATCH] Phase 5-UI: JobsView extrahiert + Trading-Toggle in die Quickbar - Neue JobsView (UserControl + Designer): DataGridView an JobManager.Jobs, Run-Now/Aktiv-Verhalten wie bisheriger Jobs-Tab. btn_jobs in toolstrip_windows, als View "core.jobs" registriert. - Trading-Toggle aus frm_main uebernommen: btn_liveTrading + btn_demoTrading in toolstrip_quickbar; Zyklus Inactive->SellOnly->Active mit Farb-/Textstatus, synchron zum TradingState (auch bei externen Aenderungen via 1s-Timer). - Build 0 Fehler. Co-Authored-By: Claude Opus 4.8 --- Program.cs | 15 ++++ Properties/Resources.Designer.cs | 10 +++ Properties/Resources.resx | 19 +++-- Resources/error_log.png | Bin 0 -> 2120 bytes Ui/LauncherForm.Designer.cs | 58 +++++++++++--- Ui/LauncherForm.cs | 54 +++++++++++++ Ui/Views/JobsView.Designer.cs | 129 +++++++++++++++++++++++++++++++ Ui/Views/JobsView.cs | 48 ++++++++++++ 8 files changed, 313 insertions(+), 20 deletions(-) create mode 100644 Resources/error_log.png create mode 100644 Ui/Views/JobsView.Designer.cs create mode 100644 Ui/Views/JobsView.cs diff --git a/Program.cs b/Program.cs index 69da252..6688087 100644 --- a/Program.cs +++ b/Program.cs @@ -161,6 +161,21 @@ internal static class Program return view; } }); + uiHost.RegisterView(new PolyTrader.Core.Modularity.ModuleView + { + Id = "core.jobs", + Title = "Server Jobs", + Group = "Core", + Order = 30, + PreferredWidth = 1000, + PreferredHeight = 500, + CreateControl = () => + { + var view = new PolyTraderSharp.Ui.Views.JobsView(); + view.Initialize(viewServices.GetRequiredService()); + return view; + } + }); // TODO Phase 5-UI: registrierte IPolyTraderModule durchlaufen und module.RegisterUi(uiHost) aufrufen. var launcher = AppHost.Services.GetRequiredService(); diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 386f5ab..b93d4b0 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -120,6 +120,16 @@ namespace PolyTraderSharp.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap error_log { + get { + object obj = ResourceManager.GetObject("error_log", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index c6f6195..fdb4711 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -118,9 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\diskette.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -157,16 +154,22 @@ ..\Resources\traffic_lights_red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\money_dollar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\money_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\accept_button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\setting_tools.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\accept_button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\money_dollar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\error_log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/error_log.png b/Resources/error_log.png new file mode 100644 index 0000000000000000000000000000000000000000..041f8ebb88a541027c11ec158d1419758c0ee92c GIT binary patch literal 2120 zcmaJ?dpMN&9v_!MB3U(*mAA2U!Q7Y`Gixwr%$hPxIN@k9W?p76^NyKeE<{u|oqf*c z7Tu&xQY}tP<(gZY5b22H+1!d9w$SEsij~f2)1E($^FGh}{w~kw^ZDLB&+}%oeZMj` z+-?Yi!Hk*SbbrkXtiA?%ny*x)n%6AbWM09t04Pc(=SV;pl?O$F08_|`2K_+}PZ{41 zy24;ONI_t*ESTj(=0ZXgXBC4|2*nyU4Cd;t5OcV(pbUrvqXi-g@>N|U5)kkx$RIom z!xGa#zQ9{00RvRNfm~HAm&8N5y8*5WvPM7%$~b^R7$=gF6%^zLU9x7sdW}W`A0V<= z3i6Mnf>~^U21!5wkHR=|F$63?a7JOBF(hY_1AxO|F=#9fjUhT>F=RZEjKKmQAEYLl zgcn8jr!zjr(wrzrzDy=2qtSA?93^)`L6T@RmP8_$i zK`B=v5X%IR2v}9*L_!HN3R08lA0-IIpJYYSk8RR446WdZ(O48_wWKv5i}nAZLg6R0 zROS!I0**Rt!L7yfr_82f`(!b zd2Ml*z8Z?_PYyQED>h&uSp-{_{mz?{ z(b_0HjDET#Hn4PNMQLr!>2XkArxjXH$P+(53gw?3eLlXWK7M9ue8F<$9ogyK@VPz* z4&OB(blWA2MV1}LvL)gyB3ro|XGE(p+it_*$Hb&b$6i+wvpe4$up%3HY+#N_M+?8z zw%L3dewty(W)j{FV|=VVx^G{qso8K1{`@j`nwZm`LNr+AmOV8?4ZpUn&WW+q>>RN1$*-%S~Ky1zAa;*q}IwU=-uEn(w>-8{G@ zGL?rB32#2Wcbo}n>HfR>-tm8?pY^%=1?fV2(+>YVN>?>M>DBvVX zSHAICq}J@~=$I>cb_G?D_^WPJ1kBiUAPH|&CZB7PphTmKe|0QQwzhEpY*RBkzpEFf zdzJIxvp43g21HN0FLFBnaX8lUwn*5l?zane@vSYJcEtQr{X9R1*r0rRuArr)04iVz z5k+Ril-V@7WVtIsw>PuB?Ztd?z|}fur?F7)iOh_QjG|zNegjy*i}vUsVD_pzY6{cS*WZ~IG##JYXIFfg)K*sqPraZZ`HmPF89gy58uge@J9@a#(+ZUZuhKup zqf{qf7-U-q0Wmrr#Ip~zn;eSvGh7%?d+M?jV0AuxPkv*JR_N9v+y34pvOIeGo9ZG~ zR>zwwxrJMo^zz8HUmXg&0r!E9sZ<;9hE(e{H0(;w*<@nU+S1}WKYuUT4e{kO+lz!9 ze_Jq|3jo{}jPpyw@0;)6VkW3}vQAmq`3SgpYi=;!Fg3_J?CR* z-+yI6a4`nX4B`Ctwzr~aVGR9v*{D41-FC;GjW#xyG483xeh9N&mR44C;NCHYb4X+1 zqx0LYb!mrOeNg#hYUIF4|A zHu0N7j{H87ltpc8JmiC|x)Twe8~aN8b;fSHeRtHYQohLswE>Gw2yelg!dqzgkJMt8+ zGo5=o^2#eJOzyX}b>8nI;zOG94({%6*EX0vg*eq*>>F004)4=~(hr23q;w*x?*1k0 zgonyDF9y+PKe6DP=IvKSSG_L_?RaT3kbrDpN1IIk@;Y_?UpXu0Z-0-0dCvOLTAk*# k54s$|f9Vo4@*ZvhgO7U@ecNN7wfb*odim1JJtNZp195m|9RL6T literal 0 HcmV?d00001 diff --git a/Ui/LauncherForm.Designer.cs b/Ui/LauncherForm.Designer.cs index ef6838c..97b2b16 100644 --- a/Ui/LauncherForm.Designer.cs +++ b/Ui/LauncherForm.Designer.cs @@ -24,13 +24,17 @@ namespace PolyTraderSharp.Ui toolstrip_windows = new ToolStrip(); btn_settings = new ToolStripButton(); btn_terminal = new ToolStripButton(); + btn_jobs = new ToolStripButton(); toolstrip_quickbar = new ToolStrip(); + btn_liveTrading = new ToolStripButton(); + btn_demoTrading = new ToolStripButton(); statusStrip_info = new StatusStrip(); lbl_trading = new ToolStripStatusLabel(); lbl_modules = new ToolStripStatusLabel(); lbl_ratelimit = new ToolStripStatusLabel(); menuStrip.SuspendLayout(); toolstrip_windows.SuspendLayout(); + toolstrip_quickbar.SuspendLayout(); statusStrip_info.SuspendLayout(); SuspendLayout(); // @@ -67,7 +71,7 @@ namespace PolyTraderSharp.Ui // toolstrip_windows.AutoSize = false; toolstrip_windows.ImageScalingSize = new Size(64, 64); - toolstrip_windows.Items.AddRange(new ToolStripItem[] { btn_settings, btn_terminal }); + toolstrip_windows.Items.AddRange(new ToolStripItem[] { btn_settings, btn_terminal, btn_jobs }); toolstrip_windows.Location = new Point(0, 35); toolstrip_windows.Name = "toolstrip_windows"; toolstrip_windows.Size = new Size(2599, 70); @@ -81,59 +85,84 @@ namespace PolyTraderSharp.Ui btn_settings.ImageScaling = ToolStripItemImageScaling.None; btn_settings.ImageTransparentColor = Color.Magenta; btn_settings.Name = "btn_settings"; - btn_settings.Size = new Size(112, 65); + btn_settings.Size = new Size(80, 65); btn_settings.Text = "Settings"; btn_settings.TextImageRelation = TextImageRelation.ImageAboveText; // // btn_terminal // - btn_terminal.DisplayStyle = ToolStripItemDisplayStyle.Text; + btn_terminal.Image = Properties.Resources.error_log; + btn_terminal.ImageScaling = ToolStripItemImageScaling.None; btn_terminal.Name = "btn_terminal"; - btn_terminal.Size = new Size(112, 65); - btn_terminal.Text = "Terminal"; + btn_terminal.Size = new Size(136, 65); + btn_terminal.Text = "Terminal / Logs"; + btn_terminal.TextImageRelation = TextImageRelation.ImageAboveText; + // + // btn_jobs + // + btn_jobs.DisplayStyle = ToolStripItemDisplayStyle.Text; + btn_jobs.Name = "btn_jobs"; + btn_jobs.Size = new Size(100, 65); + btn_jobs.Text = "Server Jobs"; // // toolstrip_quickbar // toolstrip_quickbar.ImageScalingSize = new Size(24, 24); + toolstrip_quickbar.Items.AddRange(new ToolStripItem[] { btn_liveTrading, btn_demoTrading }); toolstrip_quickbar.Location = new Point(0, 105); toolstrip_quickbar.Name = "toolstrip_quickbar"; - toolstrip_quickbar.Size = new Size(2599, 25); + toolstrip_quickbar.Size = new Size(2599, 28); toolstrip_quickbar.TabIndex = 4; toolstrip_quickbar.Text = "toolStrip2"; // + // btn_liveTrading + // + btn_liveTrading.DisplayStyle = ToolStripItemDisplayStyle.Text; + btn_liveTrading.Name = "btn_liveTrading"; + btn_liveTrading.Size = new Size(200, 25); + btn_liveTrading.Text = "LiveTrading (—)"; + // + // btn_demoTrading + // + btn_demoTrading.DisplayStyle = ToolStripItemDisplayStyle.Text; + btn_demoTrading.Name = "btn_demoTrading"; + btn_demoTrading.Size = new Size(200, 25); + btn_demoTrading.Text = "DemoTrading (—)"; + // // statusStrip_info // + statusStrip_info.BackColor = Color.Gainsboro; statusStrip_info.ImageScalingSize = new Size(24, 24); statusStrip_info.Items.AddRange(new ToolStripItem[] { lbl_trading, lbl_modules, lbl_ratelimit }); - statusStrip_info.Location = new Point(0, 924); + statusStrip_info.Location = new Point(0, 133); statusStrip_info.Name = "statusStrip_info"; - statusStrip_info.Size = new Size(2599, 22); + statusStrip_info.Size = new Size(2599, 32); statusStrip_info.TabIndex = 5; statusStrip_info.Text = "statusStrip1"; // // lbl_trading // lbl_trading.Name = "lbl_trading"; - lbl_trading.Size = new Size(100, 16); + lbl_trading.Size = new Size(97, 25); lbl_trading.Text = "Trading: —"; // // lbl_modules // lbl_modules.Name = "lbl_modules"; - lbl_modules.Size = new Size(90, 16); + lbl_modules.Size = new Size(100, 25); lbl_modules.Text = "Module: —"; // // lbl_ratelimit // lbl_ratelimit.Name = "lbl_ratelimit"; - lbl_ratelimit.Size = new Size(80, 16); + lbl_ratelimit.Size = new Size(66, 25); lbl_ratelimit.Text = "API: —"; // // LauncherForm // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(2599, 946); + ClientSize = new Size(2599, 165); Controls.Add(statusStrip_info); Controls.Add(toolstrip_quickbar); Controls.Add(toolstrip_windows); @@ -147,6 +176,8 @@ namespace PolyTraderSharp.Ui menuStrip.PerformLayout(); toolstrip_windows.ResumeLayout(false); toolstrip_windows.PerformLayout(); + toolstrip_quickbar.ResumeLayout(false); + toolstrip_quickbar.PerformLayout(); statusStrip_info.ResumeLayout(false); statusStrip_info.PerformLayout(); ResumeLayout(false); @@ -162,7 +193,10 @@ namespace PolyTraderSharp.Ui private ToolStrip toolstrip_windows; private ToolStripButton btn_settings; private ToolStripButton btn_terminal; + private ToolStripButton btn_jobs; private ToolStrip toolstrip_quickbar; + private ToolStripButton btn_liveTrading; + private ToolStripButton btn_demoTrading; private StatusStrip statusStrip_info; private ToolStripStatusLabel lbl_trading; private ToolStripStatusLabel lbl_modules; diff --git a/Ui/LauncherForm.cs b/Ui/LauncherForm.cs index 80b4ec5..e6a4c06 100644 --- a/Ui/LauncherForm.cs +++ b/Ui/LauncherForm.cs @@ -31,12 +31,63 @@ namespace PolyTraderSharp.Ui btn_settings.Click += (_, _) => OpenView("core.settings"); btn_terminal.Click += (_, _) => OpenView("core.terminal"); + btn_jobs.Click += (_, _) => OpenView("core.jobs"); + btn_liveTrading.Click += (_, _) => CycleLiveTrading(); + btn_demoTrading.Click += (_, _) => CycleDemoTrading(); miLegacy.Click += (_, _) => OpenLegacy(); miBeenden.Click += (_, _) => Close(); _statusTimer.Tick += (_, _) => UpdateStatus(); _statusTimer.Start(); UpdateStatus(); + UpdateTradingToggles(); + } + + private void CycleLiveTrading() + { + _state.LiveTradingMode = _state.LiveTradingMode switch + { + TradingMode.Inactive => TradingMode.SellOnly, + TradingMode.SellOnly => TradingMode.Active, + _ => TradingMode.Inactive + }; + UpdateTradingToggles(); + } + + private void CycleDemoTrading() + { + _state.DemoTradingMode = _state.DemoTradingMode switch + { + TradingMode.Inactive => TradingMode.SellOnly, + TradingMode.SellOnly => TradingMode.Active, + _ => TradingMode.Inactive + }; + UpdateTradingToggles(); + } + + private void UpdateTradingToggles() + { + ApplyToggle(btn_liveTrading, "LiveTrading", _state.LiveTradingMode); + ApplyToggle(btn_demoTrading, "DemoTrading", _state.DemoTradingMode); + + static void ApplyToggle(ToolStripButton btn, string label, TradingMode mode) + { + switch (mode) + { + case TradingMode.Active: + btn.Text = $"{label} (AKTIV)"; + btn.BackColor = System.Drawing.Color.LightGreen; + break; + case TradingMode.SellOnly: + btn.Text = $"{label} (SELL-ONLY)"; + btn.BackColor = System.Drawing.Color.Orange; + break; + default: + btn.Text = $"{label} (DEAKTIVIERT)"; + btn.BackColor = System.Drawing.Color.IndianRed; + break; + } + } } /// Öffnet die Ansicht mit der angegebenen ID (bzw. fokussiert das offene Fenster). @@ -61,6 +112,9 @@ namespace PolyTraderSharp.Ui lbl_modules.Text = $"Module: {moduleCount}"; lbl_ratelimit.Text = $"API: {(_state.IsAlchemyHealthy ? "WSS aktiv" : "Polling")}"; + + // Toggle-Buttons mit externem State synchron halten (z.B. Änderungen aus der Legacy-UI). + UpdateTradingToggles(); } private void OpenLegacy() diff --git a/Ui/Views/JobsView.Designer.cs b/Ui/Views/JobsView.Designer.cs new file mode 100644 index 0000000..0c49b9f --- /dev/null +++ b/Ui/Views/JobsView.Designer.cs @@ -0,0 +1,129 @@ +namespace PolyTraderSharp.Ui.Views +{ + partial class JobsView + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Komponenten-Designer generierter Code + + private void InitializeComponent() + { + this.dgvJobs = new System.Windows.Forms.DataGridView(); + this.colJobName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colStatus = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colLastRun = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colNextRun = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.col_dgv_jobs_Enabled = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.col_dgv_jobs_Run = new System.Windows.Forms.DataGridViewButtonColumn(); + this.colDescription = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvJobs)).BeginInit(); + this.SuspendLayout(); + // + // dgvJobs + // + this.dgvJobs.AllowUserToAddRows = false; + this.dgvJobs.AllowUserToDeleteRows = false; + this.dgvJobs.AutoGenerateColumns = false; + this.dgvJobs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvJobs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.colJobName, + this.colStatus, + this.colLastRun, + this.colNextRun, + this.col_dgv_jobs_Enabled, + this.col_dgv_jobs_Run, + this.colDescription}); + this.dgvJobs.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgvJobs.Location = new System.Drawing.Point(0, 0); + this.dgvJobs.Name = "dgvJobs"; + this.dgvJobs.RowHeadersVisible = false; + this.dgvJobs.Size = new System.Drawing.Size(900, 500); + this.dgvJobs.TabIndex = 0; + // + // colJobName + // + this.colJobName.DataPropertyName = "JobName"; + this.colJobName.HeaderText = "Job Name"; + this.colJobName.Name = "colJobName"; + this.colJobName.ReadOnly = true; + this.colJobName.Width = 150; + // + // colStatus + // + this.colStatus.DataPropertyName = "StatusText"; + this.colStatus.HeaderText = "Status"; + this.colStatus.Name = "colStatus"; + this.colStatus.ReadOnly = true; + this.colStatus.Width = 150; + // + // colLastRun + // + this.colLastRun.DataPropertyName = "LastRun"; + this.colLastRun.HeaderText = "Zuletzt ausgeführt"; + this.colLastRun.Name = "colLastRun"; + this.colLastRun.ReadOnly = true; + this.colLastRun.Width = 130; + // + // colNextRun + // + this.colNextRun.DataPropertyName = "NextRun"; + this.colNextRun.HeaderText = "Nächster Lauf"; + this.colNextRun.Name = "colNextRun"; + this.colNextRun.ReadOnly = true; + this.colNextRun.Width = 130; + // + // col_dgv_jobs_Enabled + // + this.col_dgv_jobs_Enabled.DataPropertyName = "IsEnabled"; + this.col_dgv_jobs_Enabled.HeaderText = "Aktiv"; + this.col_dgv_jobs_Enabled.Name = "col_dgv_jobs_Enabled"; + this.col_dgv_jobs_Enabled.Width = 60; + // + // col_dgv_jobs_Run + // + this.col_dgv_jobs_Run.HeaderText = "Aktion"; + this.col_dgv_jobs_Run.Name = "col_dgv_jobs_Run"; + this.col_dgv_jobs_Run.Text = "Run Now"; + this.col_dgv_jobs_Run.UseColumnTextForButtonValue = true; + this.col_dgv_jobs_Run.Width = 90; + // + // colDescription + // + this.colDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.colDescription.DataPropertyName = "Description"; + this.colDescription.HeaderText = "Beschreibung"; + this.colDescription.Name = "colDescription"; + this.colDescription.ReadOnly = true; + // + // JobsView + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.dgvJobs); + this.Name = "JobsView"; + this.Size = new System.Drawing.Size(900, 500); + ((System.ComponentModel.ISupportInitialize)(this.dgvJobs)).EndInit(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView dgvJobs; + private System.Windows.Forms.DataGridViewTextBoxColumn colJobName; + private System.Windows.Forms.DataGridViewTextBoxColumn colStatus; + private System.Windows.Forms.DataGridViewTextBoxColumn colLastRun; + private System.Windows.Forms.DataGridViewTextBoxColumn colNextRun; + private System.Windows.Forms.DataGridViewCheckBoxColumn col_dgv_jobs_Enabled; + private System.Windows.Forms.DataGridViewButtonColumn col_dgv_jobs_Run; + private System.Windows.Forms.DataGridViewTextBoxColumn colDescription; + } +} diff --git a/Ui/Views/JobsView.cs b/Ui/Views/JobsView.cs new file mode 100644 index 0000000..42392d1 --- /dev/null +++ b/Ui/Views/JobsView.cs @@ -0,0 +1,48 @@ +using System.Threading.Tasks; +using System.Windows.Forms; +using PolyTraderSharp.Models; +using PolyTraderSharp.Services; + +namespace PolyTraderSharp.Ui.Views +{ + /// + /// Ansicht der Hintergrund-Jobs (JobManager). Designbar (JobsView.Designer.cs). + /// Verhalten wie der bisherige Jobs-Tab: „Run Now" löst den ManualTrigger aus, + /// „Aktiv" schaltet den Job über die Bindung. + /// + public partial class JobsView : UserControl + { + public JobsView() + { + InitializeComponent(); + colLastRun.DefaultCellStyle.Format = "HH:mm:ss"; + colNextRun.DefaultCellStyle.Format = "HH:mm:ss"; + dgvJobs.CellContentClick += DgvJobs_CellContentClick; + } + + public void Initialize(JobManager jobManager) + { + dgvJobs.DataSource = jobManager.Jobs; + } + + private void DgvJobs_CellContentClick(object? sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex < 0 || e.ColumnIndex < 0) return; + var dgv = (DataGridView)sender!; + var colName = dgv.Columns[e.ColumnIndex].Name; + + if (dgv.Rows[e.RowIndex].DataBoundItem is JobStatusRow job) + { + if (colName == "col_dgv_jobs_Run") + { + if (job.ManualTriggerAction != null) + _ = Task.Run(() => job.ManualTriggerAction.Invoke()); + } + else if (colName == "col_dgv_jobs_Enabled") + { + dgv.EndEdit(); + } + } + } + } +}