Ejemplo n.º 1
0
        public TreeCategorySelector(CategoryContext ctx)
        {
            _ctx = ctx;
            InitializeComponent();

            // TODO: Whoops, missed UI Freeze... add this later
            //treeView.AccessibleName = Res.Get(StringId.CategorySelector);

            // On Windows XP, checkboxes and images seem to be mutually exclusive. Vista works fine though.
            if (Environment.OSVersion.Version.Major >= 6)
            {
                imageList.Images.Add(new Bitmap(imageList.ImageSize.Width, imageList.ImageSize.Height));
                treeView.ImageList  = imageList;
                treeView.ImageIndex = 0;
            }

            LoadCategories();

            treeView.BeforeCollapse += delegate(object sender, TreeViewCancelEventArgs e) { e.Cancel = true; };
            treeView.AfterCheck     += treeView1_AfterCheck;

            treeView.ItemHeight = (int)DisplayHelper.ScaleY(treeView.ItemHeight);

            treeView.LostFocus += delegate { treeView.Invalidate(); };
        }
 public void Initialize(IWin32Window parentFrame, CategoryContext categoryContext)
 {
     _categoryContext = categoryContext ?? new CategoryContext();
     _parentFrame     = parentFrame;
     _categoryContext.BlogCategorySettings = this;
     _categoryContext.Changed += new CategoryContext.CategoryChangedEventHandler(_categoryContext_Changed);
 }
        public RadioCategorySelector(CategoryContext ctx)
        {
            // We set it here because we need it set before we naturalize height, which happens in the costructor (LoadCategories)
            this.Font = Res.DefaultFont;
            this.ctx = ctx;
            InitializeComponent();

            LoadCategories(false);
        }
