コード例 #1
0
        protected void OnValueChanged(DesignerPropertyInfo property)
        {
            if (!_valueWasAssigned)
            {
                return;
            }

            Nodes.Node node = _object as Nodes.Node;
            if (node != null)
            {
                node.OnPropertyValueChanged(true);

                if (ValueWasChanged != null)
                {
                    ValueWasChanged(property);
                }

                return;
            }

            Attachments.Attachment attach = _object as Attachments.Attachment;
            if (attach != null)
            {
                attach.OnPropertyValueChanged(true);

                if (ValueWasChanged != null)
                {
                    ValueWasChanged(property);
                }

                return;
            }
        }
コード例 #2
0
		public override void SetProperty(DesignerPropertyInfo property, object obj)
		{
			base.SetProperty(property, obj);

			DesignerFloat floatAtt= property.Attribute as DesignerFloat;
			if(floatAtt !=null)
			{
				numericUpDown.DecimalPlaces= floatAtt.Precision;
				numericUpDown.Minimum= (decimal)floatAtt.Min;
				numericUpDown.Maximum= (decimal)floatAtt.Max;
				numericUpDown.Increment= (decimal)floatAtt.Steps;

				float val= (float)property.Property.GetValue(obj, null);
				numericUpDown.Value= (decimal)val;

				unitLabel.Text= floatAtt.Units;
			}

			DesignerInteger intAtt= property.Attribute as DesignerInteger;
			if(intAtt !=null)
			{
				numericUpDown.DecimalPlaces= 0;
				numericUpDown.Minimum= (decimal)intAtt.Min;
				numericUpDown.Maximum= (decimal)intAtt.Max;
				numericUpDown.Increment= (decimal)intAtt.Steps;

				int val= (int)property.Property.GetValue(obj, null);
				numericUpDown.Value= (decimal)val;

				unitLabel.Text= intAtt.Units;
			}

			DesignerFlexibleFloat flexFloatAtt= property.Attribute as DesignerFlexibleFloat;
			if(flexFloatAtt !=null)
			{
				numericUpDown.DecimalPlaces= flexFloatAtt.Precision;
				numericUpDown.Minimum= (decimal)flexFloatAtt.Min;
				numericUpDown.Maximum= (decimal)flexFloatAtt.Max;
				numericUpDown.Increment= (decimal)flexFloatAtt.Steps;

				FlexiblePropertyFloat flexProp= (FlexiblePropertyFloat)property.Property.GetValue(obj, null);
				numericUpDown.Value= (decimal)flexProp.Min;

				unitLabel.Text= flexFloatAtt.Units;
			}

			DesignerFlexibleInteger flexIntegerAtt= property.Attribute as DesignerFlexibleInteger;
			if(flexIntegerAtt !=null)
			{
				numericUpDown.DecimalPlaces= 0;
				numericUpDown.Minimum= (decimal)flexIntegerAtt.Min;
				numericUpDown.Maximum= (decimal)flexIntegerAtt.Max;
				numericUpDown.Increment= (decimal)flexIntegerAtt.Steps;

				FlexiblePropertyInteger flexProp= (FlexiblePropertyInteger)property.Property.GetValue(obj, null);
				numericUpDown.Value= (decimal)flexProp.Min;

				unitLabel.Text= flexIntegerAtt.Units;
			}
		}
コード例 #3
0
		public override void SetProperty(DesignerPropertyInfo property, object obj)
		{
			base.SetProperty(property, obj);

			CanUseDefinition canUseDefinition= (CanUseDefinition)property.Property.GetValue(obj, null);

			if(AIType.Current !=null)
			{
				Type type= canUseDefinition.PropertyType;

				foreach(Definition definition in AIType.Current.Definitions)
				{
					PropertyInfo[] properties= definition.Object.GetType().GetProperties(BindingFlags.Instance|BindingFlags.Public);

					foreach(PropertyInfo prop in properties)
					{
						if(!prop.CanRead || prop.PropertyType !=type)
							continue;

						comboBox.Items.Add(definition.Name +'.'+ prop.Name);
					}
				}
			}

			if(canUseDefinition.DefinitionName !=string.Empty && canUseDefinition.DefinitionMember !=string.Empty)
			{
				string str= canUseDefinition.DefinitionName +'.'+ canUseDefinition.DefinitionMember;
				if(!comboBox.Items.Contains(str))
					comboBox.Items.Insert(0, str);

				comboBox.Text= str;
			}
		}
