public void Ctor_NeedParenthesis(bool needParenthesis) { var attribute = new ParenthesizePropertyNameAttribute(needParenthesis); Assert.Equal(needParenthesis, attribute.NeedParenthesis); Assert.Equal(!needParenthesis, attribute.IsDefaultAttribute()); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] lst = new PropertyDescriptor[3]; int n = 0; Attribute[] attrs; if (attributes != null) { n = attributes.Length; attrs = new Attribute[n + 1]; if (attributes.Length > 0) { attributes.CopyTo(attrs, 0); } } else { attrs = new Attribute[n + 1]; } attrs[n] = new ParenthesizePropertyNameAttribute(true); lst[0] = new PropertyDescriptorName(ReadOnly, this, attrs); lst[1] = new PropertyDescriptorForDisplay(this.GetType(), "Type", _value.ValueType.Name, attributes); lst[2] = new PropertyDescriptorValue(ReadOnly, this, attributes); PropertyDescriptorCollection ps = new PropertyDescriptorCollection(lst); return(ps); }
public void Equals_DifferentValues() { var firstAttribute = new ParenthesizePropertyNameAttribute(true); var secondAttribute = new ParenthesizePropertyNameAttribute(false); Assert.False(firstAttribute.Equals(secondAttribute)); }
public void Ctor_Default() { var attribute = new ParenthesizePropertyNameAttribute(); Assert.False(attribute.NeedParenthesis); Assert.True(attribute.IsDefaultAttribute()); }
public void Equals_Object_ReturnsExpected(ParenthesizePropertyNameAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is ParenthesizePropertyNameAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
/// <summary> /// <para>Compares the specified object /// to this object and tests for equality.</para> /// </summary> public override bool Equals(object obj) { if (obj == this) { return(true); } ParenthesizePropertyNameAttribute other = obj as ParenthesizePropertyNameAttribute; return(other != null && other.NeedParenthesis == NeedParenthesis); }
// Determine if two objects are equal. public override bool Equals(Object obj) { ParenthesizePropertyNameAttribute other = (obj as ParenthesizePropertyNameAttribute); if (other != null) { return(needParenthesis == other.needParenthesis); } else { return(false); } }
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(); }
public void NameTests(ParenthesizePropertyNameAttribute attribute, bool needParenthesis) { Assert.Equal(needParenthesis, attribute.NeedParenthesis); }
public void GetNeedParenthesis(bool value) { var attribute = new ParenthesizePropertyNameAttribute(value); Assert.Equal(value, attribute.NeedParenthesis); }