Ejemplo n.º 4
0
        private BlogPostCategory[] GetCategories(CategoryContext context)
        {
            ArrayList categories = new ArrayList(context.Categories);

            categories.Sort();


            return((BlogPostCategory[])categories.ToArray(typeof(BlogPostCategory)));
        }
        public RadioCategorySelector(CategoryContext ctx)
        {
            // We set it here because we need it set before we naturalize height, which happens in the costructor (LoadCategories)
            this.Font = Res.DefaultFont;
            this.ctx  = ctx;
            InitializeComponent();

            LoadCategories(false);
        }
        public CategoryDisplayFormW3M1(CategoryContext ctx, Point? anchor)
        {
            this.ctx = ctx;
            this.anchor = anchor;

            InitializeComponent();

            if (ctx.MaxCategoryNameLength > 0)
                txtNewCategory.MaxLength = ctx.MaxCategoryNameLength;

            /* TODO: Whoops, missed UI Freeze... do this later
            txtFilter.AccessibleName = Res.Get(StringId.CategoryCategoryFilter);
            cbParent.AccessibleName = Res.Get(StringId.CategoryNewCategoryParent);
             */
            txtNewCategory.AccessibleName = Res.Get(StringId.CategoryCategoryName);
            btnRefresh.AccessibleName = Res.Get(StringId.CategoryRefreshList);

            grpAdd.Enter += delegate { AcceptButton = btnDoAdd; };
            grpAdd.Leave += delegate { AcceptButton = null; };

            grpAdd.Text = Res.Get(StringId.CategoryAdd);
            btnDoAdd.Text = Res.Get(StringId.AddButton2);
            toolTip.SetToolTip(btnRefresh, Res.Get(StringId.CategoryRefreshList));
            ControlHelper.SetCueBanner(txtNewCategory, Res.Get(StringId.CategoryCategoryName));
            lblNone.Text = Res.Get(StringId.CategoryControlNoCategories2);

            RefreshParentCombo();

            btnRefresh.Image = ResourceHelper.LoadAssemblyResourceBitmap("OpenPost.Images.RefreshPostListEnabled.png");
            btnRefresh.ImageAlign = ContentAlignment.MiddleCenter;
            pictureBox1.Image = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.Search.png");
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            DismissOnDeactivate = true;

            Control selectorControl;
            if (ctx.SelectionMode == CategoryContext.SelectionModes.SingleSelect)
                selectorControl = new RadioCategorySelector(ctx);
            else if (ctx.SelectionMode == CategoryContext.SelectionModes.MultiSelect)
                selectorControl = new TreeCategorySelector(ctx);
            else
                throw new ArgumentException("Unexpected selection mode: " + ctx.SelectionMode);

            lblNone.BringToFront();
            lblNone.Visible = ctx.Categories.Length == 0;

            selector = (ICategorySelector)selectorControl;
            AdaptAddCategories();
            ctx.Changed += ctx_Changed;
            Disposed += delegate { ctx.Changed -= ctx_Changed; };
            selectorControl.Dock = DockStyle.Fill;
            selectorContainer.Controls.Add(selectorControl);

            txtFilter.AccessibleName = Res.Get(StringId.FindCategory);
            cbParent.AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.CategoryParentAccessible));
        }
        public SharedPropertiesController(IWin32Window parentFrame, Label labelCategory, CategoryDropDownControlM1 categoryDropDown, Label labelTags, AutoCompleteTextbox textTags,
            Label labelPageOrder, NumericTextBox textPageOrder, Label labelPageParent, PageParentComboBox comboPageParent, Label labelPublishDate, PublishDateTimePicker datePublishDate, List<PropertyField> fields,
            CategoryContext categoryContext)
        {
            this.parentFrame = parentFrame;
            this.labelCategory = labelCategory;
            this.categoryDropDown = categoryDropDown;
            this.labelPublishDate = labelPublishDate;
            this.datePublishDate = datePublishDate;
            this.fields = fields;
            this.labelTags = labelTags;
            this.textTags = textTags;
            this.labelPageOrder = labelPageOrder;
            this.textPageOrder = textPageOrder;
            this.labelPageParent = labelPageParent;
            this.comboPageParent = comboPageParent;

            this.categoryDropDown.AccessibleName = Res.Get(StringId.CategoryControlCategories).Replace("{0}", " ").Trim();
            this.datePublishDate.AccessibleName = Res.Get(StringId.PropertiesPublishDate);

            textTags.TextChanged += MakeDirty;
            textTags.ButtonClicked += (sender, args) =>
            {
                _targetBlog.RefreshKeywords();
                LoadTagValues();
            };

            comboPageParent.SelectedIndexChanged += MakeDirty;
            textPageOrder.TextChanged += MakeDirty;

            datePublishDate.ValueChanged += MakeDirty;

            DATETIME_PICKER_PROMPT = "'" + Res.Get(StringId.PublishDatePrompt).Replace("'", "''") + "'";
            // HACK ALERT - WinLive 209226: For RTL languages, we need to reverse the string, so it displays in the right direction
            // when right aligned. We need this hack because we are essentially using the CustomFormat string to display
            // the cue text. The control assumes this to be a valid format string and does a blind reverse on RTL languages
            // to mirror the date formatting. Unfortunately we don't need that mirroring for the cue text.
            // We reverse only if either the system (control panel setting) or UI is RTL, not if both are RTL.
            bool isUIRightToLeft = BidiHelper.IsRightToLeft;
            bool isSystemRightToLeft = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft;
            if ((isUIRightToLeft && !isSystemRightToLeft) || (!isUIRightToLeft && isSystemRightToLeft))
            {
                // Reverse the string
                char[] charArray = DATETIME_PICKER_PROMPT.ToCharArray();
                Array.Reverse(charArray);
                DATETIME_PICKER_PROMPT = new string(charArray);
            }
            datePublishDate.CustomFormat = DATETIME_PICKER_PROMPT;

            categoryDropDown.Initialize(parentFrame, categoryContext);

            InitializeFields();
            InitializeSync();
        }
        public CategoryDropDownControl() : base()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // prevent editing and showing of drop down
            DropDownStyle = ComboBoxStyle.DropDownList;

            // fully cusotm painting
            IntegralHeight = false;
            DrawMode       = DrawMode.OwnerDrawFixed;
            Items.Add(String.Empty);

            _categoryContext = new CategoryContext();
        }