コード例 #4
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            object[] excludedElements = null;
            string   enumName         = string.Empty;
            Type     enumtype         = null;

            DesignerEnum enumAtt = property.Attribute as DesignerEnum;

            if (enumAtt != null)
            {
                excludedElements = enumAtt.ExcludedElements;
                enumName         = Enum.GetName(property.Property.PropertyType, property.Property.GetValue(obj, null));
                enumtype         = property.Property.PropertyType;
            }

            DesignerFlexibleEnum flexEnumAtt = property.Attribute as DesignerFlexibleEnum;

            if (flexEnumAtt != null)
            {
                excludedElements = flexEnumAtt.ExcludedElements;

                FlexiblePropertyEnum flexProp = (FlexiblePropertyEnum)property.Property.GetValue(obj, null);
                enumName = Enum.GetName(flexProp.EnumType, flexProp.Value);
                enumtype = flexProp.EnumType;
            }

            if (enumtype == null)
            {
                throw new Exception(string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name));
            }

            Array list = Enum.GetValues(enumtype);

            foreach (object enumVal in list)
            {
                bool excluded = false;

                if (excludedElements != null)
                {
                    for (int i = 0; i < excludedElements.Length; ++i)
                    {
                        if (excludedElements[i].Equals(enumVal))
                        {
                            excluded = true;
                            break;
                        }
                    }
                }

                if (!excluded)
                {
                    comboBox.Items.Add(Enum.GetName(enumtype, enumVal));
                    _values.Add(enumVal);
                }
            }

            comboBox.Text = enumName;
        }
コード例 #5
0
        /// <summary>
        /// This method is used to sort properties by their display order.
        /// </summary>
        public static int SortByDisplayOrder(DesignerPropertyInfo a, DesignerPropertyInfo b)
        {
            if (a.Attribute.DisplayOrder == b.Attribute.DisplayOrder)
            {
                return(0);
            }

            return(a.Attribute.DisplayOrder < b.Attribute.DisplayOrder ? -1 : 1);
        }
コード例 #6
0
		public override void SetProperty(DesignerPropertyInfo property, object obj)
		{
			base.SetProperty(property, obj);

			object[] excludedElements= null;
			string enumName= string.Empty;
			Type enumtype= null;

			DesignerEnum enumAtt= property.Attribute as DesignerEnum;
			if(enumAtt !=null)
			{
				excludedElements= enumAtt.ExcludedElements;
				enumName= Enum.GetName(property.Property.PropertyType, property.Property.GetValue(obj, null));
				enumtype= property.Property.PropertyType;
			}

			DesignerFlexibleEnum flexEnumAtt= property.Attribute as DesignerFlexibleEnum;
			if(flexEnumAtt !=null)
			{
				excludedElements= flexEnumAtt.ExcludedElements;

				FlexiblePropertyEnum flexProp= (FlexiblePropertyEnum)property.Property.GetValue(obj, null);
				enumName= Enum.GetName(flexProp.EnumType, flexProp.Value);
				enumtype= flexProp.EnumType;
			}

			if(enumtype ==null)
				throw new Exception( string.Format(Resources.ExceptionDesignerAttributeExpectedEnum, property.Property.Name) );

			Array list= Enum.GetValues(enumtype);
			foreach(object enumVal in list)
			{
				bool excluded= false;

				if(excludedElements !=null)
				{
					for(int i= 0; i <excludedElements.Length; ++i)
					{
						if(excludedElements[i].Equals(enumVal))
						{
							excluded= true;
							break;
						}
					}
				}

				if(!excluded)
				{
					comboBox.Items.Add( Enum.GetName(enumtype, enumVal) );
					_values.Add(enumVal);
				}
			}

			comboBox.Text= enumName;
		}
