protected override void OnMove(EventArgs e)
        {
            base.OnMove(e);
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                int w = 0, h = 0;
                if (this.Left > ep.Size.Width - 80)
                {
                    w = this.Left + 80;
                }
                if (this.Top > ep.Size.Height - 80)
                {
                    h = this.Top + 80;
                }
                if (w > 0 || h > 0)
                {
                    if (w == 0)
                    {
                        w = ep.Size.Width;
                    }
                    if (h == 0)
                    {
                        h = ep.Size.Height;
                    }
                    ep.Size = new Size(w, h);
                }
                ep.NotifyCurrentChanges();
            }
        }
Esempio n. 2
0
        private void mi_assignActions(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ep.AssignActions(this.Event);
            }
        }
Esempio n. 3
0
        private void mi_remove(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ep.RemoveEventhandlers(this.Event);
            }
        }
Esempio n. 4
0
        public override void OnRelativeDrawingMove(RelativeDrawing relDraw)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ep.NotifyCurrentChanges();
            }
        }
Esempio n. 5
0
        private void addEventHandler(Type actionType)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root = ep.Panes.Loader.GetRootId();
                root.AddEventhandlerMethod(actionType, this.Event, 0, this.Bounds, this.FindForm());
            }
        }
        private void mi_delete(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root = ep.Panes.Loader.GetRootId();
                root.AskDeleteMethod(_method, this.FindForm());
            }
        }
Esempio n. 7
0
 private void mi_delete(object sender, EventArgs e)
 {
     if (_act != null)
     {
         EventPath ep = this.Parent as EventPath;
         if (ep != null)
         {
             ClassPointer root = ep.Loader.GetRootId();
             root.AskDeleteAction(_act, this.FindForm());
         }
     }
 }
        private void mi_createAction(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                IAction act = _method.CreateAction(ep.Panes.Loader, null, null, this.FindForm());
                if (act != null)
                {
                }
            }
        }
 private void miAssignEvent_Click(object sender, EventArgs e)
 {
     if (OnBeforeUseComponent())
     {
         EventPath ep = this.Parent as EventPath;
         if (ep != null)
         {
             ILimnorDesignPane dp   = ep.Panes.Loader.DesignPane;
             MenuItemDataEvent data = (MenuItemDataEvent)(((MenuItem)sender).Tag);
             data.ExecuteMenuCommand(ep.Project, this.ClassPointer, dp.RootXmlNode, ep.Panes, null, null);
         }
     }
 }
Esempio n. 10
0
        private void mi_createAction(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root = ep.Panes.Loader.GetRootId();
                ActionClass  act  = root.CreateSetPropertyAction(_property);
                act.ActionHolder = root;
                if (root.CreateNewAction(act, ep.Panes.Loader.Writer, null, this.FindForm()))
                {
                }
            }
        }
Esempio n. 11
0
        private void mi_removeEvent(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root = ep.Panes.Loader.GetRootId();
                EventClass   ec   = this.CustomEvent;
                if (ec.ClassId == root.ClassId)
                {
                    root.AskDeleteEvent(ec, this.FindForm());
                }
            }
        }
Esempio n. 12
0
        public void SetDesigner(MultiPanes mp)
        {
            _panes     = mp;
            _classId   = mp.Loader.ClassID;
            _prjId     = mp.Loader.Project.ProjectGuid;
            _eventPath = new EventPath();
            //
            _eventPath.SetDesignerEx(mp, this);
            _eventPath.Dock = DockStyle.None;            //.Fill;
            //
            int     width = 0, height = 0;
            XmlNode epNode = _eventPath.XmlData;

            if (epNode != null)
            {
                width  = XmlUtil.GetAttributeInt(epNode, XMLATT_Width);
                height = XmlUtil.GetAttributeInt(epNode, XMLATT_Height);
            }
            if (width < splitContainer1.Panel1.Width)
            {
                width = splitContainer1.Panel1.Width * 2;
            }
            if (height < splitContainer1.Panel1.Height)
            {
                height = splitContainer1.Panel1.Height * 2;
            }
            _eventPath.Size = new Size(width, height);
            splitContainer1.Panel1.Controls.Add(_eventPath);
            Dictionary <UInt32, EventPathHolder> eps;
            EventMapService lst = VPLUtil.GetServiceByName(EGSCR) as EventMapService;

            if (lst == null)
            {
                lst = new EventMapService();
                VPLUtil.SetServiceByName(EGSCR, lst);
            }
            if (!lst.TryGetValue(_prjId, out eps))
            {
                eps = new Dictionary <uint, EventPathHolder>();
                lst.Add(_prjId, eps);
            }
            if (eps.ContainsKey(_classId))
            {
                eps[_classId] = this;
            }
            else
            {
                eps.Add(_classId, this);
            }
        }
