public PropertySettingGroup Deserialize() { PropertySettingGroup group = new PropertySettingGroup(); group.BasedOn = this.basedOn; if (this.propertySettings != null) { for (int settingIndex = 0; settingIndex < this.PropertySettings.Count; settingIndex++) { XmlPropertySetting xmlPropertySetting = this.PropertySettings[settingIndex]; IPropertySetting setting = xmlPropertySetting.Deserialize(); group.PropertySettings.Add(setting); } } if (this.selectors != null) { for (int selectorIndex = 0; selectorIndex < this.Selectors.Count; selectorIndex++) { XmlElementSelector xmlSelector = this.Selectors[selectorIndex]; IElementSelector selector = xmlSelector.Deserialize(); group.Selectors.Add(selector); } } return(group); }
public static string SerializeValue( PropertyDescriptor prop, object value, string propertyDisplayName) { return(XmlPropertySetting.ConvertValueToString(prop.Converter, value, propertyDisplayName)); }
public static object DeserializeValue( System.Type propertyType, string value, string propertyDisplayName) { return(XmlPropertySetting.ConvertValueFromString(TypeDescriptor.GetConverter(propertyType), value, propertyDisplayName, propertyType, false)); }
public override void GetSetting() { base.GetSetting(); this.generalAnimationSettings1.GetValues(); this.AnimatedSetting.StartValueIsCurrentValue = (this.checkBoxUseCurrentValue.Checked); if (!this.checkBoxUseCurrentValue.Checked) { this.AnimatedSetting.Value = XmlPropertySetting.DeserializeValue(this.Property, this.tbStartRectangle.Text); } else { this.AnimatedSetting.Value = null; } this.AnimatedSetting.StartValueIsCurrentValue = this.checkBoxUseCurrentValue.Checked; // this.AnimatedSetting.ApplyEasingType = this.comboApplyeasing if (this.AnimatedSetting.AnimationType == RadAnimationType.ByStartEndValues) { this.AnimatedSetting.EndValue = XmlPropertySetting.DeserializeValue(Property, this.tbEndRectangle.Text); } else { this.AnimatedSetting.Step = XmlAnimatedPropertySetting.SerializeStep(this.GetValidatedPadding(tbStepRectangle.Text)); if (!checkBoxAutomaticReverse.Checked) { this.AnimatedSetting.ReverseStep = XmlAnimatedPropertySetting.SerializeStep(this.GetValidatedPadding(tbReversedStepRectangle.Text)); } } }
public static object Deserialize(string fullName, string propertyName, string value) { if (PropertyReader.directConverters.ContainsKey(propertyName)) { return(PropertyReader.directConverters[propertyName](value)); } if (PropertyReader.typeDescriptorConverters.ContainsKey(propertyName)) { return(PropertyReader.typeDescriptorConverters[propertyName].Converter?.ConvertFromString((ITypeDescriptorContext)null, PropertyReader.serializationCulture, value)); } object obj = (object)null; try { RadProperty property = XmlPropertySetting.DeserializePropertySafe(!string.IsNullOrEmpty(fullName) ? fullName : propertyName); if (property != null) { obj = XmlPropertySetting.DeserializeValue(property, value); } } catch { } return(obj); }
public XmlPropertySettingGroup Serialize() { XmlPropertySettingGroup xmlGroup = new XmlPropertySettingGroup(); xmlGroup.BasedOn = this.basedOn; for (int settingIndex = 0; settingIndex < this.PropertySettings.OriginalPropertySettings.Count; settingIndex++) { IPropertySetting setting = this.PropertySettings.OriginalPropertySettings[settingIndex]; //serialize value; XmlPropertySetting xmlSetting = setting.Serialize(); xmlGroup.PropertySettings.Add(xmlSetting); } if (this.Selectors.Count > 0) { for (int selectorIndex = 0; selectorIndex < this.Selectors.Count; selectorIndex++) { IElementSelector selector = this.Selectors[selectorIndex]; xmlGroup.Selectors.Add(selector.Serialize()); } } return(xmlGroup); }
public static object DeserializeValue( PropertyDescriptor prop, string value, string propertyDisplayName, bool throwOnError) { return(XmlPropertySetting.ConvertValueFromString(prop.Converter, value, propertyDisplayName, prop.PropertyType, throwOnError)); }
public RadProperty GetDeserializedProperty() { if (this.tempPoroperty == null) { this.tempPoroperty = XmlPropertySetting.DeserializeProperty(this.Property); } return(this.tempPoroperty); }
protected override XmlPropertySetting Serialize() { XmlPropertySetting xmlPropertySetting = new XmlPropertySetting(); xmlPropertySetting.Property = this.Property.FullName; xmlPropertySetting.Value = this.valueProviderHelper.UnderlayingValue;//XmlPropertySetting.SerializeValue(this.Property, this.Value); return(xmlPropertySetting); }
void AddSetting(TreeNode node, XmlPropertySetting setting) { if (node != null && setting != null) { TreeNode newNode = new TreeNode(setting.ToString(), 5, 5); newNode.Tag = setting; node.Nodes.Add(newNode); } }
public static string SerializeValue(RadProperty property, object value) { if (value == null) { return((string)null); } PropertyDescriptor prop = TypeDescriptor.GetProperties(property.OwnerType).Find(property.Name, true); return(prop == null?XmlPropertySetting.ConvertValueToString(TypeDescriptor.GetConverter(property.PropertyType), value, property.FullName) : XmlPropertySetting.SerializeValue(prop, value, property.FullName)); }
public static object DeserializeValue(RadProperty property, string value, bool throwOnError) { if (value == null) { return((object)null); } PropertyDescriptor prop = TypeDescriptor.GetProperties(property.OwnerType).Find(property.Name, true); return(prop == null?XmlPropertySetting.ConvertValueFromString(TypeDescriptor.GetConverter(property.PropertyType), value, property.FullName, property.PropertyType, throwOnError) : XmlPropertySetting.DeserializeValue(prop, value, property.FullName, throwOnError)); }
private UITypeEditor GetActualEditor(ITypeDescriptorContext context) { if (context == null) { return(this.actualEditor); } XmlPropertySetting instance = (XmlPropertySetting)context.Instance; if (instance.Property == null) { this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } string[] strArray = instance.Property.Split('.'); if (strArray.Length > 1) { string propertyName = strArray[strArray.Length - 1]; string className = string.Join(".", strArray, 0, strArray.Length - 1); RadProperty safe = RadProperty.FindSafe(className, propertyName); this.currProperty = safe; if (safe != null) { TypeConverter converter = TypeDescriptor.GetConverter(safe.PropertyType); this.actualPropertyType = safe.PropertyType; if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string))) { if (!converter.CanConvertFrom(typeof(string))) { int num1 = (int)MessageBox.Show("Converter can't convert from string"); } else if (!converter.CanConvertTo(typeof(string))) { int num2 = (int)MessageBox.Show("Converter can't convert to string"); } else { int num3 = (int)MessageBox.Show("Converter for type not found"); } this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } this.actualConverter = converter; PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(safe.OwnerType).Find(safe.Name, false); this.actualEditor = propertyDescriptor == null ? (UITypeEditor)TypeDescriptor.GetEditor(safe.PropertyType, typeof(UITypeEditor)) : (UITypeEditor)propertyDescriptor.GetEditor(typeof(UITypeEditor)); return(this.actualEditor); } int num = (int)MessageBox.Show("Can't find property " + instance.Property + ". Property " + propertyName + "not registered for RadObject" + className); this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } int num4 = (int)MessageBox.Show("Invalid property name. Property consist of type FullName\".\"PropertyName."); this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); }
private TypeConverter GetUnderlayingConverter(ITypeDescriptorContext context) { if (this.underlayingConverter == null || context != this.currContext) { this.currContext = context; if (context == null) { return(this.underlayingConverter); } XmlPropertySetting instance = (XmlPropertySetting)context.Instance; if (string.IsNullOrEmpty(instance.Property)) { this.underlayingConverter = (TypeConverter)null; return((TypeConverter)null); } string[] strArray = instance.Property.Split('.'); if (strArray.Length <= 1) { throw new Exception("Invalid property name. Property consist of type FullName \".\" and property name."); } string propertyName = strArray[strArray.Length - 1]; string className = string.Join(".", strArray, 0, strArray.Length - 1); RadProperty safe = RadProperty.FindSafe(className, propertyName); if (safe != null) { TypeConverter converter = TypeDescriptor.GetConverter(safe.PropertyType); if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string))) { if (!converter.CanConvertFrom(typeof(string))) { int num1 = (int)MessageBox.Show("Converter can't convert from string"); } else if (!converter.CanConvertTo(typeof(string))) { int num2 = (int)MessageBox.Show("Converter can't convert to string"); } else { int num3 = (int)MessageBox.Show("Converter for type not found"); } } this.hasEditor = (UITypeEditor)TypeDescriptor.GetEditor(safe.PropertyType, typeof(UITypeEditor)) != null; this.underlayingConverter = converter; } else { int num = (int)MessageBox.Show("Can't find property " + instance.Property + ". Property " + propertyName + " not registered for " + className); this.underlayingConverter = (TypeConverter)null; return((TypeConverter)null); } } return(this.underlayingConverter); }
public virtual IPropertySetting Deserialize() { if (string.IsNullOrEmpty(this.Property)) { throw new InvalidOperationException("Property to deserialize is null or empty"); } PropertySetting propertySetting = new PropertySetting() { Property = XmlPropertySetting.DeserializeProperty(this.Property) }; propertySetting.Value = this.GetConvertedValue(propertySetting.Property, this.Value); return((IPropertySetting)propertySetting); }
public override IPropertySetting Deserialize() { AnimatedPropertySetting animatedPropertySetting = new AnimatedPropertySetting(); animatedPropertySetting.Property = XmlPropertySetting.DeserializeProperty(this.Property); if (!this.StartValueIsCurrentValue) { animatedPropertySetting.StartValue = this.GetConvertedValue(animatedPropertySetting.Property, this.Value); } animatedPropertySetting.Interval = this.Interval; animatedPropertySetting.NumFrames = this.NumFrames; animatedPropertySetting.ApplyEasingType = this.ApplyEasingType; animatedPropertySetting.EndValue = this.GetConvertedValue(animatedPropertySetting.Property, this.EndValue); return((IPropertySetting)animatedPropertySetting); }
private void addPropertySettingToolStripMenuItem_Click(object sender, EventArgs e) { XmlPropertySetting setting = null; switch (((ToolStripMenuItem)sender).Name) { case "AnimatedPropertySetting": setting = new XmlAnimatedPropertySetting(); break; case "PropertySetting": setting = new XmlPropertySetting(); break; } if (tvPropertySettingGroups.SelectedNode != null) { AddSetting(tvPropertySettingGroups.SelectedNode, setting); XmlPropertySettingGroup group = (XmlPropertySettingGroup)tvPropertySettingGroups.SelectedNode.Parent.Tag; group.PropertySettings.Add(setting); tvPropertySettingGroups.SelectedNode.Expand(); } }
private static RadProperty DeserializePropertyCore( string property, bool fallback, bool throwOnError) { if (string.IsNullOrEmpty(property)) { return((RadProperty)null); } string[] strArray = property.Split('.'); if (strArray.Length > 1) { string propertyName = strArray[strArray.Length - 1]; string className = string.Join(".", strArray, 0, strArray.Length - 1); System.Type typeByName = RadTypeResolver.Instance.GetTypeByName(className); if ((object)typeByName == null) { if (throwOnError) { throw new InvalidOperationException("Could not look-up type '" + className + "'"); } return((RadProperty)null); } RadProperty property1 = XmlPropertySetting.FindProperty(typeByName, propertyName, fallback); if (property1 != null) { return(property1); } if (!throwOnError) { return((RadProperty)null); } return(XmlPropertySetting.ProcessDuplicateAssemblies(propertyName, className)); } if (throwOnError) { throw new Exception("Invalid property parts"); } return((RadProperty)null); }
private void RectangleAnimationForm_Load(object sender, EventArgs e) { if (AnimatedSetting.Value != null) { this.tbStartRectangle.Text = XmlPropertySetting.SerializeValue(this.Property, AnimatedSetting.Value); this.checkBoxUseCurrentValue.Checked = false; } else { this.checkBoxUseCurrentValue.Checked = true; } if (AnimatedSetting.EndValue != null) { this.tbEndRectangle.Text = XmlPropertySetting.SerializeValue(this.Property, AnimatedSetting.EndValue); } if (AnimatedSetting.Step != null) { //TODO: What if the step is different type? this.tbStepRectangle.Text = AnimatedSetting.Step.Value; } else { this.checkBoxUseCurrentValue.Checked = true; } if (AnimatedSetting.ReverseStep != null) { //TODO: What if the step is different type? this.tbReversedStepRectangle.Text = AnimatedSetting.ReverseStep.Value; } if (AnimatedSetting.ReverseStep == null) { this.checkBoxAutomaticReverse.Checked = true; } }
private void SizeAnimationForm_Load(object sender, EventArgs e) { Decimal minValue = Decimal.MinValue; Decimal maxValue = Decimal.MaxValue; int decimalPlaces = 0; if (Property.PropertyType == typeof(float)) { decimalPlaces = 2; } else if (Property.PropertyType == typeof(double)) { decimalPlaces = 3; } this.numericUpDownStart1.Minimum = minValue; this.numericUpDownStart1.Maximum = maxValue; this.numericUpDownStart1.DecimalPlaces = decimalPlaces; this.numericUpDownEnd1.Minimum = minValue; this.numericUpDownEnd1.Maximum = maxValue; this.numericUpDownEnd1.DecimalPlaces = decimalPlaces; this.numericUpDownStep.Minimum = minValue; this.numericUpDownStep.Maximum = maxValue; this.numericUpDownStep.DecimalPlaces = decimalPlaces; this.numericUpDownReverseStep.Minimum = minValue; this.numericUpDownReverseStep.Maximum = maxValue; this.numericUpDownReverseStep.DecimalPlaces = decimalPlaces; if (AnimatedSetting.Value != null) { if (Property.PropertyType == typeof(Size)) { Size size = (Size)AnimatedSetting.Value; this.numericUpDownStart1.Value = Convert.ToDecimal(size.Width); this.numericUpDownEnd1.Value = Convert.ToDecimal(size.Height); } if (this.numericUpDownStart1.Value == 0) { this.checkBoxUseCurrentValue.Checked = true; } } if (AnimatedSetting.EndValue != null) { Size size = (Size)AnimatedSetting.EndValue; this.numericUpDownStart2.Value = Convert.ToDecimal(size.Width); this.numericUpDownEnd2.Value = Convert.ToDecimal(size.Height); } if (AnimatedSetting.Step != null) { this.numericUpDownStep.Value = Convert.ToDecimal(XmlPropertySetting.DeserializeValue(Property, AnimatedSetting.Step.Value)); } if (AnimatedSetting.ReverseStep != null) { this.numericUpDownReverseStep.Value = Convert.ToDecimal(XmlPropertySetting.DeserializeValue(Property, AnimatedSetting.ReverseStep.Value)); } else { this.checkBoxAutomaticReverse.Checked = true; this.numericUpDownReverseStep.Enabled = false; } }
private TypeConverter GetUnderlayingConverter(ITypeDescriptorContext context) { if (underlayingConverter == null || context != currContext) { currContext = context; if (context == null) { return(underlayingConverter); } XmlPropertySetting setting = (XmlPropertySetting)context.Instance; //Find property //setting.Property //Find type converter //Convert value //Find corresponding UITypeEditor //Edit converted value if (string.IsNullOrEmpty(setting.Property)) { this.underlayingConverter = null; return(null); } string[] propertyParts = setting.Property.Split('.'); string propertyName; string className; if (propertyParts.Length > 1) { propertyName = propertyParts[propertyParts.Length - 1]; className = string.Join(".", propertyParts, 0, propertyParts.Length - 1); } else { throw new Exception("Invalid property name. Property consist of type FullName \".\" and property name."); } RadProperty prop = RadProperty.FindSafe(className, propertyName); //this.actualProperty = prop; TypeConverter converter; if (prop != null) { converter = TypeDescriptor.GetConverter(prop.PropertyType); } else { MessageBox.Show("Can't find property " + setting.Property + ". Property " + propertyName + " not registered for " + className); this.underlayingConverter = null; return(null); } if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string))) { if (!converter.CanConvertFrom(typeof(string))) { MessageBox.Show("Converter can't convert from string"); } else if (!converter.CanConvertTo(typeof(string))) { MessageBox.Show("Converter can't convert to string"); } else { MessageBox.Show("Converter for type not found"); } } UITypeEditor editor = (UITypeEditor)TypeDescriptor.GetEditor(prop.PropertyType, typeof(UITypeEditor)); hasEditor = editor != null; underlayingConverter = converter; } return(underlayingConverter); }
private UITypeEditor GetActualEditor(ITypeDescriptorContext context) { if (context == null) { return(actualEditor); } XmlPropertySetting setting = (XmlPropertySetting)context.Instance; //Find property //setting.Property //Find type converter //Convert value //Find corresponding UITypeEditor //Edit converted value if (setting.Property == null) { this.actualEditor = null; return(null); } string[] propertyParts = setting.Property.Split('.'); string propertyName; string className; if (propertyParts.Length > 1) { propertyName = propertyParts[propertyParts.Length - 1]; className = string.Join(".", propertyParts, 0, propertyParts.Length - 1); } else { MessageBox.Show("Invalid property name. Property consist of type FullName\".\"PropertyName."); this.actualEditor = null; return(null); } RadProperty prop = RadProperty.FindSafe(className, propertyName); this.currProperty = prop; TypeConverter converter; if (prop != null) { converter = TypeDescriptor.GetConverter(prop.PropertyType); } else { MessageBox.Show("Can't find property " + setting.Property + ". Property " + propertyName + "not registered for RadObject" + className); this.actualEditor = null; return(null); } this.actualPropertyType = prop.PropertyType; if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string))) { if (!converter.CanConvertFrom(typeof(string))) { MessageBox.Show("Converter can't convert from string"); } else if (!converter.CanConvertTo(typeof(string))) { MessageBox.Show("Converter can't convert to string"); } else { MessageBox.Show("Converter for type not found"); } this.actualEditor = null; return(null); } this.actualConverter = converter; PropertyDescriptor actualProperty = TypeDescriptor.GetProperties(prop.OwnerType).Find(prop.Name, false); if (actualProperty != null) { this.actualEditor = (UITypeEditor)actualProperty.GetEditor(typeof(UITypeEditor)); } else { this.actualEditor = (UITypeEditor)TypeDescriptor.GetEditor(prop.PropertyType, typeof(UITypeEditor)); } return(actualEditor); }
/// <summary> /// This method supports TPF infrastructure and is intended for internal use only. /// </summary> /// <param name="applyUnconditional"></param> /// <param name="groups"></param> /// <returns></returns> public StyleSheet GetStyleSheet(XmlSelectorBase applyUnconditional, XmlPropertySettingGroup[] groups) { StyleSheet res = new StyleSheet(); SelectorBase applySelector = null; if (this.PropertySettingGroups == null) { return(res); } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { XmlPropertySettingGroup xmlGroup = this.PropertySettingGroups[i]; if (xmlGroup.Selectors != null) { for (int selectorIndex = 0; selectorIndex < xmlGroup.Selectors.Count; selectorIndex++) { XmlElementSelector xmlSelector = xmlGroup.Selectors[selectorIndex]; if (xmlSelector == applyUnconditional) { applySelector = (SelectorBase)xmlSelector.Deserialize(); break; } } } } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { XmlPropertySettingGroup xmlGroup = this.PropertySettingGroups[i]; PropertySettingGroup group = new PropertySettingGroup(); if (xmlGroup.PropertySettings == null || xmlGroup.Selectors == null) { continue; } bool disable = false; if (applyUnconditional != null) { for (int groupIndex = 0; groupIndex < groups.Length; groupIndex++) { XmlPropertySettingGroup g = groups[groupIndex]; if (g == xmlGroup) { disable = true; break; } } } for (int settingIndex = 0; settingIndex < xmlGroup.PropertySettings.Count; settingIndex++) { XmlPropertySetting xmlPropertySetting = xmlGroup.PropertySettings[settingIndex]; IPropertySetting setting = xmlPropertySetting.Deserialize(); group.PropertySettings.Add(setting); } //IElementSelector activeSelector = null; for (int selectorIndex = 0; selectorIndex < xmlGroup.Selectors.Count; selectorIndex++) { XmlElementSelector xmlSelector = xmlGroup.Selectors[selectorIndex]; IElementSelector selector = null; selector = xmlSelector.Deserialize(); if (xmlSelector == applyUnconditional) { applySelector.IsActiveSelectorInStyleBuilder = true; selector = applySelector; //continue; } else if (disable) { ((SelectorBase)selector).DisableStyle = true; //((SelectorBase)selector).ExcludeSelector = applySelector; } group.Selectors.Add(selector); } //if (activeSelector != null) // group.Selectors.Insert(0, activeSelector); res.PropertySettingGroups.Add(group); } return(res); }
public static RadProperty DeserializePropertySafe(string property) { return(XmlPropertySetting.DeserializePropertyCore(property, true, false)); }
public static object DeserializeValue(RadProperty property, string value) { return(XmlPropertySetting.DeserializeValue(property, value, false)); }