public void AddSection(object obj, EventArgs e) { SettingsControl sc = (SettingsControl)Component; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host == null) { return; } try { SettingsItem item = (SettingsItem)host.CreateComponent(typeof(SettingsItem)); item.TabText = "Settings Item"; sc.Items.Add(item); sc.UpdateList(); if (sc.Items.Count == 1) { sc.ShowItem(0); } } catch { } remove_verb.Enabled = sc.Items.Count > 0; }
private void SelectionChanged(object sender, EventArgs e) { ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); SettingsControl sc = (SettingsControl)Component; foreach (object comp in svc.GetSelectedComponents()) { if (comp == sc) { selected = true; ReloadTexts(); return; } } foreach (SettingsItem item in sc.Items) { foreach (Control ctrl in svc.GetSelectedComponents()) { if (item.Contains(ctrl) && sc.selected_item != item) { sc.ShowItem(item.index); break; } } } selected = false; }
public void RemoveSection(object obj, EventArgs e) { SettingsControl sc = (SettingsControl)Control; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (sc.Items.Count > 0 && sc.selected_item != null) { int index = sc.selected_item.index; int sc_count = sc.Items.Count; host.DestroyComponent(sc.selected_item); sc.Items.RemoveAt(index); if (index + 1 == sc_count && sc.Items.Count > 0) { sc.ShowItem(sc.Items.Count - 1); } sc.UpdateList(); } remove_verb.Enabled = sc.Items.Count > 0; }