public MetroCheckBox checkBoxMaker(string name) { MetroCheckBox chkbox = new MetroCheckBox(); chkbox.AutoSize = true; chkbox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; chkbox.CustomBackground = true; chkbox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; chkbox.FontSize = MetroFramework.MetroLinkSize.Tall; chkbox.FontWeight = MetroFramework.MetroLinkWeight.Bold; chkbox.ForeColor = System.Drawing.Color.Transparent; //chkbox.Location = new System.Drawing.Point(735, 401); chkbox.Margin = new System.Windows.Forms.Padding(15, 20, 15, 15); chkbox.Name = "CBtn" + name; chkbox.Size = new System.Drawing.Size(95, 24); chkbox.Style = MetroFramework.MetroColorStyle.Teal; chkbox.TabIndex = 17; chkbox.TabStop = true; chkbox.Checked = isHost ? true: false; chkbox.Text = name; chkbox.UseStyleColors = true; chkbox.UseVisualStyleBackColor = true; chkbox.CheckStateChanged += new System.EventHandler(this.metroRadioButton1_CheckedChanged); boxes.Add(chkbox); this.BeginInvoke((Action)(() => { //perform on the UI thread this.flowLayoutPanel1.Controls.Add(chkbox); })); return(chkbox); }
private void AddControls(int code, string name, string description) { var checkBox = new MetroCheckBox(); checkBox.AutoSize = true; checkBox.Location = new Point(16, this._index); checkBox.Name = "cbx_" + this._index; checkBox.Size = new Size(79, 15); checkBox.Text = name; checkBox.Tag = code; checkBox.UseCustomForeColor = true; checkBox.ForeColor = Color.Crimson; checkBox.FontWeight = MetroCheckBoxWeight.Bold; this.privilegePanel.Controls.Add(checkBox); var label = new MetroLabel(); label.AutoSize = true; label.ForeColor = Color.DimGray; label.FontSize = MetroLabelSize.Small; label.FontWeight = MetroLabelWeight.Bold; label.Location = new Point(161, this._index); label.Name = "clb_" + this._index; label.Size = new Size(81, 19); label.Text = description; label.UseCustomForeColor = true; this.privilegePanel.Controls.Add(label); this._index += this._margin; }
/// <summary> /// Cette méthode crée des controles de type chckbox ou radio button dans un controle de type panel. /// Elle va chercher les données dans la base de données et crée autant de controles (les uns au dessous des autres /// qu'il y a de lignes renvoyées par la base de données. /// </summary> /// <param name="UneForme">Le formulaire concerné</param> /// <param name="UneConnexion">L'objet connexion à utiliser pour la connexion à la BD</param> /// <param name="pUneTable">Le nom de la source de données qui va fournir les données. Il s'agit en fait d'une vue de type /// VXXXXOn ou XXXX représente le nom de la tabl à partir de laquelle la vue est créée. n représente un numéro de séquence</param> /// <param name="pPrefixe">les noms des controles sont standard : NomControle_XX /// ou XX estl'id de l'enregistrement récupéré dans la vue qui /// sert de source de données</param> /// <param name="UnPanel">panel ou groupbox dans lequel on va créer les controles</param> /// <param name="unTypeControle">type de controle à créer : checkbox ou radiobutton</param> /// <param name="callback"> Le pointeur de fonction. En fait le pointeur sur la fonction qui réagira à l'événement déclencheur </param> public static void CreerDesControles(Form UneForme, Bdd UneConnexion, String pUneTable, String pPrefixe, ScrollableControl UnPanel, String unTypeControle, Action <object, EventArgs> callback) { DataTable UneTable = UneConnexion.ObtenirDonnesOracle(pUneTable); // on va récupérer les statuts dans un datatable puis on va parcourir les lignes(rows) de ce datatable pour // construire dynamiquement les boutons radio pour le statut de l'intervenant dans son atelier Int16 i = 0; foreach (DataRow UneLigne in UneTable.Rows) { //object UnControle = Activator.CreateInstance(object unobjet, unTypeControle); //UnControle=Convert.ChangeType(UnControle, TypeC); if (unTypeControle == "MetroCheckBox") { MetroCheckBox UnControle = new MetroCheckBox(); AffecterControle(UneForme, UnPanel, UnControle, pPrefixe, UneLigne, i++, callback); } else if (unTypeControle == "MetroRadioButton") { MetroRadioButton UnControle = new MetroRadioButton(); AffecterControle(UneForme, UnPanel, UnControle, pPrefixe, UneLigne, i++, callback); UnControle.CheckedChanged += new System.EventHandler(callback); } i++; } UnPanel.Height = 20 * i + 5; }
protected override void OnShown(EventArgs e) { base.OnShown(e); if (!string.IsNullOrEmpty(DataCache.Instance.DicHdpParameter[SystemData.ConfigKey.PrintContent])) { string[] arrPrintContent = DataCache.Instance.DicHdpParameter[SystemData.ConfigKey.PrintContent].Split('|'); foreach (var item in arrPrintContent) { if (item == string.Empty) { continue; } MetroCheckBox chk = new MetroCheckBox(); chk.Text = item; chk.Name = item; chk.Width = 20 + item.Length * 20; p_PRINT_CONTENT.Controls.Add(chk); } } this.txt_PATIENT_ID.Text = SystemParam.Instance.PatVisitInfo.PATIENT_ID; this.txt_PATIENT_NAME.Text = SystemParam.Instance.PatVisitInfo.PATIENT_NAME; if (SystemParam.Instance.PatVisitInfo.DISCHARGE_TIME != SysTimeHelper.Instance.DefaultTime) { this.txt_DISCHARGE_TIME.Text = SystemParam.Instance.PatVisitInfo.DISCHARGE_TIME.ToString("yyyy-MM-dd HH:mm"); } this.txt_PATIENT_IDENTIFICATION.Text = SystemParam.Instance.PatVisitInfo.ID_NO; this.GetGridData(); }
public void RenderFlag(FormMain form) { _ptr = Defs.PointerByName(Name); if (_ptr == null) { return; } _form = form; _panel = _form.Controls.Find(Category, true)[0] as MetroPanel; var chkd = Default; var sekiro = Utils.Sekiro(); if (sekiro != null) { using (var remoteProc = new RemoteProcess(Utils.Sekiro())) { chkd = remoteProc.Read <byte>(_ptr.BasePtr()); } } _checkBox = new MetroCheckBox { Text = string.IsNullOrEmpty(Text) ? Name : Text, Checked = chkd > 0, Theme = MetroThemeStyle.Dark, Style = MetroColorStyle.Teal, AutoSize = false, Dock = DockStyle.Top, CheckAlign = ContentAlignment.MiddleRight }; _checkBox.CheckedChanged += CheckBoxOnCheckedChanged; _panel.InvokeIfRequired(() => _panel.Controls.Add(_checkBox)); }
private void NoFilterItemSearch_CheckedChanged(object sender, EventArgs e) { MetroCheckBox control = (MetroCheckBox)sender; txtSearchItems.Enabled = !control.Checked; if (!txtSearchItems.Enabled) { RefreshItemsList(); } }
void addRemoveItem(string cc, MetroCheckBox cb) { if (cb.Checked) { listCC.Items.Add(cc); } else { listCC.Items.Remove(cc); } }
private void btnListClear_Click(object sender, EventArgs e) { listCC.Items.Clear(); foreach (Control c in groupBox12.Controls) { if (c is MetroCheckBox) { MetroCheckBox chk = (MetroCheckBox)c; chk.Checked = false; } } }
protected override void OnCreateControl() { base.OnCreateControl(); txtFilter = new MetroTextBox { Visible = showFilter, Dock = System.Windows.Forms.DockStyle.Left, FontWeight = MetroTextBoxWeight.Regular, FontSize = MetroTextBoxSize.Medium, UseStyleColors = true, Width = 160, Height = 25 }; Controls.Add(txtFilter); lblFilter = new MetroLabel { Text = Properties.Resources.Search, Visible = showFilter, Dock = System.Windows.Forms.DockStyle.Left, FontWeight = MetroLabelWeight.Regular, Height = 32, TextAlign = System.Drawing.ContentAlignment.MiddleLeft, UseStyleColors = true }; Controls.Add(lblFilter); var size = TextRenderer.MeasureText(lblFilter.Text, lblFilter.Font); lblFilter.Width = size.Width + 10; btnSelect = new MetroCheckBox { Text = Properties.Resources.SelectAll, Visible = showSelectUnselect, Checked = false, Height = 32, Dock = System.Windows.Forms.DockStyle.Left, FontWeight = MetroCheckBoxWeight.Regular, FontSize = MetroCheckBoxSize.Medium, UseStyleColors = true }; Controls.Add(btnSelect); Controls.SetChildIndex(lblFilter, 5); Controls.SetChildIndex(txtFilter, 1); Controls.SetChildIndex(btnSelect, 2); btnSelect.CheckStateChanged += BtnSelect_CheckStateChanged; txtFilter.KeyUp += TxtFilter_KeyUp; }
private void ChkMostrar_CheckedChanged(object sender, EventArgs e) { MetroCheckBox chk = (MetroCheckBox)sender; if (chk.Checked) { this.txtContraseña.UseSystemPasswordChar = false; } else { this.txtContraseña.UseSystemPasswordChar = true; } }
private void showHideColumn(MetroCheckBox checkBox, int columnNumber, int columnWidth) { if (!checkBox.Checked) { mainWindow.Table_ParticipantsData1.ColumnStyles[columnNumber].Width = 0; mainWindow.table_ParticipantsHeader.ColumnStyles[columnNumber].Width = 0; } else { mainWindow.Table_ParticipantsData1.ColumnStyles[columnNumber].Width = columnWidth; mainWindow.table_ParticipantsHeader.ColumnStyles[columnNumber].Width = columnWidth; } }
private void checkBox_CheckedChanged(object sender, EventArgs e) { MetroCheckBox cb = sender as MetroCheckBox; string cbName = cb.Name; int index = int.Parse(cbName.Substring(cbName.Length - 1)); DateTimePicker startTimePicker = (DateTimePicker)this.Controls.Find("startTimePicker" + index, true)[0]; DateTimePicker endTimePicker = (DateTimePicker)this.Controls.Find("endTimePicker" + index, true)[0]; startTimePicker.Enabled = !cb.Checked; endTimePicker.Enabled = !cb.Checked; }
public static void ClearAll(MetroFramework.Forms.MetroForm form) { foreach (Control control in form.Controls) { if (control.GetType() == typeof(MetroTextBox) || control.GetType() == typeof(TextBox)) { control.Text = ""; } else if (control.GetType() == typeof(MetroComboBox) || control.GetType() == typeof(ComboBox)) { if (control.GetType() == typeof(MetroComboBox)) { MetroComboBox combo = (MetroComboBox)control; combo.Text = ""; combo.Items.Clear(); } else { ComboBox combo = (ComboBox)control; combo.Text = ""; combo.Items.Clear(); } } else if (control.GetType() == typeof(MetroCheckBox) || control.GetType() == typeof(CheckBox)) { if (control.GetType() == typeof(MetroCheckBox)) { MetroCheckBox chk = (MetroCheckBox)control; chk.Checked = false; } else { CheckBox chk = (CheckBox)control; chk.Checked = false; } } else if (control.GetType() == typeof(MetroRadioButton) || control.GetType() == typeof(RadioButton)) { if (control.GetType() == typeof(MetroRadioButton)) { MetroRadioButton radio = (MetroRadioButton)control; radio.Checked = false; } else { RadioButton radio = (RadioButton)control; radio.Checked = false; } } } }
//Check Order private void chkbOrderDay_CheckedChanged(object sender, EventArgs e) { MetroCheckBox chk = (MetroCheckBox)sender; if (chk.Checked) { chk.ForeColor = Color.Green; } else { chk.ForeColor = Color.Gray; } CheckTabActive(); }
public void FillTimetable() { for (int i = 1; i <= 7; i++) { Timetable timetable = _currentUser.Timetables.First(t => t.DayOfTheWeek == i); DateTimePicker startTimePicker = (DateTimePicker)this.Controls.Find("startTimePicker" + i, true)[0]; DateTimePicker endTimePicker = (DateTimePicker)this.Controls.Find("endTimePicker" + i, true)[0]; MetroCheckBox checkDayOff = (MetroCheckBox)this.Controls.Find("checkDayOff" + i, true)[0]; startTimePicker.Value = (timetable.StartTime == null) ? DateTime.Today : (DateTime)timetable.StartTime; endTimePicker.Value = (timetable.EndTime == null) ? DateTime.Today : (DateTime)timetable.EndTime; checkDayOff.Checked = timetable.DayOff; } }
private void chkEnableMessageTypes_CheckedChanged(object sender, EventArgs e) { foreach (Control c in gboMessageType.Controls) { if (c.Name == chkEnableMessageTypes.Name) { continue; } if (c.GetType().ToString() == "MetroCheckBox") { MetroCheckBox cx = (MetroCheckBox)c; cx.Checked = false; } c.Enabled = chkEnableMessageTypes.Checked; } }
private void checkBoxErrorCheckEnable_CheckedChanged(object sender, EventArgs e) { MetroCheckBox data = (MetroCheckBox)sender; foreach (DataGridViewRow item in this.dataGridViewErrorStatus.SelectedRows) { if (data.Checked) { dataGridViewErrorStatus.Rows[item.Index].Cells[2].Value = "Enable"; } else { dataGridViewErrorStatus.Rows[item.Index].Cells[2].Value = "Disable"; } } }
private void SnipTargetChanged(MetroCheckBox sender, EventArgs e) { SnipTarget set = (SnipTarget)Enum.Parse(typeof(SnipTarget), sender.Tag.ToString()); if (sender.Checked) { StaticData.UserData.SelectedSnipTarget |= set; } else { if (StaticData.UserData.SelectedSnipTarget.HasFlag(set)) { StaticData.UserData.SelectedSnipTarget &= ~set; } } StaticData.UserData.SaveSettings(); }
/// <summary> /// procédure permettant d'afficher l'interface de saisie des disponibilités des bénévoles. /// </summary> private void GererInscriptionBenevole() { PanelBenevole.Visible = true; PanelIntervenant.Visible = false; Utilitaire.CreerDesControles(this, UneConnexion, "VDATEBENEVOLAT01", "ChkDateB_", PanelDispoBenevole, "MetroCheckBox", this.rdbStatutIntervenant_StateChanged); // on va tester si le controle à placer est de type CheckBox afin de lui placer un événement checked_changed // Ceci afin de désactiver les boutons si aucune case à cocher du container n'est cochée foreach (Control UnControle in PanelDispoBenevole.Controls) { if (UnControle.GetType().Name == "MetroCheckBox") { MetroCheckBox UneCheckBox = (MetroCheckBox)UnControle; UneCheckBox.CheckedChanged += new System.EventHandler(this.ChkDateBenevole_CheckedChanged); } } }
private void buttonSourcesDeselectAll_Click(object sender, EventArgs e) { foreach (Control p in panelSources.Controls) { if (p is MetroPanel) { foreach (Control c in p.Controls) { if (c is MetroCheckBox) { MetroCheckBox checkBox = (MetroCheckBox)c; checkBox.Checked = false; } } } } }
private void metroRadioButton1_CheckedChanged(object sender, EventArgs e) { MetroCheckBox m = (MetroCheckBox)sender; foreach (MetroCheckBox item in flowLayoutPanel1.Controls) { if (item != m) { item.Checked = false; } } //m.Checked = m.Checked ? false : true; if (m.Checked) { if (isHost) { int len = m.Name.Length - 2; string name = m.Name.Replace("CBtn", ""); activeClient = lstClients[name]; currentPlayerLbl.Text = m.Name.Substring(4); } else { string name = m.Name.Replace("CBtn", ""); clientChosen = true; chosenClient = name; currentPlayerLbl.Text = m.Name.Substring(4); } } else { if (isHost) { activeClient = null; currentPlayerLbl.Text = ""; } else { chosenClient = null; clientChosen = false; currentPlayerLbl.Text = ""; } } }
private void SelectFilesForm_Shown(object sender, EventArgs e) { try { RefreshTreeView(); foreach (var extension in extList) { var chk = new MetroCheckBox() { Text = extension.Key }; chk.Checked = extension.Value; chk.CheckedChanged += (controlObj, args) => { if (_isChkAllChanging) { return; } var control = (MetroCheckBox)controlObj; extList[control.Text] = control.Checked; _isChildChkChanging = true; this.ChkAll.Checked = extList.ContainsValue(true); _isChildChkChanging = false; _selectType = 2; RefreshTreeView(); }; this.pannel_ChkList.Controls.Add(chk); } this.metroStyleManager1.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; if (_settingInfo.MetroColorStyle < 0 || _settingInfo.MetroColorStyle >= 15) { _settingInfo.MetroColorStyle = MetroColorStyle.Blue.GetHashCode(); } this.metroStyleManager1.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.StyleManager = this.metroStyleManager1; this.Refresh(); } catch (Exception ex) { MetroMessageBox.Show(this, ex.Message, "文件选择窗体初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void cbImmu(MetroCheckBox cb1, MetroCheckBox cb2, MetroCheckBox cb3, MetroCheckBox cb4, MetroCheckBox cb5) { if (cb1.Checked && !cb2.Checked && !cb3.Checked && !cb4.Checked && !cb5.Checked) { cb1.Checked = true; cb2.Checked = !true; cb3.Checked = !true; cb4.Checked = !true; cb5.Checked = !true; } else if (!cb1.Checked && cb2.Checked && !cb3.Checked && !cb4.Checked && !cb5.Checked) { cb1.Checked = true; cb2.Checked = true; cb3.Checked = !true; cb4.Checked = !true; cb5.Checked = !true; } else if (!cb1.Checked && !cb2.Checked && cb3.Checked && !cb4.Checked && !cb5.Checked) { cb1.Checked = true; cb2.Checked = true; cb3.Checked = true; cb4.Checked = !true; cb5.Checked = !true; } else if (!cb1.Checked && !cb2.Checked && !cb3.Checked && cb4.Checked && !cb5.Checked) { cb1.Checked = true; cb2.Checked = true; cb3.Checked = true; cb4.Checked = true; cb5.Checked = !true; } else if (!cb1.Checked && !cb2.Checked && !cb3.Checked && !cb4.Checked && cb5.Checked) { cb1.Checked = true; cb2.Checked = true; cb3.Checked = true; cb4.Checked = true; cb5.Checked = true; } }
private void MainForm_Load(object sender, EventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var folders = Directory.GetDirectories(path); var top = 0; foreach (var item in folders) { var dic = Path.GetFileName(item); if (dic.StartsWith("Visual Studio")) { var checkBox = new MetroCheckBox(); checkBox.Text = dic; checkBox.Top = top; top += 23; checkBox.Size = new Size(200, 15); pnl_Vs.Controls.Add(checkBox); } } }
private void btnSave_Click(object sender, EventArgs e) { if (ValidateStartTime()) { for (int i = 1; i <= 7; i++) { Timetable timetable = _currentUser.Timetables.First(t => t.DayOfTheWeek == i); DateTimePicker startTimePicker = (DateTimePicker)this.Controls.Find("startTimePicker" + i, true)[0]; DateTimePicker endTimePicker = (DateTimePicker)this.Controls.Find("endTimePicker" + i, true)[0]; MetroCheckBox checkDayOff = (MetroCheckBox)this.Controls.Find("checkDayOff" + i, true)[0]; timetable.DayOff = checkDayOff.Checked; if (checkDayOff.Checked) { timetable.StartTime = null; timetable.EndTime = null; } else { timetable.StartTime = startTimePicker.Value; timetable.EndTime = endTimePicker.Value; } timetablePanel.Hide(); } usersBindingSource.EndEdit(); _context.SaveChanges(); MetroMessageBox.Show(this, "Ruajtja u be me sukses", "Message", MessageBoxButtons.OK, MessageBoxIcon.Question); } else { MetroMessageBox.Show(this, "Koha e fillimit duhet te jete me e vogel se koha e mbarimit", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void checkBoxRestrictImageSizes_CheckedChanged(object sender, EventArgs e) { bool enabled = checkBoxRestrictImageSizes.Checked; panelRestrictImageSizes.Enabled = enabled; panelRestrictImageSizesMethod.Enabled = enabled; numericUpDownRestrictImageSizesWidth.Enabled = enabled; numericUpDownRestrictImageSizesHeight.Enabled = enabled; if (enabled) { radioButtonRestrictImageSizesEqual.Checked = true; radioButtonRestrictImageSizesMethodManual.Checked = true; } else { foreach (Control c in panelRestrictImageSizes.Controls) { if (c is MetroRadioButton) { MetroRadioButton m = (MetroRadioButton)c; m.Checked = false; } } foreach (Control c in panelRestrictImageSizesMethod.Controls) { if (c is MetroRadioButton) { MetroRadioButton m = (MetroRadioButton)c; m.Checked = false; } if (c is MetroCheckBox) { MetroCheckBox m = (MetroCheckBox)c; m.Checked = false; } } } }
internal static void OnCheckBoxCheckedChange(MetroCheckBox checkBox) { if (checkBox == mainForm.Settings_AutoUpdateInstaller) { Config.AutoUpdate = checkBox.Checked; } else if (checkBox == mainForm.Settings_CloseAfterCompletion) { Config.CloseAfterCompletion = checkBox.Checked; } else if (checkBox == mainForm.Settings_HighlightLogFileLocation) { Config.HighlightLogFileLocation = checkBox.Checked; } else if (checkBox == mainForm.Settings_RememberLastSelectedGame) { Config.RememberLastSelectedGame = checkBox.Checked; } else if (checkBox == mainForm.Settings_ShowALPHAPreReleases) { Config.ShowALPHAPreReleases = checkBox.Checked; } }
private void createCheckboxes() { string kandidatenStrings = Properties.Settings.Default.Kandidaten; var splitted = kandidatenStrings.Split(';').ToList(); foreach (var s in splitted) { var checkBox = new MetroCheckBox(); checkBox.Checked = false; checkBox.Name = "cB" + s; checkBox.Text = s; checkBox.Location = new Point(xCheckBox, yCheckBox); checkBox.Height = 40; checkBoxes.Add(checkBox); this.Controls.Add(checkBox); yCheckBox += 40; if (this.Height - 100 < yCheckBox) { xCheckBox += 200; yCheckBox = Convert.ToInt32(Properties.Settings.Default.Y_Checkbox); } } }
private void ucExpandButton_Load(object sender, EventArgs e) { int beginTop = btnExpand.Bottom + 5; foreach (var item in ListData) { #region create control switch (ItemType) { case ControlType.CheckBox: MetroCheckBox ckb = new MetroCheckBox(); ckb.Top = beginTop; ckb.AutoSize = true; ckb.Text = item.ToString(); ckb.FontSize = MetroFramework.MetroCheckBoxSize.Medium; this.Controls.Add(ckb); beginTop = ckb.Bottom + 5; _expandWidth += ckb.Height + 5; break; } #endregion } }
public ucAnswers(int index, List <Answer> answerList) { InitializeComponent(); label.Text = $"Câu {index}:"; label.Dock = DockStyle.Left; label.BackColor = Color.White; label.ForeColor = Color.Black; label.Cursor = Cursors.Hand; label.Width = 50; label.Padding = new Padding(4, 4, 0, 0); label.MouseEnter += Label_MouseEnter; label.MouseLeave += Label_MouseLeave; label.Click += Label_Click; this.Controls.Add(label); CheckboxList = new List <MetroCheckBox>(); int length = answerList.Count; for (int i = 0, c = 65; i < length; i++) { MetroCheckBox chk = new MetroCheckBox(); chk.Text = $"{(char)c}"; chk.Dock = DockStyle.Left; chk.Width = 30; chk.Tag = answerList[i]; this.Controls.Add(chk); this.Controls.SetChildIndex(chk, 0); CheckboxList.Add(chk); c++; } }