public PropertyAdapter(BoundPropertyDescriptor property, PropertyEditorBase editor) { _property = property; _editor = editor; _editor.PropertyChanging += _editor_PropertyChanging; _editor.PropertyChangeCommitted += _editor_PropertyChangeCommitted; _editor.PropertyChangeReverted += _editor_PropertyChangeReverted; }
internal PropertyGridItem(Panel editorPanel, Label nameLabel, PropertyEditorBase editor) { Debug.Assert(editorPanel != null); Debug.Assert(nameLabel != null); Debug.Assert(editor != null); _editorPanel = editorPanel; _nameLabel = nameLabel; _propertyEditor = editor; }
public PropertyGridItem Add(String name, PropertyEditorBase propertyEditor) { return(_owner._addItem(name, propertyEditor)); }
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); }