// Updates the list of categories and the list of items in the // selected category. private void UpdateLists() { if (toolboxService != null) { this.listBox1.SelectedIndexChanged -= new System.EventHandler(this.UpdateSelectedCategory); this.listBox2.SelectedIndexChanged -= new System.EventHandler(this.UpdateSelectedItem); listBox1.Items.Clear(); for (int i = 0; i < toolboxService.CategoryNames.Count; i++) { listBox1.Items.Add(toolboxService.CategoryNames[i]); if (toolboxService.CategoryNames[i] == toolboxService.SelectedCategory) { listBox1.SelectedIndex = i; tools = toolboxService.GetToolboxItems(toolboxService.SelectedCategory); listBox2.Items.Clear(); for (int j = 0; j < tools.Count; j++) { listBox2.Items.Add(tools[j].DisplayName); } } } this.listBox1.SelectedIndexChanged += new System.EventHandler(this.UpdateSelectedCategory); this.listBox2.SelectedIndexChanged += new System.EventHandler(this.UpdateSelectedItem); } }
public void ToolboxItemCollection_Ctor_ToolboxItemArray() { var item = new ToolboxItem(); var collection = new ToolboxItemCollection(new ToolboxItem[] { item }); Assert.Same(item, Assert.Single(collection)); Assert.Same(item, collection[0]); Assert.True(collection.Contains(item)); Assert.Equal(0, collection.IndexOf(item)); }
private static void RemoveStandardItem(IToolboxService ts) { ToolboxItemCollection items = ts.GetToolboxItems(); ToolboxItem standardItem = items.OfType <ToolboxItem>().FirstOrDefault(x => x.DisplayName == "Label"); if (standardItem != null) { ts.RemoveToolboxItem(standardItem); } }
public void ToolboxItemCollection_Contains_NoSuchValue_ReturnsFalse() { var item = new ToolboxItem(); var collection = new ToolboxItemCollection(new ToolboxItem[] { item }); Assert.False(collection.Contains(new ToolboxItem { DisplayName = "Other" })); Assert.False(collection.Contains(null)); }
public void ToolboxItemCollection_IndexOf_NoSuchValue_ReturnsNegativeOne() { var item = new ToolboxItem(); var collection = new ToolboxItemCollection(new ToolboxItem[] { item }); Assert.Equal(-1, collection.IndexOf(new ToolboxItem { DisplayName = "Other" })); Assert.Equal(-1, collection.IndexOf(null)); }
public void ToolboxItemCollection_CopyTo_Invoke_Success() { var item = new ToolboxItem(); var collection = new ToolboxItemCollection(new ToolboxItem[] { item }); var array = new ToolboxItem[3]; collection.CopyTo(array, 1); Assert.Equal(new ToolboxItem[] { null, item, null }, array); }
private static void RemoveStandardItem(IToolboxService ts) { ToolboxItemCollection items = ts.GetToolboxItems(); ToolboxItem standardItem = items.OfType <ToolboxItem>().FirstOrDefault(x => String.Equals(x.DisplayName, "Chart")); if (standardItem != null) { ts.RemoveToolboxItem(standardItem); } }
void DesignMdiController_DesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) { // Get access to an instanse of the IToolboxService interface IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); // Get access to the collection of the toolbox items ToolboxItemCollection collection = ts.GetToolboxItems(); foreach (ToolboxItem item in collection) { if (item.DisplayName == "Label") { // Change name of the report control collection[0].DisplayName = "Report Label"; } } IDesignerHost host = e.DesignerHost; nwindDataSet ds = new nwindDataSet(); // Search DataSet component foreach (IComponent comp in host.Container.Components) { ds = comp as nwindDataSet; if (!Object.Equals(ds, null)) { // Delete data source from designer host host.Container.Remove(ds); break; } } // In this place you can define your own report data source host.Container.Add(ds, "ReportDataSource"); CategoriesTableAdapter adapter = new CategoriesTableAdapter(); // Search TableAdapter component foreach (IComponent comp in host.Container.Components) { adapter = comp as CategoriesTableAdapter; if (!Object.Equals(adapter, null)) { // Delete table adapter from designer host host.Container.Remove(adapter); break; } } // In this place you can define your own report table adapter host.Container.Add(adapter, "ReportTableAdapter"); }
static void Main(string[] args) { //<Snippet1> // Create a new ToolboxItemCollection using a ToolboxItem array. ToolboxItemCollection collection = new ToolboxItemCollection(new ToolboxItem[] { new ToolboxItem(typeof(System.Windows.Forms.Label)), new ToolboxItem(typeof(System.Windows.Forms.TextBox)) }); //</Snippet1> //<Snippet2> // Create a new ToolboxItemCollection using an existing ToolboxItemCollection. ToolboxItemCollection coll = new ToolboxItemCollection(collection); //</Snippet2> //<Snippet3> // Get the number of items in the collection. int collectionLength = collection.Count; //</Snippet3> //<Snippet4> // Get the ToolboxItem at each index. ToolboxItem item = null; for (int index = 0; index < collection.Count; index++) { item = collection[index]; } //</Snippet4> //<Snippet5> // If the collection contains the specified ToolboxItem, // retrieve the collection index of the specified item. int indx = -1; if (collection.Contains(item)) { indx = collection.IndexOf(item); } //</Snippet5> //<Snippet6> // Copy the ToolboxItemCollection to the specified array. ToolboxItem[] items = new ToolboxItem[collection.Count]; collection.CopyTo(items, 0); //</Snippet6> }
private void OnDesignerLoaded(object sender, DesignerLoadedEventArgs e) { // Get the toolbox service. IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); // Get a collection of toolbox items. ToolboxItemCollection coll = ts.GetToolboxItems(); // Iterate through toolbox items. foreach (ToolboxItem item in coll) { // Add the "Cool" prefix to all toolbox item names. item.DisplayName = "Cool " + item.DisplayName; } }
public void ToolboxItemCollection_Creation() { ToolboxItem item1 = new ToolboxItem(typeof(Bitmap)); ToolboxItem item2 = new ToolboxItem(typeof(string)); ToolboxItem[] tools = { item1, item2 }; ToolboxItemCollection underTest = new ToolboxItemCollection(tools); Assert.True(underTest.Contains(item1)); Assert.Equal(item1, underTest[0]); Assert.Equal(1, underTest.IndexOf(item2)); ToolboxItem[] tools2 = new ToolboxItem[2]; underTest.CopyTo(tools2, 0); Assert.Equal(item1, tools[0]); Assert.Equal(item2, tools[1]); }
public ToolboxItemCollection GetToolbox() { var res = new ToolboxItemCollection(); if (m_appobj != null) { var lst = new List <IWidget>(); m_appobj.GetWidgetsEx(lst, ConnPack); foreach (var wid in lst) { res.Add(new WidgetToolboxItem(wid) { CategoryOverride = "Current object" }); } foreach (var holder in WidgetAddonType.Instance.CommonSpace.GetAllAddons()) { var wid = (IWidget)holder.InstanceModel; res.Add(new WidgetToolboxItem(wid)); } } return(res); }
private void Repopulate(bool categorised) { IDesignerHost host = parentServices.GetService(typeof(IDesignerHost)) as IDesignerHost; IToolboxService toolboxService = parentServices.GetService(typeof(IToolboxService)) as IToolboxService; if (toolboxService == null || host == null) { return; } store.Clear(); ToolboxItemCollection tools = toolboxService.GetToolboxItems(host); if (tools == null) { return; } ArrayList nodes = new ArrayList(tools.Count); CategoryNameCollection catNames = toolboxService.CategoryNames; foreach (string name in catNames) { tools = toolboxService.GetToolboxItems(name, host); foreach (ToolboxItem ti in tools) { ToolboxItemToolboxNode node = new ToolboxItemToolboxNode(ti); node.Category = name; nodes.Add(node); } } store.SetNodes(nodes); EnsureState(); }
// Constructors public ToolboxItemCollection(ToolboxItemCollection value) { }
public void AddTab(string tabName, Type[] types) { if (Tabs == null) Tabs = new ToolboxTabCollection(); ToolboxTab toolboxTab = new ToolboxTab(); toolboxTab.Name = tabName; ToolboxItemCollection toolboxItems = new ToolboxItemCollection(); for (int i = 0; i < types.Length; i++) { ToolboxItem toolboxItem = new ToolboxItem(); toolboxItem.Type = types[i]; toolboxItem.Name = types[i].Name; toolboxItems.Add(toolboxItem); } toolboxItems.SortByName(); toolboxTab.ToolboxItems = toolboxItems; Tabs.Add(toolboxTab); ToolboxUIManagerVS toolboxUIManagerVS = new ToolboxUIManagerVS(this); toolboxUIManagerVS.FillToolbox(); AddEventHandlers(); //PrintToolbox(); }
/// <devdoc> /// Updates the initial checks on all the items. Any items found inside the /// toolbox will be checked. /// </devdoc> public void CheckItems(IToolboxService toolboxSvc) { ToolboxItemCollection items = toolboxSvc.GetToolboxItems(); // If the toolbox contains items not listed in the SDK, add // them to this list. After our check scan we will walk // the list and add any new items to the listview. // Hashtable additionalItems = null; // But...we can't match toolbox items to list view items // without an expensive n^2 search. Hash the list view // items by their underlying ToolboxItem object. // Hashtable itemHash = new Hashtable(controlList.Items.Count); foreach (ToolboxListViewItem item in controlList.Items) { itemHash[item.Item] = item; } // Now walk the toolbox items. // foreach (ToolboxItem item in items) { ToolboxListViewItem lvItem = (ToolboxListViewItem)itemHash[item]; if (lvItem != null) { lvItem.InitiallyChecked = true; lvItem.Checked = true; } else { // Verify that this item has an assembly name before // adding it. If it doesn't, then we don't have enough // data to add it. // if (item.AssemblyName != null && item.AssemblyName.Name != null) { if (additionalItems == null) { additionalItems = new Hashtable(); } additionalItems[item] = item; } } } // Finally, if we got additional items, add them in. // if (additionalItems != null) { IComparer sorter = controlList.ListViewItemSorter; controlList.ListViewItemSorter = null; try { foreach (ToolboxItem item in additionalItems.Keys) { ToolboxListViewItem lvItem = new ToolboxListViewItem(item); lvItem.InitiallyChecked = true; lvItem.Checked = true; controlList.Items.Add(lvItem); } } finally { controlList.ListViewItemSorter = sorter; } } }
public FormsToolBoxService(FormsToolBoxBuilder builder) { _toolBoxItems = builder.CollectItemsFromAssembly(typeof(Form).Assembly); }
public ToolboxCategory() { _items = new ToolboxItemCollection(); }