void _scrollToGridItem(PropertyGridItem item)
        {
            Rectangle displayRect =
                _splitContainer.Panel1.RectangleToScreen(
                    new Rectangle(
                        0,
                        0,
                        _splitContainer.Panel1.Width,
                        _splitContainer.Panel1.Height
                        )
                    );

            Rectangle editorPanelRect =
                item.EditorPanel.RectangleToScreen(
                    new Rectangle(Point.Empty, item.EditorPanel.Size)
                    );

            if (editorPanelRect.Height >= displayRect.Height)
            {
                return;
            }

            if (editorPanelRect.Bottom > displayRect.Bottom)
            {
                int offset =
                    (displayRect.Bottom - editorPanelRect.Height) -
                    editorPanelRect.Top;

                _sectionPanelScrollBar.Value -= offset;
                _sectionPanel.Top            += offset;
            }
            else
            if (editorPanelRect.Top < displayRect.Top)
            {
                int offset = displayRect.Top - editorPanelRect.Top;

                _sectionPanelScrollBar.Value -= offset;
                _sectionPanel.Top            += offset;
            }
        }
        void _section_SelectedItemChanged(object sender, EventArgs e)
        {
            if (!_updatingSelection)
            {
                _updatingSelection = true;

                _helpTextTitleLabel.Text = "";
                _helpTextLabel.Text      = "";

                PropertyGridSection selectedSection = (PropertyGridSection)sender;

                foreach (PropertyGridSection section in _sections)
                {
                    if (selectedSection != section)
                    {
                        section.ResetSelectedItem();
                    }
                    else
                    {
                        PropertyGridItem selectedItem = section.SelectedItem;

                        if (selectedItem != null)
                        {
                            if (selectedItem.Description != null)
                            {
                                _helpTextTitleLabel.Text = selectedItem.Name;
                                _helpTextLabel.Text      = selectedItem.Description;
                            }

                            _scrollToGridItem(selectedItem);
                        }
                    }
                }

                _updatingSelection = false;
            }
        }
示例#3
0
            public void Remove(String name)
            {
                PropertyGridItem item = this[name];

                _owner._removeItem(item);
            }
示例#4
0
 public ItemEx(PropertyGridItem item, Label nameLabel)
 {
     Item      = item;
     NameLabel = nameLabel;
 }
示例#5
0
        PropertyGridItem _addItem(String name, PropertyEditorBase propertyEditor)
        {
            Debug.Assert(Items[Name] == null);
            Debug.Assert(!String.IsNullOrEmpty(name));
            Debug.Assert(propertyEditor != null);

            int y = _calculateItemHeight();

            Label nameLabel = new Label();

            nameLabel.AutoSize  = false;
            nameLabel.Location  = new Point(0, y);
            nameLabel.Size      = new Size(_splitContainer.Panel1.Width, DEFAULT_ITEM_HEIGHT - 1);
            nameLabel.Text      = name;
            nameLabel.Anchor    = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            nameLabel.BackColor = Color.White;
            nameLabel.TextAlign = ContentAlignment.MiddleLeft;
            nameLabel.Click    += new EventHandler(_nameTextBox_Click);
            nameLabel.Font      = new Font("Segoe UI", 8.25f, FontStyle.Regular);
            nameLabel.UseCompatibleTextRendering = true;

            _splitContainer.Panel1.Controls.Add(nameLabel);

            ToolTip nameLabelToolTip = new ToolTip();

            nameLabelToolTip.SetToolTip(nameLabel, nameLabel.Text);

            Panel editorPanel = new Panel();

            editorPanel.Location     = new Point(0, y);
            editorPanel.Size         = new Size(_splitContainer.Panel2.ClientSize.Width, DEFAULT_ITEM_HEIGHT - 1);
            editorPanel.Anchor       = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            editorPanel.AutoScroll   = false;
            editorPanel.BackColor    = Color.White;
            editorPanel.SizeChanged += new EventHandler(_editorPanel_SizeChanged);
            _splitContainer.Panel2.Controls.Add(editorPanel);

            PropertyGridItem item = new PropertyGridItem(editorPanel, nameLabel, propertyEditor);

            item.Owner = this;

            item.EditorPanel.Height = propertyEditor.Height;
            propertyEditor.Width    = item.EditorPanel.Width;
            propertyEditor.Anchor   =
                System.Windows.Forms.AnchorStyles.Top |
                System.Windows.Forms.AnchorStyles.Left |
                System.Windows.Forms.AnchorStyles.Right;

            editorPanel.Controls.Add(propertyEditor);

            propertyEditor.PropertyGridItem = item;

            propertyEditor.Enter += delegate(Object sender, EventArgs e)
            {
                SelectedItem = item;
            };

            propertyEditor.Leave += delegate(Object sender, EventArgs e)
            {
                SelectedItem = null;
            };

            _items.Add(new ItemEx(item, nameLabel));

            _updateExpandState();

            return(item);
        }
示例#6
0
 void _titelLabel_Click(object sender, EventArgs e)
 {
     SelectedItem = null;
 }
示例#7
0
 internal void ResetSelectedItem()
 {
     SelectedItem = null;
 }