public PropertyGrid(ServiceContainer parentServices) { this.parentServices = parentServices; grid = new AspNetEdit.UI.PropertyGrid(); this.PackEnd(grid, true, true, 0); components = new ListStore(typeof(string), typeof(IComponent)); combo = new ComboBox(components); CellRenderer rdr = new CellRendererText(); combo.PackStart(rdr, true); combo.AddAttribute(rdr, "text", 0); this.PackStart(combo, false, false, 3); //for selecting nothing, i.e. deselect all components.AppendValues(new object[] { "", null }); combo.Changed += new EventHandler(combo_Changed); InitialiseServices(); }
public PropertyGrid(ServiceContainer parentServices) { this.parentServices = parentServices; grid = new AspNetEdit.UI.PropertyGrid (); this.PackEnd (grid, true, true, 0); components = new ListStore (typeof (string), typeof (IComponent)); combo = new ComboBox (components); CellRenderer rdr = new CellRendererText (); combo.PackStart (rdr, true); combo.AddAttribute (rdr, "text", 0); this.PackStart (combo, false, false, 3); //for selecting nothing, i.e. deselect all components.AppendValues (new object[] { "", null} ); combo.Changed += new EventHandler (combo_Changed); InitialiseServices(); }
public GridRow(PropertyGrid parentGrid, PropertyDescriptor descriptor) { this.parent = parentGrid; this.propertyDescriptor = descriptor; // TODO: Need a better way to check if the property has no get accessor. // Write-only? Don't add this to the list. try {object propertyValue = descriptor.GetValue (parent.CurrentObject);} catch (Exception) { isValidProperty = false; return; } #region Name label string name = descriptor.DisplayName; ParenthesizePropertyNameAttribute paren = descriptor.Attributes[typeof (ParenthesizePropertyNameAttribute)] as ParenthesizePropertyNameAttribute; if (paren != null && paren.NeedParenthesis) name = "(" + name + ")"; propertyNameLabel = new Label (name); propertyNameLabel.Xalign = 0; propertyNameLabel.Xpad = 3; propertyNameLabel.HeightRequest = 20; propertyNameEventBox = new EventBox (); propertyNameEventBox.ModifyBg (StateType.Normal, parent.Style.White); propertyNameEventBox.Add (propertyNameLabel); propertyNameEventBox.ButtonReleaseEvent += on_label_ButtonRelease; if (propertyNameLabel.SizeRequest ().Width > 100) { propertyNameLabel.WidthRequest = 100; //TODO: Display tooltip of full name when truncated //parent.tooltips.SetTip (propertyNameLabel, descriptor.DisplayName, descriptor.DisplayName); } #endregion editor = parent.EditorManager.GetEditor(propertyDescriptor, this); propertyValueHBox = new HBox(); //check if it needs a button. Note arrays are read-only but have buttons if (editor.DialogueEdit && (!propertyDescriptor.IsReadOnly || editor.EditsReadOnlyObject)) { Label buttonLabel = new Label (); buttonLabel.UseMarkup = true; buttonLabel.Xpad = 0; buttonLabel.Ypad = 0; buttonLabel.Markup = "<span size=\"small\">...</span>"; Button dialogueButton = new Button (buttonLabel); dialogueButton.Clicked += new EventHandler (dialogueButton_Clicked); propertyValueHBox.PackEnd (dialogueButton, false, false, 0); } propertyValueEventBox = new EventBox (); propertyValueEventBox.ModifyBg (StateType.Normal, parent.Style.White); propertyValueEventBox.CanFocus = true; propertyValueEventBox.ButtonReleaseEvent += on_value_ButtonRelease; propertyValueEventBox.Focused += on_value_ButtonRelease; propertyValueHBox.PackStart (propertyValueEventBox, true, true, 0); valueBeforeEdit = propertyDescriptor.GetValue (parentGrid.CurrentObject); DisplayRenderWidget (); }