Esempio n. 13
0
        private void mi_createEventFireMethod(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root = ep.Panes.Loader.GetRootId();
                EventClass   ec   = this.CustomEvent;
                if (ec.ClassId == root.ClassId)
                {
                    root.CreateFireEventAction(ec, ep.Panes.Loader.Writer, null, ep.FindForm());
                }
            }
        }
        private void mi_edit(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                UInt32             abId = 0;
                EventHandlerMethod ehm  = _method as EventHandlerMethod;
                if (ehm != null)
                {
                    abId = ehm.ActionBranchId;
                }
                _method.Edit(abId, ep.RectangleToScreen(this.Bounds), ep.Panes.Loader, this.FindForm());
            }
        }
 private void createNewAction(MenuItemDataMethod data)
 {
     if (OnBeforeUseComponent())
     {
         EventPath ep = this.Parent as EventPath;
         if (ep != null)
         {
             ILimnorDesignPane dp  = ep.Panes.Loader.DesignPane;
             IAction           act = data.CreateMethodAction(dp, this.ClassPointer, null, null);
             if (act != null)
             {
             }
         }
     }
 }
 private void miSetProperty_Click(object sender, EventArgs e)
 {
     if (OnBeforeUseComponent())
     {
         EventPath ep = this.Parent as EventPath;
         if (ep != null)
         {
             ILimnorDesignPane    dp   = ep.Panes.Loader.DesignPane;
             MenuItemDataProperty data = (MenuItemDataProperty)(((MenuItem)sender).Tag);
             ActionClass          act  = data.CreateSetPropertyAction(dp, ClassPointer, null, null);
             if (act != null)
             {
             }
         }
     }
 }
Esempio n. 17
0
 protected override void OnMove(EventArgs e)
 {
     if (_loaded)
     {
         base.OnMove(e);
         if (!_moving && !AdjustingPosition)
         {
             SaveLocation();
             EventPath ep = this.Parent as EventPath;
             if (ep != null)
             {
                 ep.NotifyCurrentChanges();
             }
         }
     }
 }
Esempio n. 18
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            bool      isWebComponent = DesignUtil.IsWebClientObject(_event.Owner);
            EventPath ep             = this.Parent as EventPath;

            if (ep != null)
            {
                ep.SelectEventIcon(this);
            }
            if (e.Button == MouseButtons.Right)
            {
                ContextMenu        menu = new ContextMenu();
                MenuItemWithBitmap mi;
                mi = new MenuItemWithBitmap("Assign actions", mi_assignActions, Resources._eventHandlers.ToBitmap());
                menu.MenuItems.Add(mi);
                if (isWebComponent)
                {
                    mi = new MenuItemWithBitmap("Add client handler actions", mi_addWebClientHandlerClientActs, Resources._handlerMethod.ToBitmap());
                    menu.MenuItems.Add(mi);
                    mi = new MenuItemWithBitmap("Add server handler actions", mi_addWebClientHandlerServerActs, Resources._webServerHandler.ToBitmap());
                    menu.MenuItems.Add(mi);
                    mi = new MenuItemWithBitmap("Add client and download handler actions", mi_addWebClientHandlerDownloadActs, Resources._webHandler2.ToBitmap());
                }
                else
                {
                    mi = new MenuItemWithBitmap("Add handler method", mi_addHandler, Resources._handlerMethod.ToBitmap());
                }
                menu.MenuItems.Add(mi);
                menu.MenuItems.Add("-");
                if (IsCustomEventForRoot)
                {
                    mi = new MenuItemWithBitmap("Create event-firing action", mi_createEventFireMethod, Resources._createEventFireAction.ToBitmap());
                    menu.MenuItems.Add(mi);
                    menu.MenuItems.Add("-");
                    mi = new MenuItemWithBitmap("Delete event", mi_removeEvent, Resources._delEvent.ToBitmap());
                    menu.MenuItems.Add(mi);
                }
                else
                {
                    mi = new MenuItemWithBitmap("Remove event handling", mi_remove, Resources._cancel.ToBitmap());
                    menu.MenuItems.Add(mi);
                }
                menu.Show(this, e.Location);
            }
        }
        private void mi_makeCopy(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer root      = ep.Panes.Loader.GetRootId();
                MethodClass  newMethod = root.MakeMethodCopy(_method, this.FindForm());
                if (newMethod != null)
                {
                    ComponentIconMethod cim = ep.getMethodComponentIcon(newMethod.MemberId);
                    if (cim != null)
                    {
                        cim.Location = new Point(this.Location.X + 20, this.Location.Y + 20);
                    }
                }
            }
        }
