public override object GetValue(object component) { // Have the property bag raise an event to get the current value // of the property. PropertySpecEventArgs e = new PropertySpecEventArgs(item, null); bag.OnGetValue(e); return e.Value; }
public override void SetValue(object component, object value) { // Have the property bag raise an event to set the current value // of the property. PropertySpecEventArgs e = new PropertySpecEventArgs(item, value); bag.OnSetValue(e); }
public string GetPropertiesString() { string strVal = ""; foreach(PropertySpec property in properties) { PropertySpecEventArgs e = new PropertySpecEventArgs(property, null); OnGetValue(e); if(e.Value != null) { if(e.Value.GetType() == typeof(PropertyTable) || e.Value.GetType() == typeof(PropertyBag)) return ""; else strVal += e.Value.ToString() + ", "; } } return strVal.Substring(0, (strVal.Length-2)); }
/// <summary> /// Raises the SetValue event. /// </summary> /// <param name="e">A PropertySpecEventArgs that contains the event data.</param> protected virtual void OnSetValue(PropertySpecEventArgs e) { if(SetValue != null) SetValue(this, e); }
/// <summary> /// This member overrides PropertyBag.OnSetValue. /// </summary> protected override void OnSetValue(PropertySpecEventArgs e) { propValues[e.Property.Name] = e.Value; base.OnSetValue(e); }
/// <summary> /// This member overrides PropertyBag.OnGetValue. /// </summary> protected override void OnGetValue(PropertySpecEventArgs e) { e.Value = propValues[e.Property.Name]; // if(e.Value == null) // throw new System.Exception("No value with the specified property name exists. PropertyName: " + e.Property.Name); base.OnGetValue(e); }
protected void ctrlValue_Changed(object sender, System.EventArgs e) { try { if(txtValue.Text.Trim().Length == 0) throw new System.Exception("Invalid property value for '" + this.PropertyName + "', you must specify a value."); if(m_PropertySpec != null) { double dblVal = Convert.ToDouble(txtValue.Text); PropertySpecEventArgs args = new PropertySpecEventArgs(m_PropertySpec, Convert.ChangeType(dblVal, Type.GetType(m_PropertySpec.TypeName))); OnSetValue(args); SetSliderValue(dblVal); m_dblCurrentValue = dblVal; } } catch(System.Exception ex) { //System.Windows.Forms.MessageBox.Show(this, ex.Message, "Slider Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); string strVal = ex.Message; //Freaking error CS0168 //Lets reset the value back to the one in the slider. txtValue.Text = m_dblCurrentValue.ToString(); } }
protected void ctrlSlider_Scroll(object sender, System.EventArgs e) { try { if(m_PropertySpec != null) { double dblVal = CalculateValueFromSlider(); PropertySpecEventArgs args = new PropertySpecEventArgs(m_PropertySpec, Convert.ChangeType(dblVal, Type.GetType(m_PropertySpec.TypeName))); OnSetValue(args); txtValue.Text = dblVal.ToString(); m_dblCurrentValue = dblVal; } } catch(System.Exception ex) { string strVal = ex.Message; //Freaking error CS0168 //System.Windows.Forms.MessageBox.Show(this, ex.Message, "Slider Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
public void GetValues() { if(m_PropertySpec != null) { PropertySpecEventArgs args = new PropertySpecEventArgs(m_PropertySpec, 0); OnGetValue(args); double dblValue = Convert.ToDouble(args.Value); SetSliderValue(dblValue); } }