예제 #1
0
        public SetterPointer CreateSetterMethodPointer(IAction act)
        {
            SetterPointer mp = new SetterPointer(act);

            mp.SetProperty = this;
            return(mp);
        }
        public override TreeNodeObject FindObjectNode(IObjectIdentity pointer)
        {
            SetterPointer sp = pointer as SetterPointer;

            if (sp != null)
            {
                LoadNextLevel();
                for (int i = 0; i < this.Nodes.Count; i++)
                {
                    TreeNodeObject ret = this.Nodes[i] as TreeNodeObject;
                    if (ret != null)
                    {
                        if (sp.SetProperty.IsSameObjectRef(ret.OwnerPointer))
                        {
                            return(ret);
                        }
                    }
                }
            }
            TreeNodeObject node = base.FindObjectNode(pointer);

            if (node != null)
            {
                return(node);
            }
            return(null);
        }
예제 #3
0
 public override bool CanActionBeLinked(TaskID act)
 {
     if (act.Action != null)
     {
         ClassPointer cpr = this.RootPointer.GetExternalExecuterClass(act.Action);
         if (cpr != null)
         {
             return(false);
         }
         DataTypePointer dtp = act.Action.ActionMethod.Owner as DataTypePointer;
         if (dtp != null)
         {
             return(false);
         }
         SetterPointer sp = act.Action.ActionMethod as SetterPointer;
         if (sp != null)
         {
             CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
             if (cpp != null)
             {
                 return(cpp.MemberId == this.PropertyId);
             }
         }
     }
     return(false);
 }
