Exemplo n.º 1
0
        private void SaveConfiguration()
        {
            var items = new List <List <IdentifierWithShortcut> >();

            foreach (Category category in lbxCategories.Items)
            {
                var cat = new List <IdentifierWithShortcut>();

                foreach (CategoryItem item in category.Items)
                {
                    cat.Add(new IdentifierWithShortcut()
                    {
                        Identifier  = new ComponentIdentifier(item.Description, item.Configuration),
                        ShortcutKey = item.ShortcutKey
                    });
                }

                if (cat.Count > 0)
                {
                    items.Add(cat);
                }
            }

            ToolboxManager.WriteToolbox(items);
        }
Exemplo n.º 2
0
        public winToolbox()
        {
            InitializeComponent();

            // Load toolbox
            var toolboxItems = ToolboxManager.LoadToolbox();

            // Convert toolbox items for display
            foreach (var cat in toolboxItems)
            {
                var categoryItems = new ObservableCollection <CategoryItem>();

                foreach (IdentifierWithShortcut item in cat)
                {
                    categoryItems.Add(new CategoryItem(item.Identifier.Description, item.Identifier.Configuration, item.ShortcutKey));
                }

                lbxCategories.Items.Add(new Category("Category " + CategoryCounter.ToString())
                {
                    Items = categoryItems
                });
                CategoryCounter++;
            }

            // Available (not in toolbox) items
            foreach (ComponentDescription description in ComponentHelper.ComponentDescriptions)
            {
                if (!IsItemUsed(description, null) && description.Metadata.Configurations.Count == 0)
                {
                    lbxAvailableItems.Items.Add(new CategoryItem(description, null, Key.None));
                }
                foreach (ComponentConfiguration configuration in description.Metadata.Configurations)
                {
                    if (!IsItemUsed(description, configuration))
                    {
                        lbxAvailableItems.Items.Add(new CategoryItem(description, configuration, Key.None));
                    }
                }
            }

            lbxAvailableItems.Items.Filter = FilterItem;
            lbxAvailableItems.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("SortText", System.ComponentModel.ListSortDirection.Ascending));
        }