public void ChangeHWM(double pct, string target) { if (target == "GLOBAL") { ChangeHwmGlobally(pct); } else { foreach (Tablespace tb in tbs) { if (tb.Name == target) { tb.updatesRatesWithNewHwm(hwm); } } foreach (Tb_Panel pl in myLayout.Controls) { if (pl.tb.Name == target) { LiveCharts.WinForms.AngularGauge ag = (LiveCharts.WinForms.AngularGauge)pl.Controls[0]; ag.Sections[0].FromValue = ag.ToValue * Convert.ToDouble(Convert.ToDecimal(pct)); pl.Controls[2].Text = pl.tb.DaysToHwm + " days to HWM"; pl.Controls[4].Text = "HWM: " + Math.Round(pl.tb.Max * Convert.ToDouble(Convert.ToDecimal(pct)), 2) + " MB"; } } } }
private void ChangeHwmGlobally(double pct) { this.hwm = Convert.ToDecimal(pct); foreach (Tablespace tb in tbs) { tb.updatesRatesWithNewHwm(hwm); } foreach (Tb_Panel pl in myLayout.Controls) { LiveCharts.WinForms.AngularGauge ag = (LiveCharts.WinForms.AngularGauge)pl.Controls[0]; ag.Sections[0].FromValue = ag.ToValue * Convert.ToDouble(hwm); pl.Controls[2].Text = pl.tb.DaysToHwm + " days to HWM"; pl.Controls[4].Text = "HWM: " + Math.Round(pl.tb.Max * Convert.ToDouble(hwm), 2) + " MB"; } }
public Tb_Panel(Tablespace tb, decimal hwm) { this.tb = tb; this.gauge = new LiveCharts.WinForms.AngularGauge(); this.tb_name = new Label(); this.tb_pct = new Label(); this.tb_hwm = new Label(); this.tb_d_hwm = new Label(); this.tb_d_max = new Label(); this.SuspendLayout(); /* Configuramos cada elemento del panel */ // // panel // this.Controls.Add(gauge); //0 this.Controls.Add(tb_d_max); //1 this.Controls.Add(tb_d_hwm); //2 this.Controls.Add(tb_pct); //3 this.Controls.Add(tb_hwm); //4 this.Controls.Add(tb_name); this.Location = new System.Drawing.Point(3, 3); this.Name = "panel_" + tb.Name; this.Size = new System.Drawing.Size(330, 180); this.TabIndex = 2; // // tb_name // tb_name.AutoSize = true; tb_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); tb_name.ForeColor = System.Drawing.SystemColors.ControlDark; tb_name.Location = new System.Drawing.Point(170, 5); tb_name.Name = "tb_name_" + tb.Name; tb_name.Size = new System.Drawing.Size(55, 20); tb_name.TabIndex = 2; tb_name.Text = tb.Name; // // gauge // gauge.Location = new System.Drawing.Point(3, 3); gauge.Name = "gauge_" + tb.Name; gauge.Size = new System.Drawing.Size(160, 180); gauge.TabIndex = 1; gauge.Text = "angularGauge_" + tb.Name; gauge.Value = tb.Used; gauge.FromValue = 0; gauge.ToValue = tb.Max; gauge.LabelsStep = Math.Round(tb.Max / 5, MidpointRounding.ToEven); gauge.TickStep = Math.Round(gauge.LabelsStep / 10, MidpointRounding.ToEven); gauge.TicksForeground = Brushes.White; gauge.Wedge = 190; gauge.NeedleFill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(253, 142, 0)); gauge.Base.Foreground = Brushes.White; gauge.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(27)))), ((int)(((byte)(27))))); gauge.Base.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(27, 27, 27)); gauge.Base.FontWeight = FontWeights.Regular; gauge.Base.FontSize = 10; gauge.SectionsInnerRadius = 0.5; gauge.Sections.Add(new AngularSection { FromValue = tb.Max * Convert.ToDouble(hwm), ToValue = gauge.ToValue, Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(142, 63, 63)) }); // // tb_pct // this.tb_pct.AutoSize = true; this.tb_pct.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tb_pct.ForeColor = System.Drawing.SystemColors.ControlDark; this.tb_pct.Location = new System.Drawing.Point(170, 30); this.tb_pct.Name = "tb_pct_" + tb.Name; this.tb_pct.Size = new System.Drawing.Size(100, 18); this.tb_pct.TabIndex = 3; this.tb_pct.Text = "Usage: " + Math.Round((tb.Used / tb.Max) * 100, 2) + "% (" + Math.Round(tb.Used, 2) + " MB)"; // // tb_hwm // this.tb_hwm.AutoSize = true; this.tb_hwm.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tb_hwm.ForeColor = System.Drawing.SystemColors.ControlDark; this.tb_hwm.Location = new System.Drawing.Point(170, 50); this.tb_hwm.Name = "tb_pct_" + tb.Name; this.tb_hwm.Size = new System.Drawing.Size(90, 18); this.tb_hwm.TabIndex = 3; this.tb_hwm.Text = "HWM: " + Math.Round(tb.Max * Convert.ToDouble(hwm), 2) + " MB"; // // tb_d_hwm // this.tb_d_hwm.AutoSize = true; this.tb_d_hwm.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tb_d_hwm.ForeColor = System.Drawing.SystemColors.ControlLight; this.tb_d_hwm.Location = new System.Drawing.Point(170, 75); this.tb_d_hwm.Name = "tb_d_hwm_" + tb.Name; this.tb_d_hwm.Size = new System.Drawing.Size(84, 18); this.tb_d_hwm.TabIndex = 4; this.tb_d_hwm.Text = tb.DaysToHwm + " days to HWM"; // // tb_d_max // this.tb_d_max.AutoSize = true; this.tb_d_max.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tb_d_max.ForeColor = System.Drawing.SystemColors.ControlLight; this.tb_d_max.Location = new System.Drawing.Point(170, 95); this.tb_d_max.Name = "tb_d_max"; this.tb_d_max.Size = new System.Drawing.Size(77, 18); this.tb_d_max.TabIndex = 5; this.tb_d_max.Text = tb.DaysToMax + " days to MAX"; this.ResumeLayout(false); this.PerformLayout(); }