Ejemplo n.º 9
0
        public void Initialize(CategoryContext context)
        {
            SuspendLayout();
            buttonRefresh.BitmapDisabled = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapEnabled  = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapPushed   = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapSelected = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refreshSelected.png");
            buttonRefresh.TextAlignment  = TextAlignment.Right;
            buttonRefresh.ButtonStyle    = ButtonStyle.Standard;
            buttonRefresh.ButtonText     = Res.Get(StringId.CategoryRefreshList);
            this.buttonRefresh.Size      = new Size(94, 22);
            buttonRefresh.Click         += new EventHandler(buttonRefresh_Click);

            ResumeLayout(false);
            _categoryContext = context;
        }
        void IBlogPostEditor.OnBlogChanged(Blog newBlog)
        {
            _targetBlog = newBlog;

            if (newBlog.ClientOptions.SupportsMultipleCategories)
            {
                CategoryContext.SelectionMode = CategoryContext.SelectionModes.MultiSelect;
            }
            else
            {
                CategoryContext.SelectionMode = CategoryContext.SelectionModes.SingleSelect;
            }

            CategoryContext.SetBlogCategories(_targetBlog.Categories);
            CategoryContext.SelectedCategories = new BlogPostCategory[0];
        }
Ejemplo n.º 11
0
        public CategoryDisplayFormM1(Control parentControl, CategoryContext categoryContext)
        {
            SuppressAutoRtlFixup = true;
            // save references and signup for changed event
            _parentControl            = parentControl;
            _categoryContext          = categoryContext;
            _categoryContext.Changed += new CategoryContext.CategoryChangedEventHandler(_categoryContext_Changed);

            // standard designer stuff
            InitializeComponent();

            this.buttonAdd.Text = Res.Get(StringId.AddButton2);

            // mini form behavior
            DismissOnDeactivate = true;

            // dynamic background colors based on theme
            BackColor = ColorizedResources.Instance.FrameGradientLight;
            categoryRefreshControl.BackColor   = ColorizedResources.Instance.FrameGradientLight;
            categoryContainerControl.BackColor = SystemColors.Window;

            // dynamic layout depending upon whether we support adding categories
            if (categoryContext.SupportsAddingCategories)
            {
                textBoxAddCategory.MaxLength = categoryContext.MaxCategoryNameLength;
            }
            else
            {
                int gap = categoryContainerControl.Top - panelAddCategory.Top;
                panelAddCategory.Visible         = false;
                categoryContainerControl.Top     = panelAddCategory.Top + 2;
                categoryContainerControl.Height += gap;
            }

            // dynamic layout depending upon whether we support hierarchical categories
            if (!categoryContext.SupportsHierarchicalCategories)
            {
                textBoxAddCategory.Width += (comboBoxParent.Right - textBoxAddCategory.Right);
                comboBoxParent.Visible    = false;
            }

            // initialize add textbox
            ClearAddTextBox();

            // initialize category control
            categoryRefreshControl.Initialize(_categoryContext);
        }
        public CategoryDisplayFormM1(Control parentControl, CategoryContext categoryContext)
        {
            SuppressAutoRtlFixup = true;
            // save references and signup for changed event
            _parentControl = parentControl;
            _categoryContext = categoryContext;
            _categoryContext.Changed += new CategoryContext.CategoryChangedEventHandler(_categoryContext_Changed);

            // standard designer stuff
            InitializeComponent();

            this.buttonAdd.Text = Res.Get(StringId.AddButton2);

            // mini form behavior
            DismissOnDeactivate = true;

            // dynamic background colors based on theme
            BackColor = ColorizedResources.Instance.FrameGradientLight ;
            categoryRefreshControl.BackColor = ColorizedResources.Instance.FrameGradientLight ;
            categoryContainerControl.BackColor = SystemColors.Window ;

            // dynamic layout depending upon whether we support adding categories
            if ( categoryContext.SupportsAddingCategories )
            {
                textBoxAddCategory.MaxLength = categoryContext.MaxCategoryNameLength ;
            }
            else
            {
                int gap = categoryContainerControl.Top - panelAddCategory.Top ;
                panelAddCategory.Visible = false ;
                categoryContainerControl.Top = panelAddCategory.Top + 2 ;
                categoryContainerControl.Height += gap ;
            }

            // dynamic layout depending upon whether we support heirarchical categories
            if ( !categoryContext.SupportsHierarchicalCategories )
            {
                textBoxAddCategory.Width += (comboBoxParent.Right - textBoxAddCategory.Right);
                comboBoxParent.Visible = false ;
            }

            // initialize add textbox
            ClearAddTextBox() ;

            // initialize category control
            categoryRefreshControl.Initialize(_categoryContext);
        }
        public void Initialize(CategoryContext context)
        {
            SuspendLayout();
            buttonRefresh.BitmapDisabled = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapEnabled = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapPushed = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refresh.png");
            buttonRefresh.BitmapSelected = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.refreshSelected.png");
            buttonRefresh.TextAlignment = TextAlignment.Right;
            buttonRefresh.ButtonStyle = ButtonStyle.Standard;
            buttonRefresh.ButtonText = Res.Get(StringId.CategoryRefreshList);
            this.buttonRefresh.Size = new Size(94, 22);
            buttonRefresh.Click += new EventHandler(buttonRefresh_Click);

            ResumeLayout(false);
            _categoryContext = context;

        }
        private void AdaptToBlogOptions()
        {
            if (_targetBlog.ClientOptions.SupportsMultipleCategories)
            {
                CategoryContext.SelectionMode = CategoryContext.SelectionModes.MultiSelect;
            }
            else
            {
                CategoryContext.SelectionMode = CategoryContext.SelectionModes.SingleSelect;
            }

            CategoryContext.SupportsAddingCategories       = _targetBlog.ClientOptions.SupportsNewCategories;
            CategoryContext.SupportsHierarchicalCategories = _targetBlog.ClientOptions.SupportsHierarchicalCategories;
            CategoryContext.MaxCategoryNameLength          = _targetBlog.ClientOptions.MaxCategoryNameLength;

            // categories from blog
            CategoryContext.SetBlogCategories(_targetBlog.Categories);
        }
        void IBlogPostEditor.OnBlogChanged(Blog newBlog)
        {
            // save dirty state
            bool isDirty = _isDirty;

            _targetBlog = newBlog;

            AdaptToBlogOptions();

            // a new blog always wipes out "New" categories
            CategoryContext.SetNewCategories(new BlogPostCategory[0]);

            _lastSelectedCategories            = new BlogPostCategory[0];
            CategoryContext.SelectedCategories = new BlogPostCategory[0];

            // restore dirty state
            _isDirty = isDirty;
        }
        public PostPropertiesBandControl(CommandManager commandManager)
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);

            InitializeComponent();

            categoryContext = new CategoryContext();

            controller = new SharedPropertiesController(this, null, categoryDropDown,
                null, textTags, labelPageOrder, textPageOrder, labelPageParent, comboPageParent, null,
                datePublishDate, fields, categoryContext);

            SimpleTextEditorCommandHelper.UseNativeBehaviors(commandManager,
                textTags, textPageOrder);

            postPropertiesForm = new PostPropertiesForm(commandManager, categoryContext);
            if (components == null)
                components = new Container();
            components.Add(postPropertiesForm);

            postPropertiesForm.Synchronize(controller);

            commandManager.Add(CommandId.PostProperties, PostProperties_Execute);
            commandManager.Add(CommandId.ShowCategoryPopup, ShowCategoryPopup_Execute);

            linkViewAll.KeyDown += (sender, args) =>
                                   {
                                       if (args.KeyValue == ' ')
                                           linkViewAll_LinkClicked(sender, new LinkLabelLinkClickedEventArgs(null));
                                   };

            // WinLive 180287: We don't want to show or use mnemonics on labels in the post properties band because
            // they can steal focus from the canvas.
            linkViewAll.Text = TextHelper.StripAmpersands(Res.Get(StringId.ViewAll));
            linkViewAll.UseMnemonic = false;
            labelPageParent.Text = TextHelper.StripAmpersands(Res.Get(StringId.PropertiesPageParent));
            labelPageParent.UseMnemonic = false;
            labelPageOrder.Text = TextHelper.StripAmpersands(Res.Get(StringId.PropertiesPageOrder));
            labelPageOrder.UseMnemonic = false;
        }
        void IBlogPostEditor.Initialize(IBlogPostEditingContext editingContext, IBlogClientOptions clientOptions)
        {
            // categories from blog
            CategoryContext.SetBlogCategories(_targetBlog.Categories);

            // pickup new categories from the blog-post
            CategoryContext.SetNewCategories(editingContext.BlogPost.NewCategories);

            // combine all post categories before settting
            ArrayList selectedCategories = new ArrayList();

            selectedCategories.AddRange(editingContext.BlogPost.NewCategories);
            selectedCategories.AddRange(editingContext.BlogPost.Categories);
            _lastSelectedCategories            = new BlogPostCategory[0];
            CategoryContext.SelectedCategories = selectedCategories.ToArray(typeof(BlogPostCategory)) as BlogPostCategory[];

            toolTipCategories.SetToolTip(this, CategoryContext.FormattedCategoryList);
            _isDirty = false;
        }
