public void DeleteCurrentElement() { if (this.m_ActiveElement != null) { ArrayList list = new ArrayList(); foreach (Connection connection in this.m_ActiveElement.m_Connections) { list.Add(connection); connection.GetConnectedElement(this.m_ActiveElement).Disconnect(connection); } this.m_ActiveElement.Disconnect(); foreach (Connection connection in list) { this.m_Layout.Connections.Remove(connection); } this.m_Layout.Elements.Remove(this.m_ActiveElement); this.m_ActiveElement = null; this.SetScrollSize(); this.Invalidate(); } }
public bool GetConnectedElement(Element eFor, out Element e, out int nElementSource) { int num; return this.GetConnectedElement(eFor, out num, out e, out nElementSource); }
public bool IsConnectedTo(Element pe, out int nMySource, out int nForeignSource) { nForeignSource = nMySource = -1; foreach (Connection connection in this.m_Connections) { Element element; if (connection.GetConnectedElement(this, out nMySource, out element, out nForeignSource) && (pe == element)) { return true; } } return false; }
public override int CanConnect(Point p, Element e, int nSource, out Point pDest) { int num = -1; pDest = new Point(0.0, 0.0); if (e != this) { if (Element.IsPtCaptured(p, this.PointPlus)) { pDest = this.PointPlus; num = 1; } else if (Element.IsPtCaptured(p, this.PointMinus)) { pDest = this.PointMinus; num = 2; } if (num == -1) { return -1; } if (e is TrackPassive) { foreach (Connection connection in base.m_Connections) { if (connection.IsConnected(this, e)) { return -1; } } foreach (Connection connection in base.m_Connections) { if (connection.IsConnectedPath(this, num) != null) { return -1; } } return num; } } return -1; }
public override int CanConnect(Point p, Element e, int nSource, out Point pDest) { pDest = this.m_BasePoint; return -1; }
public void AddElement(Element e) { Debug.Assert(this.m_alElTypes.Contains(e.GetType())); this.m_ElToAdd = e; this.m_ElToAdd.m_Layout = this.m_Layout; }
public override int CanConnect(Point p, Element e, int nSource, out Point pDest) { pDest = this.m_PointBase; if (e is Station) { foreach (Connection connection in base.m_Connections) { if (connection.IsConnected(this, e)) { return -1; } } } return this.GetConnectionSourceID(p); }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is Connection); if (e is Connection) { this.m_PointCenter = (e as Connection).PointCenter; } }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is Perron); if (e is Perron) { this.BasePoint = (e as Perron).BasePoint; } }
public bool IsConnectedSource(Element e, int nSource) { return (((this.Element1 == e) && (this.Source1 == nSource)) || ((this.Element2 == e) && (this.Source2 == nSource))); }
public Element IsConnectedTo(Element e, int nSource, Type t) { if (((this.Element1 == e) && (this.Source1 == nSource)) && (this.Element2.GetType() == t)) { return this.Element2; } if (((this.Element2 == e) && (this.Source2 == nSource)) && (this.Element1.GetType() == t)) { return this.Element1; } return null; }
public PathElement IsConnectedPath(Element e, int nSource) { PathElement element = null; element = (PathElement) this.IsConnectedTo(e, nSource, typeof(Track)); if (element != null) { return element; } element = (PathElement) this.IsConnectedTo(e, nSource, typeof(PointSwitch)); if (element != null) { return element; } return (PathElement) this.IsConnectedTo(e, nSource, typeof(PointSimple)); }
public bool IsConnected(Element el1, Element el2) { return (((this.Element1 == el1) && (this.Element2 == el2)) || ((this.Element1 == el2) && (this.Element2 == el1))); }
public bool GetConnectedElement(Element eFor, out int nForElementSource, out Element e, out int nElementSource) { e = null; nElementSource = nForElementSource = -1; if (this.Element1 == eFor) { nForElementSource = this.Source1; e = this.Element2; nElementSource = this.Source2; return true; } if (this.Element2 == eFor) { nForElementSource = this.Source2; e = this.Element1; nElementSource = this.Source1; return true; } return false; }
public void UpdateElement(Element e) { this.Invalidate(); }
public override int CanConnect(Point p, Element e, int nSource, out Point pDest) { int connectionSourceID = -1; pDest = new Point(0.0, 0.0); if (e == this) { return -1; } connectionSourceID = this.GetConnectionSourceID(p); switch (connectionSourceID) { case 1: pDest = this.PointPeak; break; case 2: pDest = this.PointPlus; break; case 3: pDest = this.PointMinus; break; case -1: return -1; } if (e is Light) { foreach (Connection connection in base.m_Connections) { if (connection.IsConnectedTo(this, connectionSourceID, e.GetType()) != null) { return -1; } } return connectionSourceID; } if ((e is Perron) || (e is TrainNumberField)) { foreach (Connection connection in base.m_Connections) { if (connection.HasElement(e.GetType())) { return -1; } } return connectionSourceID; } if (!((e is Track) || (e is PointSwitchBase))) { return -1; } foreach (Connection connection in base.m_Connections) { if (connection.IsConnectedPath(this, connectionSourceID) != null) { return -1; } } return connectionSourceID; }
protected virtual bool FindActiveContext(Point p) { if (this.GetLayout() == null) { return false; } string toolTipText = ""; this.m_ActiveConnection = null; this.m_ActiveElement = null; if (!this.m_bReadOnly) { foreach (Connection connection in this.GetLayout().Connections) { if (connection.HasElement(this.m_alElTypes) && (connection.CanMove(p) != null)) { this.m_ActiveConnection = connection; toolTipText = this.m_ActiveConnection.GetToolTipText(true, p); break; } } } foreach (Element element in this.GetLayout().Elements) { if (this.m_alElTypes.Contains(element.GetType()) && (Element.IsPtCaptured(p, element.GetCenterPoint()) || (element.CanMove(p) != null))) { this.m_ActiveElement = element; if (toolTipText.Length == 0) { toolTipText = this.m_ActiveElement.GetToolTipText(!this.m_bReadOnly, p); } break; } } return ((this.m_ActiveConnection != null) || (this.m_ActiveElement != null)); }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is PointSwitchBase); if (e is PointSwitchBase) { this.PointCore = (e as PointSwitchBase).PointCore; this.PointPeak = (e as PointSwitchBase).PointPeak; this.PointMinus = (e as PointSwitchBase).PointMinus; this.PointPlus = (e as PointSwitchBase).PointPlus; } }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is IconElement); if (e is IconElement) { this.m_BasePoint = (e as IconElement).BasePoint; } }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is Light); if (e is Light) { this.PointLeg = (e as Light).PointLeg; } }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is Station); if (e is Station) { this.PointBase = (e as Station).PointBase; } }
public virtual int CanConnect(Point p, Element e, int nSource, out Point pDest) { pDest = new Point(0.0, 0.0); return -1; }
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is TrackPassive); if (e is TrackPassive) { this.PointPlus = (e as TrackPassive).PointPlus; this.PointMinus = (e as TrackPassive).PointMinus; } }
public abstract void CopyLocationInfoFrom(Element e);
public override void CopyLocationInfoFrom(Element e) { Debug.Assert(e is DisplayBase); if (e is DisplayBase) { this.m_BasePoint = (e as DisplayBase).BasePoint; } }
public Element GetConnectedElement(Element e) { if (this.Element1 == e) { return this.Element2; } if (this.Element2 == e) { return this.Element1; } return null; }