Esempio n. 20
0
        void mnu_remove(object sender, EventArgs e)
        {
            EventPath ep = this.Parent as EventPath;

            if (ep != null)
            {
                ClassPointer     root = ep.Panes.Loader.GetRootId();
                PropertyOverride po   = Property as PropertyOverride;
                if (po == null)
                {
                    throw new DesignerException("Overriden property is not found. [{0}]", Property);
                }
                if (MessageBox.Show(ep.FindForm(), "Do you want to remove the override of this property?", "Property", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    root.DeleteProperty(po);
                }
            }
        }
Esempio n. 21
0
        protected override void OnSelectByMouseDown()
        {
            ComponentIconEvent cie = RelativeOwner as ComponentIconEvent;

            if (cie != null)
            {
                if (cie.IsRootClass)
                {
                    EventClass ec = CustomEvent;
                    if (ec != null)
                    {
                        EventPath ep = this.Parent as EventPath;
                        if (ep != null)
                        {
                            ep.Panes.OnEventSelected(ec);
                            ep.Panes.Loader.NotifySelection(ec);
                        }
                    }
                }
            }
        }
        protected override void OnCreateContextMenu(ContextMenu mnu, Point location)
        {
            base.OnCreateContextMenu(mnu, location);
            if ((this.IsForComponent || IsClassType) && !(this.ClassPointer is HtmlElementUnknown))
            {
                if (IsRootClass)
                {
                    EventPath ep = this.Parent as EventPath;
                    if (ep != null)
                    {
                        ep.OnCreateContextMenuForRootComponent(mnu, location);
                        mnu.MenuItems.Add("-");
                    }
                }
                LimnorContextMenuCollection menudata = CreateMenuData();
                if (menudata != null)
                {
                    MenuItem mi;
                    MenuItem m0;
                    MenuItem m1;
                    //
                    #region Create Action
                    List <MenuItemDataMethod> methods = menudata.PrimaryMethods;
                    if (methods.Count > 0)
                    {
                        mi = new MenuItemWithBitmap("Create Action", Resources._newMethodAction.ToBitmap());
                        foreach (MenuItemDataMethod kv in methods)
                        {
                            m0          = new MenuItemWithBitmap(kv.Key, Resources._methodAction.ToBitmap());
                            m0.Click   += new EventHandler(miAction_Click);
                            kv.Location = location;
                            m0.Tag      = kv;
                            mi.MenuItems.Add(m0);
                        }
                        methods = menudata.SecondaryMethods;
                        if (methods.Count > 0)
                        {
                            m1 = new MenuItemWithBitmap("More methods", Resources._methods.ToBitmap());
                            mi.MenuItems.Add(m1);
                            foreach (MenuItemDataMethod kv in methods)
                            {
                                m0          = new MenuItemWithBitmap(kv.Key, Resources._methodAction.ToBitmap());
                                m0.Click   += new EventHandler(miAction_Click);
                                kv.Location = location;
                                m0.Tag      = kv;
                                m1.MenuItems.Add(m0);
                            }
                            m0 = new MenuItemWithBitmap("*All methods* =>", Resources._dialog.ToBitmap());
                            MenuItemDataMethodSelector miAll = new MenuItemDataMethodSelector(m0.Text, menudata);
                            miAll.Location = location;
                            m0.Tag         = miAll;
                            m1.MenuItems.Add(m0);
                            m0.Click += new EventHandler(miSetMethods_Click);
                        }
                        //
                        mnu.MenuItems.Add(mi);
                    }
                    #endregion
                    //
                    #region Create Set Property Action
                    List <MenuItemDataProperty> properties = menudata.PrimaryProperties;
                    if (properties.Count > 0)
                    {
                        mi = new MenuItemWithBitmap("Create Set Property Action", Resources._newPropAction.ToBitmap());
                        foreach (MenuItemDataProperty kv in properties)
                        {
                            m0          = new MenuItemWithBitmap(kv.Key, Resources._propAction.ToBitmap());
                            m0.Click   += new EventHandler(miSetProperty_Click);
                            kv.Location = location;
                            m0.Tag      = kv;
                            mi.MenuItems.Add(m0);
                        }
                        properties = menudata.SecondaryProperties;
                        if (properties.Count > 0)
                        {
                            m1 = new MenuItemWithBitmap("More properties", Resources._properties.ToBitmap());
                            mi.MenuItems.Add(m1);

                            foreach (MenuItemDataProperty kv in properties)
                            {
                                m0          = new MenuItemWithBitmap(kv.Key, Resources._propAction.ToBitmap());
                                m0.Click   += new EventHandler(miSetProperty_Click);
                                kv.Location = location;
                                m0.Tag      = kv;
                                m1.MenuItems.Add(m0);
                            }
                            m0 = new MenuItemWithBitmap("*All properties* =>", Resources._dialog.ToBitmap());
                            m1.MenuItems.Add(m0);
                            MenuItemDataPropertySelector pAll = new MenuItemDataPropertySelector(m0.Text, menudata);
                            pAll.Location = location;
                            m0.Tag        = pAll;
                            m0.Click     += new EventHandler(miSetProperties_Click);
                        }
                        //
                        mnu.MenuItems.Add(mi);
                    }
                    #endregion
                    //
                    #region Assign Actions
                    List <MenuItemDataEvent> events = menudata.PrimaryEvents;
                    if (events.Count > 0)
                    {
                        mi = new MenuItemWithBitmap("Assign Action", Resources._eventHandlers.ToBitmap());
                        foreach (MenuItemDataEvent kv in events)
                        {
                            m0          = new MenuItemWithBitmap(kv.Key, Resources._event1.ToBitmap());
                            m0.Click   += new EventHandler(miAssignEvent_Click);
                            kv.Location = location;
                            m0.Tag      = kv;
                            mi.MenuItems.Add(m0);
                            EventItem ei = kv as EventItem;
                            if (ei != null)
                            {
                                IEventInfoTree emi = ei.Value as IEventInfoTree;
                                if (emi != null)
                                {
                                    IEventInfoTree[] subs = emi.GetSubEventInfo();
                                    LimnorContextMenuCollection.createEventTree(m0, location, kv.Owner, subs, new EventHandler(miAssignEvent_Click));
                                }
                            }
                        }
                        events = menudata.SecondaryEvents;
                        if (events.Count > 0)
                        {
                            m1 = new MenuItemWithBitmap("More events", Resources._events.ToBitmap());
                            mi.MenuItems.Add(m1);
                            foreach (MenuItemDataEvent kv in events)
                            {
                                m0          = new MenuItemWithBitmap(kv.Key, Resources._event1.ToBitmap());
                                m0.Click   += new EventHandler(miAssignEvent_Click);
                                kv.Location = location;
                                m0.Tag      = kv;
                                m1.MenuItems.Add(m0);
                                EventItem ei = kv as EventItem;
                                if (ei != null)
                                {
                                    IEventInfoTree emi = ei.Value as IEventInfoTree;
                                    if (emi != null)
                                    {
                                        IEventInfoTree[] subs = emi.GetSubEventInfo();
                                        LimnorContextMenuCollection.createEventTree(m0, location, kv.Owner, subs, new EventHandler(miAssignEvent_Click));
                                    }
                                }
                            }
                            m0 = new MenuItemWithBitmap("*All events* =>", Resources._dialog.ToBitmap());
                            m1.MenuItems.Add(m0);
                            MenuItemDataEventSelector eAll = new MenuItemDataEventSelector(m0.Text, location, menudata);
                            m0.Tag    = eAll;
                            m0.Click += new EventHandler(miSetEvents_Click);
                        }
                        mnu.MenuItems.Add(mi);
                    }
                    #endregion
                }
            }
        }
Esempio n. 23
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();
        }