private void tbspChecklist_SelectedIndexChanged(object sender, EventArgs e) { if (tbspChecklist.Enabled) { tbspChecklist.Enabled = false; /* Actualizar el valor Visible del tablespace segun se checkee o no */ Tablespace selected = tbs.Find(x => x.Name == (tbspChecklist.SelectedItem as Tablespace).Name); CheckState aux = tbspChecklist.GetItemCheckState(tbspChecklist.SelectedIndex); selected.Visible = (aux == CheckState.Checked) ? true : false; /* Si el nuevo estado es false, es que antes si estaba visible. Basta con removerlo de la vista */ if (!selected.Visible) { foreach (Tb_Panel pl in myLayout.Controls) { if (pl.getTablespaceName() == selected.Name) { myLayout.Controls.Remove(pl); } } } /* Si el nuevo estado es true, es que antes no estaba visible. Basta con agregarlo a la vista */ else { this.myLayout.Controls.Add(new Tb_Panel(selected, hwm)); } /* Bloquear el checklist para que no se pueda ejecutar una operacion hasta que termine todo el proceso */ tbspChecklist.Enabled = true; } }
private void InitCheckedListBox() { tbspChecklist.CheckOnClick = true; ((ListBox)this.tbspChecklist).DataSource = tbs; ((ListBox)this.tbspChecklist).DisplayMember = "Name"; ((ListBox)this.tbspChecklist).ValueMember = "Name"; for (int i = 0; i < tbspChecklist.Items.Count; i++) { Tablespace obj = (Tablespace)tbspChecklist.Items[i]; tbspChecklist.SetItemChecked(i, obj.Visible); } tbspChecklist.SelectedIndexChanged += new System.EventHandler(this.tbspChecklist_SelectedIndexChanged); }
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(); }