/// <devdoc>
            ///     Saves any checked / unchecked changes made in the dialog to the given toolbox
            ///     service.
            /// </devdoc>
            public void SaveChanges(IToolboxService toolboxSvc)
            {
                string currentCategory = toolboxSvc.SelectedCategory;

                foreach (ToolboxListViewItem item in controlList.Items)
                {
                    if (item.InitiallyChecked != item.Checked)
                    {
                        if (item.InitiallyChecked)
                        {
                            // Item was initially checked, but it's no longer checked.
                            // Remove it from the toolbox.
                            //
                            foreach (ToolboxItem tbxItem in toolboxSvc.GetToolboxItems())
                            {
                                if (tbxItem.Equals(item.Item))
                                {
                                    toolboxSvc.RemoveToolboxItem(tbxItem);
                                }
                            }
                        }
                        else
                        {
                            // Item was not initially checked, but it is now.
                            // Add it to the toolbox.
                            //
                            toolboxSvc.AddToolboxItem(item.Item, currentCategory);
                        }
                    }

                    // Now, update the item so it reflects reality.
                    //
                    item.InitiallyChecked = item.Checked;
                }
            }
Exemplo n.º 2
0
 // 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);
     }
 }
        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);
            }
        }
        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);
            }
        }
Exemplo n.º 5
0
        private void RefreshToolboxItems(IShell shell)
        {
            _items.Clear();

            if (shell.ActiveItem == null)
            {
                return;
            }

            _items.AddRange(_toolboxService.GetToolboxItems(shell.ActiveItem.GetType())
                            .Select(x => new ToolboxItemViewModel(x)));
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
        private void RefreshToolboxItems(IShell shell)
        {
            var activeDocument = shell.ActiveDocument;

            Items.Clear();

            if (activeDocument != null)
            {
                foreach (var item in _toolboxService.GetToolboxItems(activeDocument.GetType()))
                {
                    Items.Add(new ToolboxItemViewModel(item));
                }
            }
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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;
            }
        }
        //</Snippet10>

        //<Snippet11>
        void OnRefreshToolbox(object sender, EventArgs e)
        {
            // Add new instances of all ToolboxItems contained in ToolboxItemList.
            IToolboxService service =
                GetService(typeof(IToolboxService)) as IToolboxService;
            IVsToolbox toolbox = GetService(typeof(IVsToolbox)) as IVsToolbox;

            //Remove target tab and all controls under it.
            foreach (ToolboxItem oldItem in service.GetToolboxItems(CategoryTab))
            {
                service.RemoveToolboxItem(oldItem);
            }
            toolbox.RemoveTab(CategoryTab);

            foreach (ToolboxItem itemFromList in ToolboxItemList)
            {
                service.AddToolboxItem(itemFromList, CategoryTab);
            }
            service.SelectedCategory = CategoryTab;

            service.Refresh();
        }
        //<Snippet10>
        // Add new instances of all ToolboxItems to the toolbox item list.
        void OnRefreshToolbox(object sender, EventArgs e)
        {
            IToolboxService service =
                GetService(typeof(IToolboxService)) as IToolboxService;
            IVsToolbox toolbox =
                GetService(typeof(IVsToolbox)) as IVsToolbox;

            // Remove target tab and all items under it.
            foreach (ToolboxItem item in service.GetToolboxItems(CategoryTab))
            {
                service.RemoveToolboxItem(item);
            }
            toolbox.RemoveTab(CategoryTab);

            // Recreate the target tab with the items from the current list.
            foreach (ToolboxItem item in ToolboxItemList)
            {
                service.AddToolboxItem(item, CategoryTab);
            }
            service.SelectedCategory = CategoryTab;

            service.Refresh();
        }
            /// <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;
                    }
                }
            }
Exemplo n.º 13
0
        private void OnRefreshToolbox(object sender, EventArgs e)
        {
            toolboxService = (IToolboxService)GetService(typeof(IToolboxService));
            IVsToolbox vsToolbox = GetService(typeof(IVsToolbox)) as IVsToolbox;

            if (toolboxService == null || vsToolbox == null)
            {
                return;
            }

            PetriNetEditorToolboxProvider toolboxProvider = new PetriNetEditorToolboxProvider();
            var itemList = toolboxProvider.GetToolboxItemList();

            if (itemList == null || itemList.Count == 0)
            {
                return;
            }

            string toolboxCategoryName = PetriNetEditorToolboxProvider.ToolboxCategoryName;

            //Remove target tab and all controls under it.
            foreach (ToolboxItem oldItem in toolboxService.GetToolboxItems(toolboxCategoryName))
            {
                toolboxService.RemoveToolboxItem(oldItem);
            }
            vsToolbox.RemoveTab(PetriNetEditorToolboxProvider.ToolboxCategoryName);

            foreach (ToolboxItem item in itemList)
            {
                toolboxService.AddToolboxItem(item, toolboxCategoryName);
            }

            toolboxService.SelectedCategory = toolboxCategoryName;
            toolboxService.Refresh();
        }