コード例 #1
0
        public override void OnReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
        {
            base.OnReadFromXmlNode(reader, node);
            XmlNodeList nodes = node.SelectNodes(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}/{1}", XML_EVENTS, XmlTags.XML_Item));

            if (nodes != null && nodes.Count > 0)
            {
                _events = new List <EventIcon>();
                foreach (XmlNode eNode in nodes)
                {
                    EventIcon ei = new EventIcon(this);
                    ei.ReadFromXmlNode((XmlObjectReader)reader, eNode);
                    _events.Add(ei);
                }
            }
            //
            _inPortList = new List <EventPortIn>();
            XmlNodeList nds = node.SelectNodes(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}/{1}", XML_INPORTS, XmlTags.XML_Item));

            foreach (XmlNode n in nds)
            {
                EventPortIn pi = new EventPortIn(this);
                pi.OnReadFromXmlNode(reader, n);
                _inPortList.Add(pi);
            }
        }
コード例 #2
0
        public override LinkLineNodeOutPort CreateDuplicateOutPort()
        {
            EventPortOut po = (EventPortOut)base.CreateDuplicateOutPort();
            EventIcon    ei = (EventIcon)po.PortOwner;

            ei.AddOutPort(po);
            return(po);
        }
コード例 #3
0
 public override void RemoveIcon()
 {
     if (FirerPort != null && FirerPort.LinkedInPort != null)
     {
         EventIcon ei = FirerPort.LinkedInPort.PortOwner as EventIcon;
         if (ei != null)
         {
             ei.RemoveInPort(FirerPort.LinkedInPort);
         }
     }
     base.RemoveIcon();
 }
コード例 #4
0
        /// <summary>
        /// get the EventIcon for the event.
        /// create it if it does not exist.
        /// </summary>
        /// <param name="ea"></param>
        /// <param name="eventData"></param>
        /// <returns></returns>
        public EventIcon ValidateEventFirer(List <EventAction> eas, EventPathData eventData)
        {
            EventIcon ei = null;

            if (_events == null)
            {
                _events = new List <EventIcon>();
            }
            foreach (EventIcon e in _events)
            {
                if (e.Event.IsSameObjectRef(eas[0].Event))
                {
                    ei = e;
                    ei.SetData(eas, eventData);
                    break;
                }
            }
            if (ei == null)
            {
                ei = new EventIcon(this, eas, eventData);
                _events.Add(ei);
            }
            return(ei);
        }
コード例 #5
0
 public EventIcon CheckCreateEventIcon(EventClass ec)
 {
     if (IsRootClass)
     {
         ClassPointer root = this.ClassPointer.RootPointer;
         EventIcon    ei   = GetEventIcon(ec);
         if (ei == null)
         {
             ei       = new EventIcon(this);
             ei.Event = new CustomEventPointer(ec, root);
             if (_events == null)
             {
                 _events = new List <EventIcon>();
             }
             _events.Add(ei);
             ei.SetMoveUnLink(true);
             ComponentIconEvent.SetInitialPosition(100, ei);
             Parent.Controls.Add(ei);
             ei.Initialize();
         }
         return(ei);
     }
     return(null);
 }