Ejemplo n.º 18
0
        private void LayoutControls(CategoryContext categoryContext, bool sizeForm, bool performRtlLayoutFixup)
        {
            ClearForm();
            SuspendLayout();

            // calculate how much room there is above me on the parent form
            int  parentControlY = _parentControl.PointToScreen(_parentControl.Location).Y;
            Form parentForm     = _parentControl.FindForm();
            int  parentFormY    = parentForm.PointToScreen(parentForm.ClientRectangle.Location).Y;
            int  maxHeight      = parentControlY - parentFormY - ScaleY(_topMargin) - ScaleY(_bottomMargin);

            // enforce additional constraint (or not, let freedom reign!)
            //maxHeight = Math.Min(maxHeight, 400) ;

            using (PositionManager positionManager = new PositionManager(ScaleX(X_MARGIN), ScaleY(Y_MARGIN + 2), ScaleY(4), ScaleX(MinDropDownWidth), categoryContainerControl.Width, maxHeight, scale))
            {
                // add 'none' if we're single selecting categories
                if (categoryContext.SelectionMode != CategoryContext.SelectionModes.MultiSelect)
                {
                    AddCategoryControl(new BlogPostCategoryListItem(new BlogPostCategoryNone(), 0), positionManager);
                }

                // add the other categories
                BlogPostCategoryListItem[] categoryListItems = BlogPostCategoryListItem.BuildList(categoryContext.Categories, true);
                foreach (BlogPostCategoryListItem categoryListItem in categoryListItems)
                {
                    AddCategoryControl(categoryListItem, positionManager);
                }

                if (sizeForm)
                {
                    PositionAndSizeForm(positionManager);
                }
            }
            if (performRtlLayoutFixup)
            {
                BidiHelper.RtlLayoutFixup(categoryContainerControl);
            }
            ResumeLayout();
        }
