public PropertyEditor PickEditorAt(int x, int y, bool ownChildrenOnly = false)
        {
            Rectangle indentClientRect = this.ClientRectangle;

            indentClientRect.X     += this.indent;
            indentClientRect.Width -= this.indent;
            if (this.expanded && indentClientRect.Contains(new Point(x, y)))
            {
                foreach (PropertyEditor child in this.propertyEditors)
                {
                    if (child.EditorRectangle.Contains(x, y))
                    {
                        GroupedPropertyEditor groupedEditor = child as GroupedPropertyEditor;
                        if (groupedEditor != null && !ownChildrenOnly)
                        {
                            return(groupedEditor.PickEditorAt(x, y));
                        }
                        else
                        {
                            return(child);
                        }
                    }
                }
            }

            return(this);
        }
 public void SetEditorExpanded(GroupedPropertyEditor editor, bool expanded)
 {
     if (editor == null) return;
     string id = GetEditorFullId(editor);
     if (expanded) this.expandedNodes.Add(id);
     else this.expandedNodes.Remove(id);
 }
        protected void AddPropertyEditor(PropertyEditor editor, int atIndex = -1)
        {
            if (this.propertyEditors.Contains(editor))
            {
                this.propertyEditors.Remove(editor);
            }

            editor.ParentEditor = this;

            if (atIndex == -1)
            {
                this.propertyEditors.Add(editor);
            }
            else
            {
                this.propertyEditors.Insert(atIndex, editor);
            }

            GroupedPropertyEditor groupedEditor = editor as GroupedPropertyEditor;

            if (groupedEditor != null && groupedEditor.Expanded && !groupedEditor.ContentInitialized)
            {
                groupedEditor.InitContent();
            }

            this.OnEditorAdded(editor);
            this.UpdateChildGeometry();

            editor.ValueChanged    += this.OnValueChanged;
            editor.EditingFinished += this.OnEditingFinished;
            editor.SizeChanged     += this.child_SizeChanged;
        }
Beispiel #4
0
        public bool IsEditorExpanded(GroupedPropertyEditor editor)
        {
            if (editor == null)
            {
                return(false);
            }
            string id = GetEditorFullId(editor);

            return(expandedNodes.Contains(id));
        }
        protected void IndentChildExpandOnMouseUp(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null)
            {
                return;
            }

            if (childGroup.expandCheckPressed && (e.Button & MouseButtons.Left) != MouseButtons.None)
            {
                Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
                childGroup.expandCheckPressed = false;
                this.Invalidate(expandRect);
            }
        }
        protected void IndentChildExpandOnMouseLeave(EventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null)
            {
                return;
            }
            Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);

            if (childGroup.expandCheckHovered)
            {
                this.Invalidate(expandRect);
            }
            childGroup.expandCheckHovered = false;
            childGroup.expandCheckPressed = false;
        }
Beispiel #7
0
        public PropertyEditor PickEditorAt(int x, int y, bool scrolled = false)
        {
            if (this.mainEditor == null)
            {
                return(null);
            }
            if (scrolled)
            {
                x -= this.AutoScrollPosition.X;
                y -= this.AutoScrollPosition.Y;
            }
            GroupedPropertyEditor groupedMainEdit = this.mainEditor as GroupedPropertyEditor;

            return(groupedMainEdit != null?groupedMainEdit.PickEditorAt(x - this.ClientRectangle.X, y - this.ClientRectangle.Y) : this.mainEditor);
        }
