Esempio n. 1
0
 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();
     }
 }
Esempio n. 2
0
 public bool GetConnectedElement(Element eFor, out Element e, out int nElementSource)
 {
     int num;
     return this.GetConnectedElement(eFor, out num, out e, out nElementSource);
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 public override int CanConnect(Point p, Element e, int nSource, out Point pDest)
 {
     pDest = this.m_BasePoint;
     return -1;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Connection);
     if (e is Connection)
     {
         this.m_PointCenter = (e as Connection).PointCenter;
     }
 }
Esempio n. 9
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Perron);
     if (e is Perron)
     {
         this.BasePoint = (e as Perron).BasePoint;
     }
 }
Esempio n. 10
0
 public bool IsConnectedSource(Element e, int nSource)
 {
     return (((this.Element1 == e) && (this.Source1 == nSource)) || ((this.Element2 == e) && (this.Source2 == nSource)));
 }
Esempio n. 11
0
 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;
 }
Esempio n. 12
0
 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));
 }
Esempio n. 13
0
 public bool IsConnected(Element el1, Element el2)
 {
     return (((this.Element1 == el1) && (this.Element2 == el2)) || ((this.Element1 == el2) && (this.Element2 == el1)));
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 public void UpdateElement(Element e)
 {
     this.Invalidate();
 }
Esempio n. 16
0
        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;
        }
Esempio n. 17
0
 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));
 }
Esempio n. 18
0
 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;
     }
 }
Esempio n. 19
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is IconElement);
     if (e is IconElement)
     {
         this.m_BasePoint = (e as IconElement).BasePoint;
     }
 }
Esempio n. 20
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Light);
     if (e is Light)
     {
         this.PointLeg = (e as Light).PointLeg;
     }
 }
Esempio n. 21
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Station);
     if (e is Station)
     {
         this.PointBase = (e as Station).PointBase;
     }
 }
Esempio n. 22
0
 public virtual int CanConnect(Point p, Element e, int nSource, out Point pDest)
 {
     pDest = new Point(0.0, 0.0);
     return -1;
 }
Esempio n. 23
0
 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;
     }
 }
Esempio n. 24
0
 public abstract void CopyLocationInfoFrom(Element e);
Esempio n. 25
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is DisplayBase);
     if (e is DisplayBase)
     {
         this.m_BasePoint = (e as DisplayBase).BasePoint;
     }
 }
Esempio n. 26
0
 public Element GetConnectedElement(Element e)
 {
     if (this.Element1 == e)
     {
         return this.Element2;
     }
     if (this.Element2 == e)
     {
         return this.Element1;
     }
     return null;
 }