Ejemplo n.º 19
0
        public TreeCategorySelector(CategoryContext ctx)
        {
            this.ctx = ctx;
            InitializeComponent();

            // TODO: Whoops, missed UI Freeze... add this later
            //treeView.AccessibleName = Res.Get(StringId.CategorySelector);

            // On Windows XP, checkboxes and images seem to be mutually exclusive. Vista works fine though.
            if (Environment.OSVersion.Version.Major >= 6)
            {
                imageList.Images.Add(new Bitmap(imageList.ImageSize.Width, imageList.ImageSize.Height));
                treeView.ImageList = imageList;
                treeView.ImageIndex = 0;
            }

            LoadCategories();

            treeView.BeforeCollapse += delegate (object sender, TreeViewCancelEventArgs e) { e.Cancel = true; };
            treeView.AfterCheck += treeView1_AfterCheck;

            treeView.LostFocus += delegate { treeView.Invalidate(); };
        }
 private void _categoryContext_Changed(object sender, CategoryContext.CategoryChangedEventArgs e)
 {
     if (e.ChangeType == CategoryContext.ChangeType.Category || e.ChangeType == CategoryContext.ChangeType.SelectionMode)
     {
         BlogPostCategory[] selectedCategories = GetCurrentlySelectedCategories();
         LayoutControls(_categoryContext, false, true);
         UpdateSelectedCategories(selectedCategories);
         RefreshParentCombo() ;
         Invalidate() ;
     }
 }