예제 #4
0
        public override bool CanActionBeLinked(TaskID act)
        {
            if (act.Action == null)
            {
                act.LoadActionInstance(this.RootPointer);
            }
            ActionAttachEvent aae = act.Action as ActionAttachEvent;

            if (aae != null)
            {
                return(aae.ExecuterMemberId == ActionExecuterId);
            }
            if (act.Action != null && act.Action.ActionMethod != null)
            {
                ClassPointer cpr = this.RootPointer.GetExternalExecuterClass(act.Action);
                if (cpr != null)
                {
                    return(false);
                }
                DataTypePointer dtp = act.Action.ActionMethod.Owner as DataTypePointer;
                if (dtp != null)
                {
                    return(false);
                }
                CustomMethodPointer cp = act.Action.ActionMethod as CustomMethodPointer;
                if (cp != null)
                {
                    if (cp.ClassId != act.ClassId)
                    {
                        if (act.Action.ExecuterMemberId == ActionExecuterId)
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    SetterPointer sp = act.Action.ActionMethod as SetterPointer;
                    if (sp != null)
                    {
                        CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                        if (cpp == null || cpp.ClassId != act.ClassId)
                        {
                            if (act.Action.ExecuterMemberId == ActionExecuterId)
                            {
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        if (act.Action.ExecuterMemberId == ActionExecuterId)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
예제 #5
0
        public override bool IsActionExecuter(IAction act, ClassPointer root)
        {
            SetterPointer sp = act.ActionMethod as SetterPointer;

            if (sp != null)
            {
                CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                if (cpp != null)
                {
                    return(cpp.MemberId == this.PropertyId);
                }
            }
            return(false);
        }
예제 #6
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);
        }
예제 #7
0
        public override object Clone()
        {
            SetterPointer o = Owner as SetterPointer;

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

            if (sc != null)
            {
                return(new ParameterClassBaseProperty(sc));
            }
            GetterClass gc = Owner as GetterClass;

            if (gc != null)
            {
                return(new ParameterClassBaseProperty(gc));
            }
            return(this);
        }
예제 #8
0
        /// <summary>
        /// this control is already added to Parent.Controls.
        /// 1. remove invalid inports
        /// 2. add missed EventPortIn
        /// </summary>
        /// <param name="viewer"></param>
        public override void Initialize(EventPathData eventData)
        {
            ClassPointer       root = this.ClassPointer.RootPointer;
            List <EventAction> ehs  = root.EventHandlers;

            if (ehs != null && ehs.Count > 0)
            {
                if (DestinationPorts == null)
                {
                    DestinationPorts = new List <EventPortIn>();
                }
                else
                {
                    //remove invalid inport
                    List <EventPortIn> invalidInports = new List <EventPortIn>();
                    foreach (EventPortIn pi in DestinationPorts)
                    {
                        bool bFound = false;
                        foreach (EventAction ea in ehs)
                        {
                            if (pi.Event.IsSameObjectRef(ea.Event))
                            {
                                if (pi.Event.IsSameObjectRef(ea.Event))
                                {
                                    if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                                    {
                                        foreach (TaskID tid in ea.TaskIDList)
                                        {
                                            if (tid.IsEmbedded)
                                            {
                                            }
                                            else
                                            {
                                                tid.LoadActionInstance(root);
                                                IAction a = tid.Action;
                                                if (a != null)
                                                {
                                                    SetterPointer cmp = a.ActionMethod as SetterPointer;
                                                    if (cmp != null)
                                                    {
                                                        CustomPropertyPointer cpp = cmp.SetProperty as CustomPropertyPointer;
                                                        if (cpp != null)
                                                        {
                                                            if (cpp.MemberId == this.PropertyId)
                                                            {
                                                                bFound = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (bFound)
                                {
                                    break;
                                }
                            }
                        }
                        if (!bFound)
                        {
                            invalidInports.Add(pi);
                        }
                    }
                    if (invalidInports.Count > 0)
                    {
                        foreach (EventPortIn pi in invalidInports)
                        {
                            DestinationPorts.Remove(pi);
                        }
                    }
                }
                //add missed EventPortIn
                foreach (EventAction ea in ehs)
                {
                    if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                    {
                        foreach (TaskID tid in ea.TaskIDList)
                        {
                            if (!tid.IsEmbedded)
                            {
                                IAction a = tid.LoadActionInstance(root);
                                if (a == null)
                                {
                                    MathNode.LogError(string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                                    "Action [{0}] not found", tid));
                                }
                                else
                                {
                                    SetterPointer cmp = a.ActionMethod as SetterPointer;
                                    if (cmp != null)
                                    {
                                        CustomPropertyPointer cpp = cmp.SetProperty as CustomPropertyPointer;
                                        if (cpp != null && cpp.MemberId == this.PropertyId)
                                        {
                                            bool bFound = false;
                                            foreach (EventPortIn pi in DestinationPorts)
                                            {
                                                if (pi.Event.IsSameObjectRef(ea.Event))
                                                {
                                                    bFound = true;
                                                    break;
                                                }
                                            }
                                            if (!bFound)
                                            {
                                                EventPortIn pi = new EventPortIn(this);
                                                pi.Event = ea.Event;
                                                double x, y;
                                                ComponentIconEvent.CreateRandomPoint(Width + ComponentIconEvent.PortSize, out x, out y);
                                                pi.Location = new Point((int)(Center.X + x), (int)(Center.Y + y));
                                                pi.SetLoaded();
                                                pi.SaveLocation();
                                                DestinationPorts.Add(pi);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// check whether the action is executed by the owner of this icon
        /// </summary>
        /// <param name="act"></param>
        /// <param name="root"></param>
        /// <returns></returns>
        public virtual bool IsActionExecuter(IAction act, ClassPointer root)
        {
            FireEventMethod fe = act.ActionMethod as FireEventMethod;

            if (fe != null)
            {
            }
            else if (act.ActionMethod != null)
            {
                DataTypePointer dtp = act.ActionMethod.Owner as DataTypePointer;
                if (dtp != null)
                {
                    return(false);
                }
                ClassPointer cpa = root.GetExternalExecuterClass(act);
                if (cpa != null)
                {
                    MemberComponentIdCustom idc = this.ClassPointer as MemberComponentIdCustom;
                    if (idc != null)
                    {
                        return(act.ExecuterClassId == idc.DefinitionClassId);
                    }
                    return(false);
                }
                CustomMethodPointer cmp = act.ActionMethod as CustomMethodPointer;
                if (cmp != null)
                {
                    //for the same class, ComponentIconMethod is used
                    if (act.ExecuterClassId != this.ClassPointer.ClassId)
                    {
                        MemberComponentIdCustom idc = this.ClassPointer as MemberComponentIdCustom;
                        if (idc != null)
                        {
                            return(act.ExecuterClassId == idc.DefinitionClassId);
                        }
                    }
                    return(false);
                }
                else
                {
                    SetterPointer sp = act.ActionMethod as SetterPointer;
                    if (sp != null)
                    {
                        CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                        if (cpp != null)
                        {
                            //for the same class ComponentIconProperty is used
                            if (act.ExecuterClassId != this.ClassPointer.ClassId)
                            {
                                MemberComponentIdCustom idc = this.ClassPointer as MemberComponentIdCustom;
                                if (idc != null)
                                {
                                    return(act.ExecuterClassId == idc.DefinitionClassId);
                                }
                            }
                            return(false);
                        }
                    }
                    return(act.ExecuterMemberId == this.ClassPointer.MemberId);
                }
            }
            else
            {
                ActionAttachEvent aae = act as ActionAttachEvent;
                if (aae != null)
                {
                    if (aae.ClassId == this.ClassId && aae.ExecuterMemberId == this.ClassPointer.MemberId)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #10
0
        public static EventPortOut CreateOutPort(TaskID a, EventIcon owner)
        {
            EventPortOut        po  = null;
            CustomMethodPointer cmp = null;
            HandlerMethodID     hid = a as HandlerMethodID;

            if (hid != null)
            {
                EventPortOutExecuteMethod em = new EventPortOutExecuteMethod(owner);
                em.SetMethod(hid.HandlerMethod);
                po = em;
            }
            else
            {
                if (a.Action == null)
                {
                }
                else
                {
                    IEventMapSource eir  = owner as IEventMapSource;
                    ClassPointer    root = eir.RootPointer;
                    ClassPointer    cpre = root.GetExternalExecuterClass(a.Action);
                    if (a.Action.IsStatic && cpre != null)
                    {
                        EventPortOutClassTypeAction pct = new EventPortOutClassTypeAction(owner);
                        pct.SetOwnerClassPointer(cpre);
                        po = pct;
                    }
                    else if (a.Action.ActionMethod != null)
                    {
                        DataTypePointer dtp = a.Action.ActionMethod.Owner as DataTypePointer;
                        if (dtp != null)
                        {
                            EventPortOutTypeAction pot = new EventPortOutTypeAction(owner);
                            pot.SetOwnerType(dtp.BaseClassType);
                            po = pot;
                        }
                        else
                        {
                            cmp = a.Action.ActionMethod as CustomMethodPointer;
                            if (cmp != null && cmp.Holder.DefinitionClassId == a.ClassId)
                            {
                                EventPortOutExecuteMethod em = new EventPortOutExecuteMethod(owner);
                                MethodClass mc = cmp.MethodPointed as MethodClass;
                                if (mc != null)
                                {
                                    em.SetMethod(mc);
                                }
                                po = em;
                            }
                            else
                            {
                                po = null;
                                SetterPointer sp = a.Action.ActionMethod as SetterPointer;
                                if (sp != null)
                                {
                                    CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                                    if (cpp != null)
                                    {
                                        EventPortOutSetProperty posp = new EventPortOutSetProperty(owner);
                                        posp.SetProperty(cpp.Property);
                                        posp.PropertyId = cpp.MemberId;
                                        po = posp;
                                    }
                                }
                                if (po == null)
                                {
                                    EventPortOutExecuter pe = new EventPortOutExecuter(owner);
                                    pe.ActionExecuterId = a.Action.ExecuterMemberId;
                                    po = pe;
                                }
                            }
                        }
                    }
                    else
                    {
                        ActionAttachEvent aae = a.Action as ActionAttachEvent;
                        if (aae != null)
                        {
                            EventPortOutExecuter pe = new EventPortOutExecuter(owner);
                            pe.ActionExecuterId = a.Action.ExecuterMemberId;
                            po = pe;
                        }
                    }
                }
            }
            if (po != null)
            {
                po.AddAction(a);
                ActiveDrawing ei = owner as ActiveDrawing;
                double        x, y;
                ComponentIconEvent.CreateRandomPoint(ei.Width + ComponentIconEvent.PortSize, out x, out y);
                po.Location = new Point((int)(ei.Center.X + x), (int)(ei.Center.Y + y));
                po.SetLoaded();
                po.SaveLocation();
            }
            return(po);
        }