protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0 && e.Index < this.Items.Count) { bool selected = ((e.State & DrawItemState.Selected) != 0); ComponentIconEvent item = this.Items[e.Index] as ComponentIconEvent; if (item != null) { Bitmap bmp = (Bitmap)item.IconImage; Rectangle rcBK = new Rectangle(e.Bounds.Left, e.Bounds.Top, 1, this.ItemHeight); if (e.Bounds.Width > bmp.Width) { rcBK.Width = e.Bounds.Width - bmp.Width; rcBK.X = bmp.Width; if (selected) { e.Graphics.FillRectangle(Brushes.LightBlue, rcBK); } else { e.Graphics.FillRectangle(Brushes.White, rcBK); } } Rectangle rc = new Rectangle(e.Bounds.Left, e.Bounds.Top + 2, bmp.Width, this.ItemHeight); float w = (float)(e.Bounds.Width - bmp.Width); if (w > 0) { RectangleF rcf = new RectangleF((float)(rc.Left + bmp.Width + 2), (float)(rc.Top), w, (float)this.ItemHeight); if (selected) { e.Graphics.DrawString(item.ToString(), this.Font, Brushes.White, rcf); } else { e.Graphics.DrawString(item.ToString(), this.Font, Brushes.Black, rcf); } } e.Graphics.DrawImage(bmp, rc); } else { if (selected) { e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds); } else { e.Graphics.FillRectangle(Brushes.White, e.Bounds); } if (this.Items[e.Index] != null) { e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds.Left, e.Bounds.Top); } } } }
public override bool IsActionExecuter(ComponentIconEvent obj) { ComponentIconClass cim = obj as ComponentIconClass; if (cim != null) { return(_classId == cim.ClassId); } return(false); }
private void btOK_Click(object sender, EventArgs e) { int n = listBox1.SelectedIndex; if (n >= 0) { SelectedIcon = listBox1.Items[n] as ComponentIconEvent; this.DialogResult = DialogResult.OK; } }
public override bool IsActionExecuter(ComponentIconEvent obj) { if (_type != null) { ComponentIconClassType cim = obj as ComponentIconClassType; if (cim != null) { return(_type.Equals(cim.ClassType)); } } return(false); }
public override bool IsActionExecuter(ComponentIconEvent obj) { ComponentIconFireEvent cife = obj as ComponentIconFireEvent; if (cife != null) { ComponentIconFireEvent cife0 = this.PortOwner as ComponentIconFireEvent; if (cife0 != null) { if (cife.FirerId == cife0.FirerId && cife.EventId == cife0.EventId) { return(true); } } } return(false); }
public override bool IsActionExecuter(ComponentIconEvent obj) { if (obj.IsForComponent) { MemberComponentIdCustom idc = obj.ClassPointer as MemberComponentIdCustom; if (idc != null && idc.DefinitionClassId != obj.ClassId) { return(idc.DefinitionClassId == _property.ClassId); } } else { ComponentIconProperty cim = obj as ComponentIconProperty; if (cim != null) { return(cim.PropertyId == this.PropertyId); } } return(false); }
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); } } } } }
public EventPortIn ValidateActionExecuter(EventAction ea, ClassPointer root) { EventPortIn missing = null; if (_inPortList == null) { _inPortList = new List <EventPortIn>(); } foreach (TaskID tid in ea.TaskIDList) { if (this.IsActionExecuter(tid, root)) { bool bFound = false; foreach (EventPortIn pi in _inPortList) { if (pi.Event.IsSameObjectRef(ea.Event)) { bFound = true; break; } } if (!bFound) { EventPortIn pi = new EventPortIn(this); pi.Event = ea.Event; _inPortList.Add(pi); double x, y; ComponentIconEvent.CreateRandomPoint(Width + ComponentIconEvent.PortSize, out x, out y); pi.Location = new Point((int)(Center.X + x), (int)(Center.Y + y)); pi.SetLoaded(); pi.SaveLocation(); // missing = pi; } break; } } return(missing); }
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); }
public static void MakePortLinks(PortCollection ports) { foreach (LinkLineNodePort p in ports) { EventPortIn epi = p as EventPortIn; if (epi != null) { EventPortInFireEvent epife = epi as EventPortInFireEvent; // bool bLinked = false; foreach (LinkLineNodePort p2 in ports) { bool bMatch = false; if (epife != null) { EventPortOutFirer epof = p2 as EventPortOutFirer; if (epof != null) { //it is a fire-event action ComponentIconFireEvent cife = epof.PortOwner as ComponentIconFireEvent; if (cife != null) { FireEventMethod fe1 = epife.FireEventMethod; FireEventMethod fe2 = cife.Firer; if (fe1 != null && fe2 != null && fe1.EventId == fe2.EventId && fe2.MemberId == fe2.MemberId) { bMatch = true; } } } } else { EventPortOut epo = p2 as EventPortOut; if (epo != null) { if (epi.Event.IsSameObjectRef(epo.Event)) { ComponentIconEvent cieDest = (ComponentIconEvent)(epi.PortOwner); if (epo.IsActionExecuter(cieDest)) { bMatch = true; } } } } if (bMatch) { if (p2.LinkedPortID == epi.PortID && p2.LinkedPortInstanceID == epi.PortInstanceID && epi.LinkedPortID == p2.PortID && epi.LinkedPortInstanceID == p2.PortInstanceID) { bLinked = true; break; } else { //try to fix it if (p2.LinkedPortID == 0 && epi.LinkedPortID == 0) { p2.LinkedPortID = epi.PortID; p2.LinkedPortInstanceID = epi.PortInstanceID; epi.LinkedPortID = p2.PortID; epi.LinkedPortInstanceID = p2.PortInstanceID; bLinked = true; break; } else { LinkLineNodePort lp; lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID); if (lp == null) { if (p2.LinkedPortID == 0) { p2.LinkedPortID = epi.PortID; p2.LinkedPortInstanceID = epi.PortInstanceID; epi.LinkedPortID = p2.PortID; epi.LinkedPortInstanceID = p2.PortInstanceID; bLinked = true; break; } else { lp = ports.GetPortByID(p2.LinkedPortID, p2.LinkedPortInstanceID); if (lp == null) { p2.LinkedPortID = epi.PortID; p2.LinkedPortInstanceID = epi.PortInstanceID; epi.LinkedPortID = p2.PortID; epi.LinkedPortInstanceID = p2.PortInstanceID; bLinked = true; break; } } } else { if (lp.LinkedPortID == epi.PortID && lp.LinkedPortInstanceID == epi.PortInstanceID) { bLinked = true; break; } } } } } } if (!bLinked) { if (epi.LinkedPortID != 0) { LinkLineNodePort lp; lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID); if (lp == null || lp != epi) { epi.LinkedPortInstanceID = 0; epi.LinkedPortID = 0; } } if (epi.LinkedPortID == 0) { } } } } foreach (LinkLineNodePort p in ports) { EventPortOut epo = p as EventPortOut; if (epo != null) { if (epo.LinkedPortID != 0) { if (ports.GetPortByID(epo.LinkedPortID, epo.LinkedPortInstanceID) == null) { epo.LinkedPortInstanceID = 0; epo.LinkedPortID = 0; } } } } }
/// <summary> /// this control is already added to Parent.Controls. /// 1. remove invalid inports /// 2. add missed EventPortIn /// </summary> /// <param name="viewer"></param> public override void Initialize(EventPathData eventData) { ClassPointer root = this.ClassPointer.RootPointer; List <EventAction> ehs = root.EventHandlers; if (ehs != null && ehs.Count > 0) { if (DestinationPorts == null) { DestinationPorts = new List <EventPortIn>(); } else { //remove invalid inport List <EventPortIn> invalidInports = new List <EventPortIn>(); foreach (EventPortIn pi in DestinationPorts) { bool bFound = false; foreach (EventAction ea in ehs) { if (pi.Event.IsSameObjectRef(ea.Event)) { if (pi.Event.IsSameObjectRef(ea.Event)) { if (ea.TaskIDList != null && ea.TaskIDList.Count > 0) { foreach (TaskID tid in ea.TaskIDList) { if (tid.IsEmbedded) { HandlerMethodID hid = tid as HandlerMethodID; if (hid != null) { if (hid.ActionId == this.MethodId) { bFound = true; break; } } } else { IAction a = root.GetActionInstance(tid.ActionId); //only public actions in map if (a != null) { CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer; if (cmp != null) { if (cmp.MemberId == this.MethodId) { bFound = true; break; } } } } } } } if (bFound) { break; } } } if (!bFound) { invalidInports.Add(pi); } } if (invalidInports.Count > 0) { foreach (EventPortIn pi in invalidInports) { DestinationPorts.Remove(pi); } } } //add missed EventPortIn foreach (EventAction ea in ehs) { if (ea.TaskIDList != null && ea.TaskIDList.Count > 0) { foreach (TaskID tid in ea.TaskIDList) { HandlerMethodID hid = tid as HandlerMethodID; if (hid != null) { if (hid.ActionId == this.MethodId) { bool bFound = false; foreach (EventPortIn pi in DestinationPorts) { if (pi.Event.IsSameObjectRef(ea.Event)) { bFound = true; break; } } if (!bFound) { EventPortIn pi = new EventPortIn(this); pi.Event = ea.Event; double x, y; ComponentIconEvent.CreateRandomPoint(Width + ComponentIconEvent.PortSize, out x, out y); pi.Location = new Point((int)(Center.X + x), (int)(Center.Y + y)); pi.SetLoaded(); pi.SaveLocation(); DestinationPorts.Add(pi); } } } else { //it is a root scope action IAction a = root.GetActionInstance(tid.ActionId); if (a == null) { MathNode.LogError(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Action [{0}] not found", tid)); } else { CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer; if (cmp != null) { if (cmp.MemberId == this.MethodId) { bool bFound = false; foreach (EventPortIn pi in DestinationPorts) { if (pi.Event.IsSameObjectRef(ea.Event)) { bFound = true; break; } } if (!bFound) { EventPortIn pi = new EventPortIn(this); pi.Event = ea.Event; double x, y; ComponentIconEvent.CreateRandomPoint(Width + ComponentIconEvent.PortSize, out x, out y); pi.Location = new Point((int)(Center.X + x), (int)(Center.Y + y)); pi.SetLoaded(); pi.SaveLocation(); DestinationPorts.Add(pi); } } } } } } } } } }
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); }
public void OnActionChanged(uint classId, IAction act, bool isNewAction) { if (_panes.Loader.ClassID == classId) { if (isNewAction) { if (_eventPath.SelectedEvent == null && _eventPath.SelectedLinkLine == null) { ComponentIconEvent cie = _eventPath.GetSelectedComponentIcon(); if (cie != null) { if (cie.IsForComponent) { if (cie.ClassPointer.MemberId == act.ExecuterMemberId) { listBoxActions.Items.Add(act); } } else { ComponentIconMethod cim = cie as ComponentIconMethod; if (cim != null) { CustomMethodPointer cmp = act.ActionMethod as CustomMethodPointer; if (cmp != null) { if (cmp.MemberId == cim.MethodId) { listBoxActions.Items.Add(act); } } } else { ComponentIconProperty cip = cie as ComponentIconProperty; if (cip != null) { if (cip.Property.IsActionOwner(act)) { listBoxActions.Items.Add(act); } } } } } } } else { for (int i = 0; i < listBoxActions.Items.Count; i++) { IAction a = listBoxActions.Items[i] as IAction; if (a != null) { if (a.ActionId == act.ActionId) { if (string.CompareOrdinal(a.ActionName, act.ActionName) != 0) { } } } } //if(_eventPath. } _eventPath.OnActionChanged(classId, act, isNewAction); } }
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); }
/// <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(); }
public override bool IsActionExecuter(ComponentIconEvent obj) { if (obj.IsForComponent) { if (Actions.Count > 0) { foreach (TaskID tid in Actions) { if (obj.IsActionExecuter(tid, tid.Action.Class)) { return(true); } } } return(false); } else { ComponentIconFireEvent cife = obj as ComponentIconFireEvent; if (cife != null) { if (Actions.Count > 0) { foreach (TaskID tid in Actions) { if (!tid.IsEmbedded) { if (tid.Action == null) { tid.LoadActionInstance(this.RootPointer); } if (tid.Action != null) { FireEventMethod fe = tid.Action.ActionMethod as FireEventMethod; if (fe != null) { if (fe.EventId == cife.EventId && fe.MemberId == cife.FirerId) { return(true); } } } } } } } else { ComponentIconClass cic = obj as ComponentIconClass; if (cic != null) { if (Actions.Count > 0) { foreach (TaskID tid in Actions) { if (tid.Action == null) { tid.LoadActionInstance(this.RootPointer); } if (tid.Action != null) { ClassPointer cp = this.RootPointer.GetExternalExecuterClass(tid.Action); if (cp != null) { if (cp.ClassId == cic.ClassId) { return(true); } } } } } } else { ComponentIconClassType cict = obj as ComponentIconClassType; if (cict != null) { if (Actions.Count > 0) { foreach (TaskID tid in Actions) { if (tid.Action == null) { tid.LoadActionInstance(this.RootPointer); } if (tid.Action != null) { ActionAttachEvent aae = tid.Action as ActionAttachEvent; if (aae != null) { if (aae.Class.BaseClassType.Equals(cict.ClassType)) { return(true); } } else if (tid.Action.ActionMethod != null) { DataTypePointer dtp = tid.Action.ActionMethod.Owner as DataTypePointer; if (dtp != null && dtp.BaseClassType != null) { if (dtp.BaseClassType.Equals(cict.ClassType)) { return(true); } } } } } } } } } } return(false); }
public abstract bool IsActionExecuter(ComponentIconEvent obj);
public List <Control> GetRelatedControls() { List <Control> lst = new List <Control>(); lst.Add(this); lst.Add(_label); if (_outPortList != null && _outPortList.Count > 0) { foreach (EventPortOut po in _outPortList) { lst.Add(po); if (po.Label != null) { lst.Add(po.Label); } ILinkLineNode l = po.NextNode; while (l != null && l.NextNode != null) { Control c = l as Control; if (c != null) { lst.Add(c); } l = l.NextNode; } EventPortIn pi = l as EventPortIn; if (pi != null) { lst.Add(pi); if (pi.Label != null) { lst.Add(pi.Label); } ComponentIconEventhandle cieh = pi.Owner as ComponentIconEventhandle; if (cieh != null) { if (cieh.Label != null) { lst.Add(cieh.Label); } lst.Add(cieh); } else { ComponentIconEvent cie = pi.Owner as ComponentIconEvent; if (cie != null) { cie.RemoveDestinationIcon(pi); } } if (this.Parent != null) { foreach (Control c in this.Parent.Controls) { ComponentIconEvent cie = c as ComponentIconEvent; if (cie != null) { List <EventPortIn> pis = cie.DestinationPorts; if (pis != null && pis.Count > 0) { bool b = false; foreach (EventPortIn p in pis) { if (p == pi) { b = true; break; } } if (b) { pis.Remove(pi); break; } } } } } } } } return(lst); }
/// <summary> /// icon selected by mouse, called from EventPath /// </summary> /// <param name="ci"></param> public void OnComponentIconSelection(ComponentIcon ci) { if (!_loading) { listBoxActions.Items.Clear(); ClassPointer root = _panes.Loader.GetRootId(); List <EventAction> eas = root.EventHandlers; if (eas != null) { ComponentIconEventhandle h = ci as ComponentIconEventhandle; if (h != null) { foreach (EventAction ea in eas) { if (ea.TaskIDList != null) { bool b = false; foreach (TaskID tid in ea.TaskIDList) { HandlerMethodID hid = tid as HandlerMethodID; if (hid != null) { if (hid.ActionId == h.MethodId) { listBoxActions.Items.Add(tid); b = true; break; } } } if (b) { break; } } } } else { Dictionary <UInt32, IAction> acts = root.GetActions(); if (acts != null) { ComponentIconMethod cim = ci as ComponentIconMethod; if (cim != null) { foreach (IAction a in acts.Values) { if (a != null && a.IsPublic) { CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer; if (cmp != null) { if (cmp.MemberId == cim.MethodId) { listBoxActions.Items.Add(a); } } } } } else { ComponentIconProperty cip = ci as ComponentIconProperty; if (cip != null) { foreach (IAction a in acts.Values) { if (a != null && a.IsPublic) { if (cip.Property.IsActionOwner(a)) { listBoxActions.Items.Add(a); } } } } else { ComponentIconClass cic = ci as ComponentIconClass; if (cic != null) { foreach (IAction a in acts.Values) { if (a != null && a.IsPublic) { if (cic.IsActionExecuter(a, root)) { listBoxActions.Items.Add(a); } } } } else { ComponentIconClassType cict = ci as ComponentIconClassType; if (cict != null) { foreach (IAction a in acts.Values) { if (a != null && a.IsPublic) { if (cict.IsActionExecuter(a, root)) { listBoxActions.Items.Add(a); } } } } else { ComponentIconEvent cie = ci as ComponentIconEvent; if (cie != null && cie.IsForComponent) { foreach (IAction a in acts.Values) { if (a != null && a.IsPublic) { if (cie.IsActionExecuter(a, root)) { listBoxActions.Items.Add(a); } } } } } } } } } } } } }