Beispiel #8
0
        public void SetEditorExpanded(GroupedPropertyEditor editor, bool expanded)
        {
            if (editor == null)
            {
                return;
            }
            string id = GetEditorFullId(editor);

            if (expanded)
            {
                this.expandedNodes.Add(id);
            }
            else
            {
                this.expandedNodes.Remove(id);
            }
        }
        protected bool IndentChildExpandOnMouseDown(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null)
            {
                return(false);
            }

            if (childGroup.expandCheckHovered && (e.Button & MouseButtons.Left) != MouseButtons.None)
            {
                Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
                childGroup.expandCheckPressed = true;
                this.Invalidate(expandRect);
                childGroup.OnExpandCheckPressed();
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        protected void IndentChildExpandOnMouseMove(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null)
            {
                return;
            }
            Rectangle expandRect        = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
            bool      lastExpandHovered = childGroup.expandCheckHovered;

            childGroup.expandCheckHovered =
                childGroup.CanExpand &&
                (childGroup.Hints & HintFlags.ExpandEnabled) != HintFlags.None &&
                expandRect.Contains(e.Location);

            if (lastExpandHovered != childGroup.expandCheckHovered)
            {
                this.Invalidate(expandRect);
            }
        }
Beispiel #11
0
        protected void UpdatePropertyEditor()
        {
            if (this.mainEditor == null)
            {
                return;
            }

            this.mainEditor.ParentGrid   = this;
            this.mainEditor.ParentEditor = null;
            this.mainEditor.Hints       &= ~(PropertyEditor.HintFlags.HasButton | PropertyEditor.HintFlags.ButtonEnabled);
            this.mainEditor.Getter       = this.ValueGetter;
            this.mainEditor.Setter       = this.readOnly ? null : (Action <IEnumerable <object> >) this.ValueSetter;
            this.mainEditor.Location     = Point.Empty;
            this.mainEditor.Width        = this.ClientSize.Width;
            if (this.mainEditor is GroupedPropertyEditor)
            {
                GroupedPropertyEditor mainGroupEditor = this.mainEditor as GroupedPropertyEditor;
                mainGroupEditor.HeaderStyle = GroupedPropertyEditor.GroupHeaderStyle.Emboss;
                mainGroupEditor.Hints      &= ~PropertyEditor.HintFlags.HasExpandCheck;
            }
        }
Beispiel #12
0
        protected void InitPropertyEditor(Type type)
        {
            if (this.mainEditor != null)
            {
                this.DisposePropertyEditor();
            }

            this.focusEditor                 = null;
            this.mainEditor                  = this.editorProvider.CreateEditor(type, new ProviderContext(this));
            this.mainEditor.SizeChanged     += this.mainEditor_SizeChanged;
            this.mainEditor.ValueChanged    += this.mainEditor_ValueChanged;
            this.mainEditor.EditingFinished += this.mainEditor_EditingFinished;
            this.UpdatePropertyEditor();
            this.ConfigureEditor(this.mainEditor);

            if (this.mainEditor is GroupedPropertyEditor)
            {
                GroupedPropertyEditor mainGroupEditor = this.mainEditor as GroupedPropertyEditor;
                mainGroupEditor.Expanded = true;
            }

            this.Invalidate();
        }
