protected override void OnDrawItem(DrawItemEventArgs e)
            {
                if (e.Index != -1)
                {
                    ParentCategoryComboItem comboItem = Items[e.Index] as ParentCategoryComboItem;

                    e.DrawBackground();

                    // don't indent for main display of category
                    string text = comboItem != null?comboItem.ToString() : "";

                    if (e.Bounds.Width < Width)
                    {
                        text = text.Trim();
                    }

                    Color textColor = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                                          ? SystemColors.HighlightText
                                          : comboItem.TextColor;

                    BidiGraphics bg = new BidiGraphics(e.Graphics, e.Bounds);
                    bg.DrawText(text, e.Font, e.Bounds, textColor, TextFormatFlags.NoPrefix);

                    e.DrawFocusRectangle();
                }
            }
            public override bool Equals(object obj)
            {
                ParentCategoryComboItem item = obj as ParentCategoryComboItem;

                if (item == null)
                {
                    return(false);
                }
                return(item.Category.Equals(Category));
            }
Example #3
0
        private BlogPostCategory GetParentCategory()
        {
            ParentCategoryComboItem parentComboItem = comboBoxParent.SelectedItem as ParentCategoryComboItem;

            if (parentComboItem != null)
            {
                if (!BlogPostCategoryNone.IsCategoryNone(parentComboItem.Category))
                {
                    return(parentComboItem.Category);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #4
0
            protected override void OnDrawItem(DrawItemEventArgs e)
            {
                if (e.Index != -1)
                {
                    ParentCategoryComboItem comboItem = Items[e.Index] as ParentCategoryComboItem;

                    e.DrawBackground();

                    // don't indent for main display of category
                    string text = comboItem.ToString();
                    if (e.Bounds.Width < Width)
                    {
                        text = text.Trim();
                    }

                    using (Brush brush = new SolidBrush(e.ForeColor))
                        e.Graphics.DrawString(text, e.Font, brush, e.Bounds.X, e.Bounds.Y);

                    e.DrawFocusRectangle();
                }
            }