void LoadComponentGlyph(TextReader sr) { string id; int X, Y, width, height; LoadBounds(sr, out id, out X, out Y, out width, out height); string parentId = NextLine(sr); if (parentId != "NOPARENT") { _ParentChildRel [id] = parentId; } IComponentGlyph glyph = _Factory.CreateComponent(id, new Rectangle(X, Y, width, height)); LoadGlyphCommon(sr, glyph); IComponentGlyph comp = glyph; comp.Name = LoadText(sr, "NAME"); comp.TypeName = LoadText(sr, "TYPENAME", ""); string isMultiInstance = LoadText(sr, "ISMULTIINSTANCE", false.ToString()); comp.IsMultiInstance = bool.Parse(isMultiInstance); BlankLine(sr); // blank line _GlyphLookup.Add(id, glyph); _Glyphs.Add(glyph); }
protected void Process() { _ComponentContexts = new Hashtable(); foreach (IComponentGlyph component in _Components) { Log(System.Drawing.Color.Green, "{1} {0} = new {1} ();", component.Name, component.TypeName); Type type = Type.GetType(component.TypeName); if (type == null) { throw new NullReferenceException("Type [" + component.TypeName + "] not found"); } object hsm = HsmUtil.CreateHsm(type); _ComponentContexts.Add(component.Name, new ComponentContext(hsm, component)); } foreach (IPortLinkGlyph portLink in _Ports) { IComponentGlyph compFrom = GetComponent(portLink, TransitionContactEnd.From); IComponentGlyph compTo = GetComponent(portLink, TransitionContactEnd.To); Log(System.Drawing.Color.Blue, "{0}.{1}.QEvents += new QEventHandler ({2}.{3}.Receive);", compFrom.Name, portLink.FromPortName, compTo.Name, portLink.ToPortName); ComponentContext compCtxFrom = _ComponentContexts [compFrom.Name] as ComponentContext; ComponentContext compCtxTo = _ComponentContexts [compTo.Name] as ComponentContext; LinkPorts(compCtxFrom, compCtxTo, portLink); } foreach (DictionaryEntry de in _PortContext) { IQPort port = de.Key as IQPort; port.QEvents += new QEventHandler(port_QEvents); } }
public void Visit(IPortLinkGlyph portLink) { WriteDefaults(portLink); _Writer.WriteElementString("FromPortName", portLink.FromPortName); _Writer.WriteElementString("SendIndex", portLink.SendIndex); _Writer.WriteElementString("ToPortName", portLink.ToPortName); foreach (IPortLinkContactPointGlyph contactPoint in portLink.ContactPoints) { if (contactPoint.Parent != null) { IComponentGlyph comp = contactPoint.Parent as IComponentGlyph; System.Diagnostics.Debug.Assert(comp != null); _Writer.WriteStartElement("Component"); try { _Writer.WriteElementString("Id", comp.Id); _Writer.WriteElementString("Name", comp.Name); } finally { _Writer.WriteEndElement(); } } } }
public ComponentContext(object hsm, IComponentGlyph comp) { _Component = comp; _Hsm = hsm as ILQHsm; if (_Hsm == null) { throw new NullReferenceException("Hsm created using " + _Component.TypeName + " is null"); } }
public override void Draw(IGraphicsContext GC) { Color oldColor = GC.Color; Color primary = Color.Orchid; if (!IsNotEmptyString(FromPortName) || !IsNotEmptyString(ToPortName) /* || !IsNotEmptyString (Interface) */) { primary = Color.Red; } GC.Color = primary; if (Selected) { GC.Thickness = 5; } else { GC.Thickness = 2; } GC.DrawLine(_From, _To); foreach (IPortLinkContactPointGlyph contact in ContactPoints) { switch (contact.WhichEnd) { case TransitionContactEnd.From: GC.Thickness = 3; break; case TransitionContactEnd.To: GC.Thickness = 5; break; default: throw new NotSupportedException("Unknown TransitionContactEnd: " + contact.WhichEnd.ToString()); } IComponentGlyph component = contact.Parent as IComponentGlyph; if (component != null) { GC.Color = component.ComponentColor; contact.Draw(GC); } else { GC.Color = primary; contact.Draw(GC); } } string s = DisplayText(); using (Brush brush = new System.Drawing.SolidBrush(Color.Black)) { GC.DrawString(s, brush, 10, new Point((_To.X + _From.X) / 2, (_To.Y + _From.Y) / 2), true); } GC.Color = oldColor; }
void SaveComponentGlyph(TextWriter sw, IComponentGlyph glyph) { SaveBounds(sw, "COMPONENT:", glyph); if (glyph.Parent != null) { sw.WriteLine(glyph.Parent.Id); } else { sw.WriteLine("NOPARENT"); } SaveGlyphCommon(sw, glyph); IComponentGlyph comp = glyph; SaveText(sw, "NAME", comp.Name); SaveText(sw, "TYPENAME", comp.TypeName); SaveTextIfNotDefault(sw, "ISMULTIINSTANCE", comp.IsMultiInstance.ToString(), false.ToString()); }
public void Visit(IComponentGlyph component) { WriteDefaults(component); _Writer.WriteElementString("TypeName", component.TypeName); _Writer.WriteElementString("IsMultiInstance", component.IsMultiInstance.ToString().ToLower()); }
protected IComponentGlyph GetComponent(IPortLinkGlyph portLink, IPortLinkContactPointGlyph contactPoint) { IComponentGlyph parent = contactPoint.Parent as IComponentGlyph; return(parent); }
public void Visit(IComponentGlyph component) { WriteDefaults (component); _Writer.WriteElementString ("TypeName", component.TypeName); _Writer.WriteElementString ("IsMultiInstance", component.IsMultiInstance.ToString ()); }
void SaveComponentGlyph(TextWriter sw, IComponentGlyph glyph) { SaveBounds (sw, "COMPONENT:", glyph); if (glyph.Parent != null) { sw.WriteLine (glyph.Parent.Id); } else { sw.WriteLine ("NOPARENT"); } SaveGlyphCommon (sw, glyph); IComponentGlyph comp = glyph; SaveText (sw, "NAME", comp.Name); SaveText (sw, "TYPENAME", comp.TypeName); SaveTextIfNotDefault (sw, "ISMULTIINSTANCE", comp.IsMultiInstance.ToString (), false.ToString ()); }
public ComponentContext(object hsm, IComponentGlyph comp) { _Component = comp; _Hsm = hsm as ILQHsm; if (_Hsm == null) { throw new NullReferenceException ("Hsm created using " + _Component.TypeName + " is null"); } }