コード例 #7
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            DesignerBoolean boolAtt = property.Attribute as DesignerBoolean;

            if (boolAtt != null)
            {
                checkBox.Checked = (bool)property.Property.GetValue(obj, null);
            }
        }
コード例 #8
0
		public override void SetProperty(DesignerPropertyInfo property, object obj)
		{
			base.SetProperty(property, obj);

			DesignerBoolean boolAtt= property.Attribute as DesignerBoolean;
			if(boolAtt !=null)
			{
				checkBox.Checked= (bool)property.Property.GetValue(obj, null);
			}

			DesignerFlexibleBoolean flexBooleanAtt= property.Attribute as DesignerFlexibleBoolean;
			if(flexBooleanAtt !=null)
			{
				FlexiblePropertyBoolean flexProp= (FlexiblePropertyBoolean)property.Property.GetValue(obj, null);
				checkBox.Checked= flexProp.Value;
			}
		}
コード例 #9
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            DesignerBoolean boolAtt = property.Attribute as DesignerBoolean;

            if (boolAtt != null)
            {
                checkBox.Checked = (bool)property.Property.GetValue(obj, null);
            }

            DesignerFlexibleBoolean flexBooleanAtt = property.Attribute as DesignerFlexibleBoolean;

            if (flexBooleanAtt != null)
            {
                FlexiblePropertyBoolean flexProp = (FlexiblePropertyBoolean)property.Property.GetValue(obj, null);
                checkBox.Checked = flexProp.Value;
            }
        }
コード例 #10
0
        /// <summary>
        /// Returns the property this one is linked to.
        /// </summary>
        /// <param name="linkBroken">Is true if a link was found but it does not work.</param>
        /// <returns>The info of the property this is linked to.</returns>
        public DesignerPropertyInfo GetLinkedProperty(object obj, out bool linkBroken)
        {
            linkBroken = false;

            if (string.IsNullOrEmpty(_linkedToProperty))
            {
                return(new DesignerPropertyInfo());
            }

            DesignerPropertyInfo dpi = DesignerProperty.GetDesignerProperty(obj.GetType(), _linkedToProperty);

            // if we are linked to a DesignerNodeProperty we get the information of its assigned property
            DesignerNodeProperty dnp = dpi.Attribute as DesignerNodeProperty;

            if (dnp == null)
            {
                return(dpi);
            }

            Attachments.Attachment attach = (Attachments.Attachment)obj;

            // check if a valid property is associated
            object objvalue = dpi.Property.GetValue(obj, null);

            string value = dnp.GetDisplayValue(objvalue);

            if (string.IsNullOrEmpty(value) || value == Resources.DesignerNodePropertyNone)
            {
                linkBroken = true;

                return(new DesignerPropertyInfo());
            }

            // return the property we are pointing at
            return(DesignerProperty.GetDesignerProperty(attach.Node.GetType(), value));
        }