Beispiel #13
0
        protected void PaintIndentExpandButton(Graphics g, GroupedPropertyEditor childGroup)
        {
            if (childGroup.headerHeight == 0)
            {
                return;
            }
            if ((childGroup.Hints & HintFlags.HasExpandCheck) == HintFlags.None)
            {
                return;
            }

            Rectangle indentExpandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
            Rectangle expandButtonRect = new Rectangle(
                indentExpandRect.X + indentExpandRect.Width / 2 - ControlRenderer.ExpandNodeSize.Width / 2,
                indentExpandRect.Y + indentExpandRect.Height / 2 - ControlRenderer.ExpandNodeSize.Height / 2 - 1,
                ControlRenderer.ExpandNodeSize.Width,
                ControlRenderer.ExpandNodeSize.Height);
            ExpandNodeState expandState = ExpandNodeState.OpenedDisabled;

            if (childGroup.Enabled && childGroup.CanExpand && (childGroup.Hints & HintFlags.ExpandEnabled) != HintFlags.None)
            {
                if (!childGroup.Expanded)
                {
                    if (childGroup.expandCheckPressed)
                    {
                        expandState = ExpandNodeState.ClosedPressed;
                    }
                    else if (childGroup.expandCheckHovered)
                    {
                        expandState = ExpandNodeState.ClosedHot;
                    }
                    else if (childGroup.Focused)
                    {
                        expandState = ExpandNodeState.ClosedHot;
                    }
                    else
                    {
                        expandState = ExpandNodeState.ClosedNormal;
                    }
                }
                else
                {
                    if (childGroup.expandCheckPressed)
                    {
                        expandState = ExpandNodeState.OpenedPressed;
                    }
                    else if (childGroup.expandCheckHovered)
                    {
                        expandState = ExpandNodeState.OpenedHot;
                    }
                    else if (childGroup.Focused)
                    {
                        expandState = ExpandNodeState.OpenedHot;
                    }
                    else
                    {
                        expandState = ExpandNodeState.OpenedNormal;
                    }
                }
            }
            else
            {
                if (childGroup.Expanded)
                {
                    expandState = ExpandNodeState.OpenedDisabled;
                }
                else
                {
                    expandState = ExpandNodeState.ClosedDisabled;
                }
            }

            ControlRenderer.DrawExpandNode(g, expandButtonRect.Location, expandState);
        }
