Example #1
0
        private void AddCategoryControl(BlogPostCategoryListItem categoryListItem, PositionManager positionManager)
        {
            ICategorySelectorControl catSelector =
                CategorySelectorControlFactory.Instance.GetControl(categoryListItem.Category,
                                                                   (_categoryContext.SelectionMode ==
                                                                    CategoryContext.SelectionModes.MultiSelect));

            catSelector.SelectedChanged += new EventHandler(catSelector_SelectedChanged);

            catSelector.Control.Scale(new SizeF(scale.X, scale.Y));

            positionManager.PositionControl(catSelector.Control, categoryListItem.IndentLevel);

            categoryContainerControl.Controls.Add(catSelector.Control);

            _categoryControls.Add(catSelector.Control);
        }
Example #2
0
        private void AddCategory()
        {
            // add the new category
            BlogPostCategory newCategory = GetNewCategory();

            // see if the "new" category is already in our list
            if (newCategory != null)
            {
                ICategorySelectorControl selectorControl = GetCategorySelectorControl(newCategory);

                // if there is no existing selector control then add the category
                if (selectorControl == null)
                {
                    _categoryContext.AddNewCategory(newCategory);
                }

                // now re-lookup the selector control and select it
                selectorControl          = GetCategorySelectorControl(newCategory);
                selectorControl.Selected = true;

                // ensure the added category is scrolled into view
                categoryContainerControl.ScrollControlIntoView(selectorControl.Control);

                // clear the parent combo and update its ui
                comboBoxParent.SelectedIndex = 0;
                UpdateParentComboForeColor();

                // setup the text box to add another category if we support multiple categories
                if (_categoryContext.SelectionMode == CategoryContext.SelectionModes.MultiSelect)
                {
                    ActivateAddTextBoxForEdit();
                    textBoxAddCategory.Focus();
                }
                else
                {
                    ClearAddTextBox();
                    selectorControl.Control.Focus();
                }
            }
        }