コード例 #11
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            DesignerFloat floatAtt = property.Attribute as DesignerFloat;

            if (floatAtt != null)
            {
                numericUpDown.DecimalPlaces = floatAtt.Precision;
                numericUpDown.Minimum       = (decimal)floatAtt.Min;
                numericUpDown.Maximum       = (decimal)floatAtt.Max;
                numericUpDown.Increment     = (decimal)floatAtt.Steps;

                float val = (float)property.Property.GetValue(obj, null);
                numericUpDown.Value = (decimal)val;

                unitLabel.Text = floatAtt.Units;
            }

            DesignerInteger intAtt = property.Attribute as DesignerInteger;

            if (intAtt != null)
            {
                numericUpDown.DecimalPlaces = 0;
                numericUpDown.Minimum       = (decimal)intAtt.Min;
                numericUpDown.Maximum       = (decimal)intAtt.Max;
                numericUpDown.Increment     = (decimal)intAtt.Steps;

                int val = (int)property.Property.GetValue(obj, null);
                numericUpDown.Value = (decimal)val;

                unitLabel.Text = intAtt.Units;
            }

            DesignerFlexibleFloat flexFloatAtt = property.Attribute as DesignerFlexibleFloat;

            if (flexFloatAtt != null)
            {
                numericUpDown.DecimalPlaces = flexFloatAtt.Precision;
                numericUpDown.Minimum       = (decimal)flexFloatAtt.Min;
                numericUpDown.Maximum       = (decimal)flexFloatAtt.Max;
                numericUpDown.Increment     = (decimal)flexFloatAtt.Steps;

                FlexiblePropertyFloat flexProp = (FlexiblePropertyFloat)property.Property.GetValue(obj, null);
                numericUpDown.Value = (decimal)flexProp.Min;

                unitLabel.Text = flexFloatAtt.Units;
            }

            DesignerFlexibleInteger flexIntegerAtt = property.Attribute as DesignerFlexibleInteger;

            if (flexIntegerAtt != null)
            {
                numericUpDown.DecimalPlaces = 0;
                numericUpDown.Minimum       = (decimal)flexIntegerAtt.Min;
                numericUpDown.Maximum       = (decimal)flexIntegerAtt.Max;
                numericUpDown.Increment     = (decimal)flexIntegerAtt.Steps;

                FlexiblePropertyInteger flexProp = (FlexiblePropertyInteger)property.Property.GetValue(obj, null);
                numericUpDown.Value = (decimal)flexProp.Min;

                unitLabel.Text = flexIntegerAtt.Units;
            }
        }
コード例 #12
0
ファイル: Node.cs プロジェクト: drzo/opensim4opencog
		/// <summary>
		/// Is called after a property of a node was initialised, allowing further processing.
		/// </summary>
		/// <param name="property">The property which was initialised.</param>
		public virtual void PostPropertyInit(DesignerPropertyInfo property)
		{
		}
コード例 #13
0
		/// <summary>
		/// Initialises a property on a given event.
		/// </summary>
		/// <param name="xml">The XML element containing the attribute we want to get.</param>
		/// <param name="node">The event whose property we want to set.</param>
		/// <param name="property">The property on the event we want to set.</param>
		protected void InitProperty(XmlNode xml, Events.Event evnt, DesignerPropertyInfo property)
		{
			string value;
			if(GetAttribute(xml, property.Property.Name, out value))
				property.SetValueFromString(evnt, value);
		}
コード例 #14
0
		/// <summary>
		/// This method is used to sort properties by their display order.
		/// </summary>
		public static int SortByDisplayOrder(DesignerPropertyInfo a, DesignerPropertyInfo b)
		{
			if(a.Attribute.DisplayOrder ==b.Attribute.DisplayOrder)
				return 0;

			return a.Attribute.DisplayOrder <b.Attribute.DisplayOrder ? -1 : 1;
		}
コード例 #15
0
 /// <summary>
 /// This method is used to sort properties by their name.
 /// </summary>
 public static int SortByName(DesignerPropertyInfo a, DesignerPropertyInfo b)
 {
     return(a.Property.Name.CompareTo(b.Property.Name));
 }
コード例 #16
0
		public override void SetProperty(DesignerPropertyInfo property, object obj)
		{
			base.SetProperty(property, obj);

			textBox.Text= (string)property.Property.GetValue(obj, null);
		}
コード例 #17
0
ファイル: DesignerStringEditor.cs プロジェクト: yh821/Zombie
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            textBox.Text = (string)property.Property.GetValue(obj, null);
        }