Beispiel #14
0
        protected void PaintHeader(Graphics g)
        {
            if (this.headerHeight == 0)
            {
                return;
            }
            Rectangle buttonRect = this.ButtonRectangle;

            CheckBoxState  activeState  = CheckBoxState.UncheckedDisabled;
            ExpandBoxState expandState  = ExpandBoxState.ExpandDisabled;
            bool           parentExpand = this.ParentUseIndentChildExpand;

            if (!parentExpand && (this.Hints & HintFlags.HasExpandCheck) != HintFlags.None)
            {
                if (this.Enabled && this.CanExpand && (this.Hints & HintFlags.ExpandEnabled) != HintFlags.None)
                {
                    if (!this.Expanded)
                    {
                        if (this.expandCheckPressed)
                        {
                            expandState = ExpandBoxState.ExpandPressed;
                        }
                        else if (this.expandCheckHovered)
                        {
                            expandState = ExpandBoxState.ExpandHot;
                        }
                        else
                        {
                            expandState = ExpandBoxState.ExpandNormal;
                        }
                    }
                    else
                    {
                        if (this.expandCheckPressed)
                        {
                            expandState = ExpandBoxState.CollapsePressed;
                        }
                        else if (this.expandCheckHovered)
                        {
                            expandState = ExpandBoxState.CollapseHot;
                        }
                        else
                        {
                            expandState = ExpandBoxState.CollapseNormal;
                        }
                    }
                }
                else
                {
                    if (this.Expanded)
                    {
                        expandState = ExpandBoxState.ExpandDisabled;
                    }
                    else
                    {
                        expandState = ExpandBoxState.CollapseDisabled;
                    }
                }
            }
            if ((this.Hints & HintFlags.HasActiveCheck) != HintFlags.None)
            {
                if (this.Enabled && !this.ReadOnly && (this.Hints & HintFlags.ActiveEnabled) != HintFlags.None)
                {
                    if (this.Active)
                    {
                        if (this.activeCheckPressed)
                        {
                            activeState = CheckBoxState.CheckedPressed;
                        }
                        else if (this.activeCheckHovered)
                        {
                            activeState = CheckBoxState.CheckedHot;
                        }
                        else
                        {
                            activeState = CheckBoxState.CheckedNormal;
                        }
                    }
                    else
                    {
                        if (this.activeCheckPressed)
                        {
                            activeState = CheckBoxState.UncheckedPressed;
                        }
                        else if (this.activeCheckHovered)
                        {
                            activeState = CheckBoxState.UncheckedHot;
                        }
                        else
                        {
                            activeState = CheckBoxState.UncheckedNormal;
                        }
                    }
                }
                else
                {
                    if (this.Active)
                    {
                        activeState = CheckBoxState.CheckedDisabled;
                    }
                    else
                    {
                        activeState = CheckBoxState.UncheckedDisabled;
                    }
                }
            }

            Rectangle iconRect;

            if (this.headerIcon != null)
            {
                iconRect = new Rectangle(
                    this.activeCheckRect.Right + 2,
                    this.headerRect.Y + this.headerRect.Height / 2 - this.headerIcon.Height / 2,
                    this.headerIcon.Width,
                    this.headerIcon.Height);
            }
            else
            {
                iconRect = new Rectangle(this.activeCheckRect.Right, this.headerRect.Y, 0, 0);
            }
            Rectangle textRect = new Rectangle(
                iconRect.Right,
                this.headerRect.Y,
                this.headerRect.Width - buttonRect.Width - iconRect.Width - this.expandCheckRect.Width - this.activeCheckRect.Width - 2,
                this.headerRect.Height);
            Rectangle nameTextRect;
            Rectangle valueTextRect;

            if (!string.IsNullOrEmpty(this.PropertyName) && !string.IsNullOrEmpty(this.headerValueText))
            {
                int nameWidth;
                nameWidth     = this.NameLabelWidth - (textRect.X - this.headerRect.X);
                nameTextRect  = new Rectangle(textRect.X, textRect.Y, nameWidth, textRect.Height);
                valueTextRect = new Rectangle(textRect.X + nameWidth, textRect.Y, textRect.Width - nameWidth, textRect.Height);
            }
            else if (!string.IsNullOrEmpty(this.headerValueText))
            {
                nameTextRect  = new Rectangle(textRect.X, textRect.Y, 0, 0);
                valueTextRect = textRect;
            }
            else
            {
                nameTextRect  = textRect;
                valueTextRect = new Rectangle(textRect.X, textRect.Y, 0, 0);
            }


            bool  focusBg       = this.Focused || (this is IPopupControlHost && (this as IPopupControlHost).IsDropDownOpened);
            bool  adaptBgColor  = this.headerStyle == GroupHeaderStyle.Flat || this.headerStyle == GroupHeaderStyle.Simple;
            Color headerBgColor = this.ControlRenderer.GetBackgroundColor(this.headerColor.Value, focusBg && adaptBgColor, this.Location.X);

            GroupedPropertyEditor.DrawGroupHeaderBackground(g, this.headerRect, headerBgColor, this.headerStyle);
            if (focusBg && !adaptBgColor)
            {
                this.ControlRenderer.DrawBorder(g, this.headerRect, Drawing.BorderStyle.Simple, BorderState.Normal);
            }

            if (!parentExpand && (this.Hints & HintFlags.HasExpandCheck) != HintFlags.None)
            {
                this.ControlRenderer.DrawExpandBox(g, this.expandCheckRect.Location, expandState);
            }
            if ((this.Hints & HintFlags.HasActiveCheck) != HintFlags.None)
            {
                this.ControlRenderer.DrawCheckBox(g, this.activeCheckRect.Location, activeState);
            }

            if (this.headerIcon != null)
            {
                g.DrawImage(this.Enabled ? this.headerIcon.Normal : this.headerIcon.Disabled, iconRect);
            }

            this.ControlRenderer.DrawStringLine(g,
                                                this.PropertyName,
                                                this.ValueModified ? this.ControlRenderer.FontBold : this.ControlRenderer.FontRegular,
                                                nameTextRect,
                                                this.Enabled && !this.NonPublic ? this.ControlRenderer.ColorText : this.ControlRenderer.ColorGrayText);
            this.ControlRenderer.DrawStringLine(g,
                                                this.headerValueText,
                                                this.ValueModified ? this.ControlRenderer.FontBold : this.ControlRenderer.FontRegular,
                                                valueTextRect,
                                                this.Enabled ? this.ControlRenderer.ColorText : this.ControlRenderer.ColorGrayText);
        }
        protected void IndentChildExpandOnMouseUp(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null) return;

            if (childGroup.expandCheckPressed && (e.Button & MouseButtons.Left) != MouseButtons.None)
            {
                Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
                childGroup.expandCheckPressed = false;
                this.Invalidate(expandRect);
            }
        }
        protected void IndentChildExpandOnMouseLeave(EventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null) return;
            Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);

            if (childGroup.expandCheckHovered) this.Invalidate(expandRect);
            childGroup.expandCheckHovered = false;
            childGroup.expandCheckPressed = false;
        }
        protected void PaintIndentExpandButton(Graphics g, GroupedPropertyEditor childGroup)
        {
            if (childGroup.headerHeight == 0) return;
            if ((childGroup.Hints & HintFlags.HasExpandCheck) == HintFlags.None) return;

            Rectangle indentExpandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
            Rectangle expandButtonRect = new Rectangle(
                indentExpandRect.X + indentExpandRect.Width / 2 - ControlRenderer.ExpandNodeSize.Width / 2,
                indentExpandRect.Y + indentExpandRect.Height / 2 - ControlRenderer.ExpandNodeSize.Height / 2 - 1,
                ControlRenderer.ExpandNodeSize.Width,
                ControlRenderer.ExpandNodeSize.Height);
            ExpandNodeState expandState = ExpandNodeState.OpenedDisabled;
            if (childGroup.Enabled && childGroup.CanExpand && (childGroup.Hints & HintFlags.ExpandEnabled) != HintFlags.None)
            {
                if (!childGroup.Expanded)
                {
                    if (childGroup.expandCheckPressed)		expandState = ExpandNodeState.ClosedPressed;
                    else if (childGroup.expandCheckHovered)	expandState = ExpandNodeState.ClosedHot;
                    else if (childGroup.Focused)			expandState = ExpandNodeState.ClosedHot;
                    else									expandState = ExpandNodeState.ClosedNormal;
                }
                else
                {
                    if (childGroup.expandCheckPressed)		expandState = ExpandNodeState.OpenedPressed;
                    else if (childGroup.expandCheckHovered)	expandState = ExpandNodeState.OpenedHot;
                    else if (childGroup.Focused)			expandState = ExpandNodeState.OpenedHot;
                    else									expandState = ExpandNodeState.OpenedNormal;
                }
            }
            else
            {
                if (childGroup.Expanded)	expandState = ExpandNodeState.OpenedDisabled;
                else						expandState = ExpandNodeState.ClosedDisabled;
            }

            ControlRenderer.DrawExpandNode(g, expandButtonRect.Location, expandState);
        }
 public bool IsEditorExpanded(GroupedPropertyEditor editor)
 {
     if (editor == null) return false;
     string id = GetEditorFullId(editor);
     return expandedNodes.Contains(id);
 }
        protected bool IndentChildExpandOnMouseDown(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null) return false;

            if (childGroup.expandCheckHovered && (e.Button & MouseButtons.Left) != MouseButtons.None)
            {
                Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
                childGroup.expandCheckPressed = true;
                this.Invalidate(expandRect);
                childGroup.OnExpandCheckPressed();
                return true;
            }

            return false;
        }
        protected void IndentChildExpandOnMouseMove(MouseEventArgs e, GroupedPropertyEditor childGroup)
        {
            if (childGroup == null) return;
            Rectangle expandRect = new Rectangle(childGroup.Location.X - this.indent, childGroup.Location.Y, this.indent, childGroup.headerHeight);
            bool lastExpandHovered = childGroup.expandCheckHovered;

            childGroup.expandCheckHovered =
                childGroup.CanExpand &&
                (childGroup.Hints & HintFlags.ExpandEnabled) != HintFlags.None &&
                expandRect.Contains(e.Location);

            if (lastExpandHovered != childGroup.expandCheckHovered) this.Invalidate(expandRect);
        }