public static Control AddControlToGroup(RibbonGroup grp, DataRow r, DataTable funzioni) { Control container = Utility.CreateEmptyContainer(grp); IRibbonControl ctrl = null; switch ((int)r["IdTipologiaControllo"]) { case 1: case 2: grp.Controls.Add(container); RibbonButton btn = new RibbonButton(r["Immagine"].ToString(), (int)r["IdControllo"]); container.Controls.Add(btn); btn.Top = container.Padding.Top; btn.Left = container.Padding.Left; btn.Description = r["Descrizione"].ToString(); btn.Name = r["Nome"].ToString(); btn.Text = r["Label"].ToString(); btn.ScreenTip = r["ScreenTip"].ToString(); btn.Dimension = (int)r["ControlSize"]; btn.ToggleButton = r["IdTipologiaControllo"].Equals(2); ctrl = btn; break; case 3: grp.Controls.Add(container); RibbonDropDown drpD = new RibbonDropDown((int)r["IdControllo"]); container.Controls.Add(drpD); drpD.Top = container.Padding.Top; drpD.Left = container.Padding.Left; drpD.Description = r["Descrizione"].ToString(); drpD.Name = r["Nome"].ToString(); drpD.Text = r["Label"].ToString(); drpD.SetWidth(); drpD.ScreenTip = r["ScreenTip"].ToString(); ctrl = drpD; break; } ctrl.Enabled = r["Abilitato"].Equals("1"); if (ctrl != null && funzioni != null) { var functions = funzioni.AsEnumerable() .Where(func => func["IdGruppoControllo"].Equals(r["IdGruppoControllo"])); foreach (var func in functions) { ctrl.Functions.Add((int)func["IdFunzione"]); } } return(ctrl as Control); }
//COMBO private void AggiungiNuovoCombo_Click(object sender, EventArgs e) { Control container = CreateEmptyContainer(); if (container != null) { RibbonDropDown newDrpDwn = new RibbonDropDown(panelRibbonLayout); if (!newDrpDwn.IsDisposed) { container.Controls.Add(newDrpDwn); newDrpDwn.Top = container.Padding.Top; newDrpDwn.Left = container.Padding.Left; ActiveControl.Controls.Add(container); } } }
private void AggiungiControllo_Click(object sender, EventArgs e) { if (treeViewControlli.SelectedNode != null) { TreeNode ctrl = treeViewControlli.SelectedNode; if (ctrl.Tag != null && ctrl.Tag.GetType() == typeof(int)) { ControlContainer container = Utility.CreateEmptyContainer(_group) as ControlContainer; _group.Controls.Add(container); if (ctrl.Parent.Name == "1" || ctrl.Parent.Name == "2") { RibbonButton btn = new RibbonButton(imgButton.Tag.ToString(), (int)ctrl.Tag); btn.Text = txtLabel.Text; btn.Dimension = radioDimLarge.Checked ? 1 : 0; btn.ScreenTip = txtScreenTip.Text; btn.Description = txtDesc.Text; btn.ToggleButton = ctrl.Parent.Name == "2"; btn.Functions = listBoxFunzioni.Items .Cast <DataRowView>() .Select(r => (int)r["IdFunzione"]) .ToList(); container.Controls.Add(btn); } else { RibbonDropDown drp = new RibbonDropDown((int)ctrl.Tag); drp.Text = txtLabel.Text; drp.ScreenTip = txtScreenTip.Text; drp.Description = txtDesc.Text; drp.Functions = listBoxFunzioni.Items .Cast <DataRowView>() .Select(r => (int)r["IdFunzione"]) .ToList(); container.Controls.Add(drp); } } } }