Ejemplo n.º 21
0
        public CategoryDisplayFormW3M1(CategoryContext ctx, Point?anchor)
        {
            this.ctx    = ctx;
            this.anchor = anchor;

            InitializeComponent();

            if (ctx.MaxCategoryNameLength > 0)
            {
                txtNewCategory.MaxLength = ctx.MaxCategoryNameLength;
            }

            /* TODO: Whoops, missed UI Freeze... do this later
             * txtFilter.AccessibleName = Res.Get(StringId.CategoryCategoryFilter);
             * cbParent.AccessibleName = Res.Get(StringId.CategoryNewCategoryParent);
             */
            txtNewCategory.AccessibleName = Res.Get(StringId.CategoryCategoryName);
            btnRefresh.AccessibleName     = Res.Get(StringId.CategoryRefreshList);

            grpAdd.Enter += delegate { AcceptButton = btnDoAdd; };
            grpAdd.Leave += delegate { AcceptButton = null; };

            grpAdd.Text   = Res.Get(StringId.CategoryAdd);
            btnDoAdd.Text = Res.Get(StringId.AddButton2);
            toolTip.SetToolTip(btnRefresh, Res.Get(StringId.CategoryRefreshList));
            ControlHelper.SetCueBanner(txtNewCategory, Res.Get(StringId.CategoryCategoryName));
            lblNone.Text = Res.Get(StringId.CategoryControlNoCategories2);

            RefreshParentCombo();

            btnRefresh.Image      = ResourceHelper.LoadAssemblyResourceBitmap("OpenPost.Images.RefreshPostListEnabled.png");
            btnRefresh.ImageAlign = ContentAlignment.MiddleCenter;
            pictureBox1.Image     = ResourceHelper.LoadAssemblyResourceBitmap("PostPropertyEditing.CategoryControl.Images.Search.png");
            pictureBox1.SizeMode  = PictureBoxSizeMode.StretchImage;
            DismissOnDeactivate   = true;

            Control selectorControl;

            if (ctx.SelectionMode == CategoryContext.SelectionModes.SingleSelect)
            {
                selectorControl = new RadioCategorySelector(ctx);
            }
            else if (ctx.SelectionMode == CategoryContext.SelectionModes.MultiSelect)
            {
                selectorControl = new TreeCategorySelector(ctx);
            }
            else
            {
                throw new ArgumentException("Unexpected selection mode: " + ctx.SelectionMode);
            }

            lblNone.BringToFront();
            lblNone.Visible = ctx.Categories.Length == 0;

            selector = (ICategorySelector)selectorControl;
            AdaptAddCategories();
            ctx.Changed         += ctx_Changed;
            Disposed            += delegate { ctx.Changed -= ctx_Changed; };
            selectorControl.Dock = DockStyle.Fill;
            selectorContainer.Controls.Add(selectorControl);

            txtFilter.AccessibleName = Res.Get(StringId.FindCategory);
            cbParent.AccessibleName  = ControlHelper.ToAccessibleName(Res.Get(StringId.CategoryParentAccessible));
        }
        private void LayoutControls(CategoryContext categoryContext, bool sizeForm, bool performRtlLayoutFixup)
        {
            ClearForm();
            SuspendLayout();

            // calculate how much room there is above me on the parent form
            int parentControlY = _parentControl.PointToScreen(_parentControl.Location).Y ;
            Form parentForm = _parentControl.FindForm() ;
            int parentFormY = parentForm.PointToScreen(parentForm.ClientRectangle.Location).Y ;
            int maxHeight = parentControlY - parentFormY - ScaleY(_topMargin) - ScaleY(_bottomMargin);

            // enforce additional constraint (or not, let freedom reign!)
            //maxHeight = Math.Min(maxHeight, 400) ;

            using (PositionManager positionManager = new PositionManager(ScaleX(X_MARGIN), ScaleY(Y_MARGIN + 2), ScaleY(4), ScaleX(MinDropDownWidth), categoryContainerControl.Width, maxHeight, scale))
            {
                // add 'none' if we're single selecting categories
                if (categoryContext.SelectionMode != CategoryContext.SelectionModes.MultiSelect)
                    AddCategoryControl(new BlogPostCategoryListItem(new BlogPostCategoryNone(), 0), positionManager);

                // add the other categories
                BlogPostCategoryListItem[] categoryListItems = BlogPostCategoryListItem.BuildList(categoryContext.Categories, true) ;
                foreach(BlogPostCategoryListItem categoryListItem in categoryListItems)
                    AddCategoryControl(categoryListItem, positionManager) ;

                if ( sizeForm )
                    PositionAndSizeForm(positionManager);
            }
            if (performRtlLayoutFixup)
                BidiHelper.RtlLayoutFixup(categoryContainerControl);
            ResumeLayout();
        }
        private void _categoryContext_Changed(object sender, CategoryContext.CategoryChangedEventArgs e)
        {
            _isDirty = true ;

            toolTipCategories.SetToolTip(this, CategoryContext.FormattedCategoryList);
            Invalidate();
            Update();
        }
        public CategoryDropDownControl() : base()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // prevent editing and showing of drop down
            DropDownStyle = ComboBoxStyle.DropDownList ;

            // fully cusotm painting
            IntegralHeight = false ;
            DrawMode = DrawMode.OwnerDrawFixed ;
            Items.Add(String.Empty) ;

            _categoryContext = new CategoryContext();
        }
        private BlogPostCategory[] GetCategories(CategoryContext context)
        {
            ArrayList categories = new ArrayList(context.Categories);
            categories.Sort();


            return (BlogPostCategory[]) categories.ToArray(typeof (BlogPostCategory));
        }
        private void _categoryContext_Changed(object sender, CategoryContext.CategoryChangedEventArgs e)
        {
            if (!CategoryListsAreEqual(_lastSelectedCategories, CategoryContext.SelectedCategories))
                _isDirty = true;

            // always record last selected categories
            _lastSelectedCategories = CategoryContext.SelectedCategories;

            toolTipCategories.SetToolTip(this, CategoryContext.FormattedCategoryList);
            Invalidate();
            Update();
        }
        private void ctx_Changed(object sender, CategoryContext.CategoryChangedEventArgs eventArgs)
        {
            switch (eventArgs.ChangeType)
            {
                case CategoryContext.ChangeType.Category:
                    lblNone.Visible = ctx.Categories.Length == 0;
                    selector.LoadCategories();

                    // Fix bug 611888: Funny grey box in category control when adding a category to an empty category list
                    // Yes, this does need to happen in a BeginInvoke--invalidating doesn't work
                    // properly until some other (unknown) message gets consumed
                    BeginInvoke(new System.Threading.ThreadStart(delegate { ((Control)selector).Invalidate(true); }));

                    break;
                case CategoryContext.ChangeType.SelectionMode:
                    Close();
                    break;
            }
        }
 void IBlogPostEditor.OnBlogSettingsChanged(bool templateChanged)
 {
     // make sure we have the lastest categoires (in case the underlying target blog changed)
     CategoryContext.SetBlogCategories(_targetBlog.Categories);
 }
 public void Initialize(IWin32Window parentFrame, CategoryContext categoryContext)
 {
     _categoryContext = categoryContext ?? new CategoryContext();
     _parentFrame = parentFrame;
     _categoryContext.BlogCategorySettings = this;
     _categoryContext.Changed += new CategoryContext.CategoryChangedEventHandler(_categoryContext_Changed);
 }