コード例 #6
0
        public void OnEventIconSelection(EventIcon ei)
        {
            listBoxActions.Items.Clear();
            ClassPointer       root = _panes.Loader.GetRootId();
            List <EventAction> eas  = root.EventHandlers;

            if (eas != null)
            {
                foreach (EventAction ea in eas)
                {
                    if (ei.Event.IsSameObjectRef(ea.Event))
                    {
                        if (ea.TaskIDList != null)
                        {
                            foreach (TaskID tid in ea.TaskIDList)
                            {
                                if (tid.Action == null)
                                {
                                    HandlerMethodID hmid = tid as HandlerMethodID;
                                    if (hmid != null)
                                    {
                                    }
                                    else
                                    {
                                        //it is a public action
                                        tid.SetAction(root.GetActionInstance(tid.ActionId));
                                    }
                                }
                                listBoxActions.Items.Add(tid);
                            }
                        }
                        break;
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// this control is already added to Parent.Controls
        /// 1. remove invalid inports
        /// 2. remove invalid EventIcon
        /// 3. add missed EventIcon
        /// 4. add missed EventPortIn
        /// 4. add EventIcon objects to Parent.Controls
        /// 5. initialize EventIcon
        /// </summary>
        /// <param name="viewer"></param>
        public virtual void Initialize(EventPathData eventData)
        {
            bool isRoot = this.IsRootClass;
            //validate events
            ClassPointer root = RootClassPointer;
            Dictionary <string, EventClass> events = root.CustomEvents;
            List <EventAction> ehs = root.EventHandlers;

            if (ehs != null && ehs.Count > 0)
            {
                if (_inPortList == null)
                {
                    _inPortList = new List <EventPortIn>();
                }
                else
                {
                    //remove invalid inport
                    List <EventPortIn> invalidInports = new List <EventPortIn>();
                    foreach (EventPortIn pi in _inPortList)
                    {
                        bool bFound = false;
                        foreach (EventAction ea in ehs)
                        {
                            if (pi.Event.IsSameObjectRef(ea.Event))
                            {
                                if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                                {
                                    foreach (TaskID tid in ea.TaskIDList)
                                    {
                                        if (this.IsActionExecuter(tid, root))
                                        {
                                            bFound = true;
                                            break;
                                        }
                                    }
                                }
                                if (bFound)
                                {
                                    break;
                                }
                            }
                        }
                        if (!bFound)
                        {
                            invalidInports.Add(pi);
                        }
                    }
                    if (invalidInports.Count > 0)
                    {
                        foreach (EventPortIn pi in invalidInports)
                        {
                            _inPortList.Remove(pi);
                        }
                    }
                }
                //remove invalid EventIcon objects
                if (_events != null)
                {
                    List <EventIcon> invalid = new List <EventIcon>();
                    foreach (EventIcon ei in _events)
                    {
                        bool bFound = false;
                        if (ei.Event != null)
                        {
                            EventClass eic = ei.CustomEvent;
                            if (eic != null)
                            {
                                if (isRoot)
                                {
                                    if (this.ClassId == eic.ClassId)
                                    {
                                        foreach (EventClass ec in events.Values)
                                        {
                                            if (ec.IsSameObjectRef(eic))
                                            {
                                                bFound = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (!bFound)
                            {
                                foreach (EventAction ea in ehs)
                                {
                                    if (ei.Event.IsSameObjectRef(ea.Event))
                                    {
                                        bFound = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!bFound)
                        {
                            invalid.Add(ei);
                        }
                    }
                    foreach (EventIcon ei in invalid)
                    {
                        _events.Remove(ei);
                    }
                    //remove duplicated ports
                    foreach (EventIcon ei in _events)
                    {
                        ei.ValidateSourcePorts();
                    }
                }
                //add missed EventIcon
                //add missed EventPortIn
                Dictionary <string, List <EventAction> > eaGroup = EventPathData.CreateHandlerGroup(ehs);
                foreach (EventAction ea in ehs)
                {
                    IClass ic = EventPathData.GetEventFirerRef(ea.Event.Holder);
                    if (ic != null)
                    {
                        if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                        {
                            if (ic.IsSameObjectRef(this.ClassPointer))
                            {
                                List <EventAction> eas;
                                if (eaGroup.TryGetValue(ea.Event.ObjectKey, out eas))
                                {
                                    ValidateEventFirer(eas, eventData);
                                }
                            }
                            ValidateActionExecuter(ea, root);
                        }
                    }
                }
            }
            if (isRoot)
            {
                foreach (EventClass ec in events.Values)
                {
                    bool bFound = false;
                    if (_events != null)
                    {
                        foreach (EventIcon ei in _events)
                        {
                            if (ec.IsSameObjectRef(ei.CustomEvent))
                            {
                                ei.SetMoveUnLink(true);
                                bFound = true;
                                break;
                            }
                        }
                    }
                    if (!bFound)
                    {
                        if (_events == null)
                        {
                            _events = new List <EventIcon>();
                        }
                        EventIcon ei = new EventIcon(this);
                        ei.Event = new CustomEventPointer(ec, root);
                        ei.SetMoveUnLink(true);
                        _events.Add(ei);
                    }
                }
            }
            //add EventIcon objects to Parent.Controls
            //initialize EventIcon
            if (_events != null)
            {
                Parent.Controls.AddRange(_events.ToArray());
                foreach (EventIcon ei in _events)
                {
                    ei.AdjustPosition();
                    ei.Initialize();
                }
            }
            else
            {
                _events = new List <EventIcon>();
            }
        }
コード例 #8
0
        protected override List <Control> GetRelatedControls()
        {
            List <Control> lst = base.GetRelatedControls();

            if (_inPortList != null && _inPortList.Count > 0)
            {
                foreach (EventPortIn pi in _inPortList)
                {
                    lst.Add(pi);
                    if (pi.Label != null)
                    {
                        lst.Add(pi.Label);
                    }
                    ILinkLineNode l = pi.PrevNode;
                    while (l != null && l.PrevNode != null)
                    {
                        Control c = l as Control;
                        if (c != null)
                        {
                            lst.Add(c);
                        }
                        l = l.PrevNode;
                    }
                    EventPortOut po = l as EventPortOut;
                    if (po != null)
                    {
                        EventIcon ei = po.Owner as EventIcon;
                        if (ei != null)
                        {
                            if (ei.SourcePorts.Count == 1)
                            {
                                lst.Add(po);
                                if (po.Label != null)
                                {
                                    lst.Add(po.Label);
                                }
                                lst.Add(ei);
                                if (ei.Label != null)
                                {
                                    lst.Add(ei.Label);
                                }
                                ComponentIconEvent cie = ei.RelativeOwner as ComponentIconEvent;
                                if (cie != null)
                                {
                                    if (cie._events != null && cie._events.Contains(ei))
                                    {
                                        cie._events.Remove(ei);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (_events != null && _events.Count > 0)
            {
                foreach (EventIcon ei in _events)
                {
                    lst.AddRange(ei.GetRelatedControls());
                }
            }
            return(lst);
        }
コード例 #9
0
        /// <summary>
        /// remove invalid icons
        /// add missing icons
        /// make links
        /// </summary>
        /// <param name="eventPath"></param>
        public void OnLoadData(EventPath eventPath)
        {
            _owner = eventPath;
            //all icons saved in XML
            List <ComponentIconEvent> iconList = ComponentIconList;
            //all components, each corresponding to one icon
            ClassPointer  root    = _owner.Loader.GetRootId();
            List <IClass> objList = root.GetClassList();
            //all custom methods, each corresponding to one icon
            Dictionary <string, MethodClass> methods = root.CustomMethods;
            //all event handlers, each HandlerMathodID object corresponds to one icon
            List <EventAction> handlers = root.EventHandlers;
            //all custom properties
            Dictionary <string, PropertyClass> props = root.CustomProperties;
            //all used html elements
            IList <HtmlElement_BodyBase> htmlElements = null;

            if (root.IsWebPage)
            {
                htmlElements = root.UsedHtmlElements;
            }
            //
            //remove invalid icons
            List <ComponentIconEvent> iconInvalid = new List <ComponentIconEvent>();

            foreach (ComponentIconEvent ic in iconList)
            {
                if (!ic.OnDeserialize(root, _owner.Loader))
                {
                    iconInvalid.Add(ic);
                }
            }
            foreach (ComponentIconEvent ic in iconInvalid)
            {
                iconList.Remove(ic);
            }
            //remove invalid events. unknown reason causing invalid events
            foreach (ComponentIconEvent ic in iconList)
            {
                if (ic.MemberId != 0 && ic.GetType().Equals(typeof(ComponentIconEvent)))
                {
                    MemberComponentId mid0 = ic.ClassPointer as MemberComponentId;
                    if (mid0 != null)
                    {
                        List <EventIcon> eis = ic.EventIcons;
                        if (eis != null && eis.Count > 0)
                        {
                            List <EventIcon> invalidEis = new List <EventIcon>();
                            foreach (EventIcon ei in eis)
                            {
                                if (ei.Event != null)
                                {
                                    MemberComponentId mid = ei.Event.Owner as MemberComponentId;
                                    if (mid != null && mid.MemberId != 0)
                                    {
                                        if (mid.MemberId != ic.MemberId)
                                        {
                                            invalidEis.Add(ei);
                                        }
                                    }
                                }
                            }
                            foreach (EventIcon ei in invalidEis)
                            {
                                eis.Remove(ei);
                            }
                        }
                    }
                }
            }
            //
            //add new icons
            int x0 = 20;
            int y0 = 20;
            int x  = x0;
            int y  = y0;
            int dx = 30;
            int dy = 30;

            //add missing component icon
            foreach (IClass c in objList)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (ic.IsForComponent)
                    {
                        if (ic.MemberId == c.MemberId)
                        {
                            ic.Designer = _owner.Loader;
                            bFound      = true;
                            break;
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconEvent cip;
                    if (c is HtmlElement_Base)
                    {
                        cip = new ComponentIconHtmlElement();
                    }
                    else
                    {
                        cip = new ComponentIconEvent();
                    }
                    cip.Init(_owner.Loader, c);
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
            ComponentIconEvent rootIcon = null;

            foreach (ComponentIconEvent ci in iconList)
            {
                if (ci.IsForComponent)
                {
                    if (ci.IsRootClass)
                    {
                        rootIcon = ci;
                        break;
                    }
                }
            }
            if (rootIcon == null)
            {
                throw new DesignerException("Root component icon not found for class {0}", root.ClassId);
            }
#if USEHTMLEDITOR
            //add missing html element
            if (htmlElements != null)
            {
                foreach (HtmlElement_Base he in htmlElements)
                {
                    bool bFound = false;
                    foreach (ComponentIconEvent ic in iconList)
                    {
                        ComponentIconHtmlElement cihe = ic as ComponentIconHtmlElement;
                        if (cihe != null)
                        {
                            if (ic.MemberId == cihe.MemberId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                    if (!bFound)
                    {
                        ComponentIconHtmlElement cip = new ComponentIconHtmlElement();
                        cip.Init(_owner.Loader, he);
                        cip.Location = new Point(x, y);
                        x           += dx;
                        x           += cip.Width;
                        if (x > _owner.Width)
                        {
                            x  = x0;
                            y += dy;
                            y += cip.Height;
                        }
                        iconList.Add(cip);
                    }
                }
            }
            //add missing current html element
            if (root.IsWebPage)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    ComponentIconHtmlElementCurrent cic = ic as ComponentIconHtmlElementCurrent;
                    if (cic != null)
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    HtmlElement_body heb = new HtmlElement_body(root);
                    ComponentIconHtmlElementCurrent cip = new ComponentIconHtmlElementCurrent();
                    cip.ClassPointer = heb;
                    cip.Init(_owner.Loader, heb);
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
#endif
            //add missing FireEventMethod, ComponentIconClass and ComponentIconClassType
            Dictionary <UInt32, IAction> actions = root.GetActions();
            foreach (IAction act in actions.Values)
            {
                if (act != null)
                {
                    FireEventMethod fe = act.ActionMethod as FireEventMethod;
                    if (fe != null)
                    {
                        ComponentIconFireEvent cife = null;
                        foreach (ComponentIconEvent ic in iconList)
                        {
                            if (!ic.IsForComponent)
                            {
                                ComponentIconFireEvent cie = ic as ComponentIconFireEvent;
                                if (cie != null)
                                {
                                    if (fe.MemberId == cie.FirerId && fe.EventId == cie.EventId)
                                    {
                                        cie.Firer   = fe;
                                        ic.Designer = _owner.Loader;
                                        cife        = cie;
                                        break;
                                    }
                                }
                            }
                        }
                        if (cife == null)
                        {
                            cife       = new ComponentIconFireEvent();
                            cife.Firer = fe;
                            cife.Init(_owner.Loader, root);
                            cife.Location = new Point(x, y);
                            //cip.FirerPort
                            x += dx;
                            x += cife.Width;
                            if (x > _owner.Width)
                            {
                                x  = x0;
                                y += dy;
                                y += cife.Height;
                            }
                            iconList.Add(cife);
                        }
                        //make port link
                        EventPortInFireEvent epife = null;
                        EventIcon            ei    = rootIcon.GetEventIcon(fe.Event);
                        if (ei == null)
                        {
                            ei       = new EventIcon(rootIcon);
                            ei.Event = fe.Event;
                            ComponentIconEvent.SetInitialPosition(100, ei);
                            rootIcon.EventIcons.Add(ei);
                        }
                        List <EventPortIn> ports = ei.DestinationPorts;
                        foreach (EventPortIn epi in ports)
                        {
                            EventPortInFireEvent epife0 = epi as EventPortInFireEvent;
                            if (epife0 != null)
                            {
                                if (epife0.FireEventMethodId == fe.MemberId)
                                {
                                    epife0.FireEventMethod = fe;
                                    epife = epife0;
                                    break;
                                }
                            }
                        }
                        if (epife == null)
                        {
                            epife = new EventPortInFireEvent(ei);
                            epife.FireEventMethod = fe;
                            ei.DestinationPorts.Add(epife);
                        }
                        epife.LinkedPortID                  = cife.FirerPort.PortID;
                        epife.LinkedPortInstanceID          = cife.FirerPort.PortInstanceID;
                        cife.FirerPort.LinkedPortID         = epife.PortID;
                        cife.FirerPort.LinkedPortInstanceID = epife.PortInstanceID;
                        //
                        epife.RestoreLocation();
                        epife.SetLoaded();
                        //
                        cife.FirerPort.RestoreLocation();
                        cife.FirerPort.SetLoaded();
                    }
                    else if (act.ActionMethod != null)
                    {
                        ClassPointer cp = root.GetExternalExecuterClass(act);
                        if (cp != null)
                        {
                            ComponentIconClass cic = null;
                            foreach (ComponentIconEvent ic in iconList)
                            {
                                ComponentIconClass cic0 = ic as ComponentIconClass;
                                if (cic0 != null)
                                {
                                    if (cic0.ClassId == act.ExecuterClassId)
                                    {
                                        cic          = cic0;
                                        cic.Designer = _owner.Loader;
                                        break;
                                    }
                                }
                            }
                            if (cic == null)
                            {
                                cic = new ComponentIconClass();
                                cic.Init(_owner.Loader, cp);
                                cic.Location = new Point(x, y);
                                x           += dx;
                                x           += cic.Width;
                                if (x > _owner.Width)
                                {
                                    x  = x0;
                                    y += dy;
                                    y += cic.Height;
                                }
                                iconList.Add(cic);
                            }
                        }
                        else
                        {
                            DataTypePointer tp = act.ActionMethod.Owner as DataTypePointer;
                            if (tp != null)
                            {
                                ComponentIconClassType cict = null;
                                foreach (ComponentIconEvent ic in iconList)
                                {
                                    ComponentIconClassType cict0 = ic as ComponentIconClassType;
                                    if (cict0 != null)
                                    {
                                        if (cict0.ClassType.Equals(tp.BaseClassType))
                                        {
                                            cict          = cict0;
                                            cict.Designer = _owner.Loader;
                                            break;
                                        }
                                    }
                                }
                                if (cict == null)
                                {
                                    cict = new ComponentIconClassType();
                                    cict.Init(_owner.Loader, tp);
                                    cict.Location = new Point(x, y);
                                    x            += dx;
                                    x            += cict.Width;
                                    if (x > _owner.Width)
                                    {
                                        x  = x0;
                                        y += dy;
                                        y += cict.Height;
                                    }
                                    iconList.Add(cict);
                                }
                            }
                        }
                    }
                    else
                    {
                        ActionAttachEvent aae = act as ActionAttachEvent;
                        if (aae != null)
                        {
                            IObjectPointer eventOwner = aae.EventOwner;
                            if (eventOwner != null)
                            {
                            }
                        }
                    }
                }
            }
            //add missing method icon
            foreach (MethodClass mc in methods.Values)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (!ic.IsForComponent)
                    {
                        ComponentIconMethod cie = ic as ComponentIconMethod;
                        if (cie != null)
                        {
                            if (mc.MethodID == cie.MethodId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconMethod cip = new ComponentIconMethod();
                    cip.Init(_owner.Loader, mc.RootPointer);
                    cip.Method   = mc;
                    cip.MethodId = mc.MethodID;
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
            //add missing handler icon
            foreach (EventAction ea in handlers)
            {
                if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                {
                    foreach (TaskID tid in ea.TaskIDList)
                    {
                        HandlerMethodID hid = tid as HandlerMethodID;
                        if (hid != null)
                        {
                            bool bFound = false;
                            foreach (ComponentIconEvent ic in iconList)
                            {
                                ComponentIconEventhandle cie = ic as ComponentIconEventhandle;
                                if (cie != null)
                                {
                                    if (ic.MemberId == cie.MemberId && cie.MethodId == hid.ActionId)
                                    {
                                        ic.Designer = _owner.Loader;
                                        bFound      = true;
                                        break;
                                    }
                                }
                            }
                            if (!bFound)
                            {
                                ComponentIconEventhandle cip = new ComponentIconEventhandle();
                                cip.Init(_owner.Loader, root);
                                cip.Method   = hid.HandlerMethod;
                                cip.MethodId = hid.ActionId;
                                cip.Location = new Point(x, y);
                                x           += dx;
                                x           += cip.Width;
                                if (x > _owner.Width)
                                {
                                    x  = x0;
                                    y += dy;
                                    y += cip.Height;
                                }
                                iconList.Add(cip);
                            }
                        }
                    }
                }
            }
            //add missing property icon
            foreach (PropertyClass p in props.Values)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (!ic.IsForComponent)
                    {
                        ComponentIconProperty cie = ic as ComponentIconProperty;
                        if (cie != null)
                        {
                            if (p.MemberId == cie.PropertyId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconProperty cip = new ComponentIconProperty();
                    cip.Init(_owner.Loader, root);
                    cip.Property   = p;
                    cip.PropertyId = p.MemberId;
                    cip.Location   = new Point(x, y);
                    x += dx;
                    x += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }

            //add icons to the parent
            _owner.Controls.AddRange(iconList.ToArray());
            //collect all ports
            PortCollection pc = new PortCollection();
            foreach (ComponentIconEvent ic in iconList)
            {
                if (ic.Left < 0)
                {
                    ic.Left = 2;
                }
                if (ic.Top < 0)
                {
                    ic.Top = 2;
                }
                ic.Visible = true;
                ic.BringToFront();
                ic.RefreshLabelPosition();
                //
                if (ic.IsPortOwner)
                {
                    //validate the input/output ports of the icon.
                    //it will also add EventIcon controls to the parent
                    ic.Initialize(this);
                    //collect ports from the icon
                    pc.AddRange(ic.GetAllPorts());
                }
            }
            //add all ports to the parent
            List <Control> cs = pc.GetAllControls(false);
            _owner.Controls.AddRange(cs.ToArray());
            //apply port locations
            foreach (ComponentIconEvent ic in iconList)
            {
                //output ports
                List <EventIcon> eis = ic.EventIcons;
                if (eis != null && eis.Count > 0)
                {
                    foreach (EventIcon ei in eis)
                    {
                        List <EventPortOut> pos = ei.SourcePorts;
                        if (pos != null)
                        {
                            foreach (EventPortOut po in pos)
                            {
                                po.RestoreLocation();
                                po.SetLoaded();
                            }
                        }
                    }
                }
                //input ports
                List <EventPortIn> epis = ic.DestinationPorts;
                if (epis != null && epis.Count > 0)
                {
                    foreach (EventPortIn pi in epis)
                    {
                        pi.RestoreLocation();
                        pi.SetLoaded();
                    }
                }
            }
            pc.ValidatePortLinks();
            //link ports
            MakePortLinks(pc);
            //link lines
            pc.MakeLinks(TraceLogClass.MainForm);
            //set line color
            SetDynamicEventHandlerLineColor(pc);
            //
            pc.CreateLinkLines();
            //
            //remove unlinked inports
            foreach (ComponentIconEvent cieSource in iconList)
            {
                List <EventPortIn> epis = cieSource.DestinationPorts;
                if (epis != null && epis.Count > 0)
                {
                    List <EventPortIn> unlinked = new List <EventPortIn>();
                    foreach (EventPortIn ei in epis)
                    {
                        if (ei.LinkedOutPort == null)
                        {
                            unlinked.Add(ei);
                        }
                    }
                    if (unlinked.Count > 0)
                    {
                        foreach (EventPortIn ei in unlinked)
                        {
                            epis.Remove(ei);
                            if (ei.Parent != null)
                            {
                                ei.Parent.Controls.Remove(ei);
                            }
                        }
                    }
                }
            }
            //monitor and notify link line changes
            eventPath.SetupLineNodeMonitor();
            //
            //remedy for unsolved bug: remove duplicated ComponentIconEvent
            Dictionary <UInt64, List <ComponentIconEvent> > cieList = new Dictionary <UInt64, List <ComponentIconEvent> >();
            foreach (ComponentIconEvent cieSource in iconList)
            {
                if (typeof(ComponentIconEvent).Equals(cieSource.GetType()))
                {
                    UInt64 id = cieSource.WholeId;
                    List <ComponentIconEvent> list;
                    if (!cieList.TryGetValue(id, out list))
                    {
                        list = new List <ComponentIconEvent>();
                        cieList.Add(id, list);
                    }
                    list.Add(cieSource);
                }
            }
            foreach (KeyValuePair <UInt64, List <ComponentIconEvent> > kv in cieList)
            {
                if (kv.Value.Count > 1)
                {
                    //duplicate icons. Find those can be removed
                    List <ComponentIconEvent> deleting = new List <ComponentIconEvent>();
                    foreach (ComponentIconEvent cie in kv.Value)
                    {
                        if (cie.DestinationPorts.Count == 0)
                        {
                            if (cie.EventIcons.Count == 0)
                            {
                                deleting.Add(cie);
                            }
                        }
                    }
                    if (deleting.Count == kv.Value.Count)
                    {
                        deleting.RemoveAt(0);
                    }
                    foreach (ComponentIconEvent cie in deleting)
                    {
                        cie.Parent.Controls.Remove(cie.Label);
                        cie.Parent.Controls.Remove(cie);
                        _componentIconList.Remove(cie);
                        if (cie.DataXmlNode != null)
                        {
                            XmlNode xmp = cie.DataXmlNode.ParentNode;
                            xmp.RemoveChild(cie.DataXmlNode);
                        }
                    }
                }
            }
            eventPath.EnlargeForChildren();
        }
コード例 #10
0
 public EventPortOutSetProperty(EventIcon owner)
     : base(owner)
 {
 }
コード例 #11
0
 public EventPortOutExecuteMethod(EventIcon owner)
     : base(owner)
 {
 }
コード例 #12
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);
        }
コード例 #13
0
 public EventPortOutClassTypeAction(EventIcon owner)
     : base(owner)
 {
 }