public override object Clone()
        {
            SetterClass obj = new SetterClass(_property);

            CopyFromThis(obj);
            return(obj);
        }
Example #2
0
        /// <summary>
        /// "value" is used inside a ParameterValue, let ReadXml to find out SetterClass
        /// </summary>
        /// <param name="value"></param>
        public PropertyValueClass(ParameterValue value)
            : base((IMethod)null)
        {
            SetterClass sc = value.OwnerMethod as SetterClass;

            if (sc != null)
            {
                init(sc);
            }
            else
            {
            }
        }
Example #3
0
 private void init(SetterClass setter)
 {
     if (setter == null)
     {
         throw new DesignerException("Setter not initialized for property value");
     }
     if (setter.Property == null)
     {
         throw new DesignerException("Property for Setter not initialized");
     }
     SetDataType(setter.Property.PropertyType);
     Method      = setter;
     Name        = "value";
     Description = "The value to be assigned to this property. This is the same value parameter for a SetProperty action.";
 }
Example #4
0
        public override object Clone()
        {
            SetterPointer o = Owner as SetterPointer;

            if (o != null)
            {
                return(new PropertyValueClass(o));
            }
            SetterClass sc = Owner as SetterClass;

            if (sc != null)
            {
                return(new PropertyValueClass(sc));
            }
            return(this);
        }
Example #5
0
 /// <summary>
 /// for deserialization, let the ReadXml function to find the SetterClass
 /// </summary>
 /// <param name="componentIcon"></param>
 public PropertyValueClass(ComponentIconParameter componentIcon)
     : base((IMethod)null)
 {
     if (componentIcon != null)
     {
         SetterClass sc = componentIcon.Method as SetterClass;
         if (sc == null)
         {
             throw new DesignerException("SetterClass is null for PropertyValueClass");
         }
         init(sc);
     }
     else
     {
         throw new DesignerException("ComponentIconParameter is null for PropertyValueClass");
     }
 }
Example #6
0
        protected override object OnEditValue(ITypeDescriptorContext context, IServiceProvider provider, System.Windows.Forms.Design.IWindowsFormsEditorService service, object value)
        {
            IWithProject mc = context.Instance as IWithProject;

            if (mc != null)
            {
                if (mc.Project == null)
                {
                    MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                }
                else
                {
                    SetterClass          val      = value as SetterClass;
                    System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
                    rc.X = curPoint.X;
                    rc.Y = curPoint.Y;
                    DlgMethod dlg = val.CreateMethodEditor(rc);
                    try
                    {
                        dlg.LoadMethod(val, EnumParameterEditType.ReadOnly);
                        dlg.SetNameReadOnly();
                        if (service.ShowDialog((Form)dlg) == DialogResult.OK)
                        {
                            value = val;
                            ILimnorDesignerLoader l = LimnorProject.ActiveDesignerLoader as ILimnorDesignerLoader;
                            if (l != null)
                            {
                                DesignUtil.SaveCustomProperty(LimnorProject.ActiveDesignerLoader.Node, l.Writer, val.Property);
                                LimnorProject.ActiveDesignerLoader.NotifyChanges();
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        MathNode.Log(TraceLogClass.GetForm(provider), err);
                    }
                    finally
                    {
                        val.ExitEditor();
                    }
                }
            }
            return(value);
        }
Example #7
0
 public override CodeExpression GetReferenceCode(IMethodCompile method, CodeStatementCollection statements, bool forValue)
 {
     if (Property != null)
     {
         bool        inside = false;
         SetterClass sc     = method as SetterClass;
         if (sc != null)
         {
             inside = sc.Property.IsSameObjectRef(Property);
         }
         else
         {
             GetterClass gc = method as GetterClass;
             if (gc != null)
             {
                 inside = gc.Property.IsSameObjectRef(Property);
             }
         }
         if (inside)
         {
             CodeExpression ownerCode;
             if (Property.IsStatic)
             {
                 MathNodePropertyField.CheckDeclareField(Property.IsStatic, Property.FieldMemberName, Property.PropertyType, method.TypeDeclaration, Property.DefaultValue);
                 ownerCode = new CodeTypeReferenceExpression(Property.Holder.TypeString);
                 return(new CodeFieldReferenceExpression(ownerCode, Property.FieldMemberName));
             }
             else
             {
                 ownerCode = new CodeBaseReferenceExpression();
                 return(new CodeFieldReferenceExpression(ownerCode, Property.Name));
             }
         }
         else
         {
             Property.SetHolder(Holder);
             return(Property.GetReferenceCode(method, statements, forValue));
         }
     }
     return(null);
 }
Example #8
0
 public PropertyValueClass(SetterClass setter)
     : base(setter)
 {
     init(setter);
 }
Example #9
0
 public virtual CodeExpression GetReferenceCode(IMethodCompile method, CodeStatementCollection statements, bool forValue)
 {
     if (Property != null)
     {
         bool isWeb = false;
         if (this.RootPointer != null)
         {
             isWeb = this.RootPointer.IsWebObject;
         }
         else if (this.Property.RootPointer != null)
         {
             isWeb = this.Property.RootPointer.IsWebObject;
         }
         if (isWeb)
         {
             if (forValue && Property.RunAt == EnumWebRunAt.Client)
             {
                 if (this.ObjectType.IsArray)
                 {
                     CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(
                         new CodeVariableReferenceExpression("clientRequest"), "GetStringArrayValue", new CodePrimitiveExpression(DataPassingCodeName));
                     return(cmie);
                 }
                 else
                 {
                     CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(
                         new CodeVariableReferenceExpression("clientRequest"), "GetStringValue", new CodePrimitiveExpression(DataPassingCodeName));
                     return(cmie);
                 }
             }
         }
         bool        inside = false;
         SetterClass sc     = method as SetterClass;
         if (sc != null)
         {
             inside = sc.Property.IsSameObjectRef(Property);
         }
         else
         {
             GetterClass gc = method as GetterClass;
             if (gc != null)
             {
                 inside = gc.Property.IsSameObjectRef(Property);
             }
         }
         if (inside)
         {
             CodeExpression ownerCode;
             MathNodePropertyField.CheckDeclareField(Property.IsStatic, Property.FieldMemberName, Property.PropertyType, method.TypeDeclaration, Property.DefaultValue);
             if (Property.IsStatic)
             {
                 ownerCode = new CodeTypeReferenceExpression(Property.Holder.TypeString);
             }
             else
             {
                 ownerCode = new CodeThisReferenceExpression();
             }
             return(new CodeFieldReferenceExpression(ownerCode, Property.FieldMemberName));
         }
         else
         {
             Property.SetHolder(_holder);
             return(Property.GetReferenceCode(method, statements, forValue));
         }
     }
     return(null);
 }