コード例 #18
0
ファイル: DesignerNumberEditor.cs プロジェクト: yh821/Zombie
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            // check if there is an override for this paroperty
            Nodes.Node node = _object as Nodes.Node;
            if (node != null && node.HasOverrride(property.Property.Name))
            {
                numericUpDown.Enabled = false;

                return;
            }

            DesignerPropertyInfo restrictions = property;

            bool linkBroken;
            DesignerPropertyInfo linkedProperty = property.Attribute.GetLinkedProperty(obj, out linkBroken);

            // control cannot be used with a broken link
            if (linkBroken)
            {
                numericUpDown.Enabled = false;

                return;
            }

            // if we have a linked property this property will define the restrictions
            if (linkedProperty.Property != null)
            {
                restrictions = linkedProperty;
            }

            // extract resrictions for float property
            DesignerFloat restFloatAtt = restrictions.Attribute as DesignerFloat;

            if (restFloatAtt != null)
            {
                numericUpDown.DecimalPlaces = restFloatAtt.Precision;
                numericUpDown.Minimum       = (decimal)restFloatAtt.Min;
                numericUpDown.Maximum       = (decimal)restFloatAtt.Max;
                numericUpDown.Increment     = (decimal)restFloatAtt.Steps;

                unitLabel.Text = restFloatAtt.Units;
            }

            // extract restrictions for int property
            DesignerInteger restIntAtt = restrictions.Attribute as DesignerInteger;

            if (restIntAtt != null)
            {
                numericUpDown.DecimalPlaces = 0;
                numericUpDown.Minimum       = (decimal)restIntAtt.Min;
                numericUpDown.Maximum       = (decimal)restIntAtt.Max;
                numericUpDown.Increment     = (decimal)restIntAtt.Steps;

                unitLabel.Text = restIntAtt.Units;
            }

            // extract the value
            decimal value = 0;

            DesignerFloat floatAtt = property.Attribute as DesignerFloat;

            if (floatAtt != null)
            {
                float val = (float)property.Property.GetValue(obj, null);

                value = (decimal)val;
            }

            DesignerInteger intAtt = property.Attribute as DesignerInteger;

            if (intAtt != null)
            {
                int val = (int)property.Property.GetValue(obj, null);

                value = (decimal)val;
            }

            // assign value within limits
            numericUpDown.Value = Math.Max(numericUpDown.Minimum, Math.Min(numericUpDown.Maximum, value));
        }
コード例 #19
0
        public override void SetProperty(DesignerPropertyInfo property, object obj)
        {
            base.SetProperty(property, obj);

            Nodes.Node node = null;
            if (obj is Nodes.Node)
            {
                node = (Nodes.Node)obj;
            }
            else if (obj is Attachments.Attachment)
            {
                node = ((Attachments.Attachment)obj).Node;
            }
            else
            {
                throw new Exception(string.Format(Resources.ExceptionDesignerAttributeCouldNotRetrieveNode, obj));
            }

            string[] excludedProperties = node.GetNodePropertyExcludedProperties();

            DesignerNodeProperty attribute = (DesignerNodeProperty)property.Attribute;

            comboBox.Items.Add(Resources.DesignerNodePropertyNone);

            IList <DesignerPropertyInfo> properties = node.GetDesignerProperties();

            foreach (DesignerPropertyInfo dpi in properties)
            {
                bool supported = false;

                // check if the property is allowed
                foreach (Type supportedType in attribute.SupportedTypes)
                {
                    if (dpi.Property.PropertyType == supportedType)
                    {
                        supported = true;

                        break;
                    }
                }

                // skip this property if it is not supported
                if (!supported)
                {
                    continue;
                }

                // check if the node denies using this property
                foreach (string excludedProperty in excludedProperties)
                {
                    if (dpi.Property.Name == excludedProperty)
                    {
                        supported = false;

                        break;
                    }
                }

                // skip this property if it is not supported
                if (!supported)
                {
                    continue;
                }

                // add the property to the list
                comboBox.Items.Add(dpi.Property.Name);
            }

            comboBox.Text = (string)property.Property.GetValue(obj, null);

            if (comboBox.Text.Length < 1)
            {
                comboBox.SelectedIndex = 0;
            }
        }
コード例 #20
0
		/// <summary>
		/// This method is used to sort properties by their name.
		/// </summary>
		public static int SortByName(DesignerPropertyInfo a, DesignerPropertyInfo b)
		{
			return a.Property.Name.CompareTo( b.Property.Name );
		}