Пример #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();
     }
 }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }
Пример #5
0
 public override int CanConnect(Point p, Element e, int nSource, out Point pDest)
 {
     pDest = this.m_BasePoint;
     return -1;
 }
Пример #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;
 }
Пример #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);
 }
Пример #8
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Connection);
     if (e is Connection)
     {
         this.m_PointCenter = (e as Connection).PointCenter;
     }
 }
Пример #9
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Perron);
     if (e is Perron)
     {
         this.BasePoint = (e as Perron).BasePoint;
     }
 }
Пример #10
0
 public bool IsConnectedSource(Element e, int nSource)
 {
     return (((this.Element1 == e) && (this.Source1 == nSource)) || ((this.Element2 == e) && (this.Source2 == nSource)));
 }
Пример #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;
 }
Пример #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));
 }
Пример #13
0
 public bool IsConnected(Element el1, Element el2)
 {
     return (((this.Element1 == el1) && (this.Element2 == el2)) || ((this.Element1 == el2) && (this.Element2 == el1)));
 }
Пример #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;
 }
Пример #15
0
 public void UpdateElement(Element e)
 {
     this.Invalidate();
 }
Пример #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;
        }
Пример #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));
 }
Пример #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;
     }
 }
Пример #19
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is IconElement);
     if (e is IconElement)
     {
         this.m_BasePoint = (e as IconElement).BasePoint;
     }
 }
Пример #20
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Light);
     if (e is Light)
     {
         this.PointLeg = (e as Light).PointLeg;
     }
 }
Пример #21
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is Station);
     if (e is Station)
     {
         this.PointBase = (e as Station).PointBase;
     }
 }
Пример #22
0
 public virtual int CanConnect(Point p, Element e, int nSource, out Point pDest)
 {
     pDest = new Point(0.0, 0.0);
     return -1;
 }
Пример #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;
     }
 }
Пример #24
0
 public abstract void CopyLocationInfoFrom(Element e);
Пример #25
0
 public override void CopyLocationInfoFrom(Element e)
 {
     Debug.Assert(e is DisplayBase);
     if (e is DisplayBase)
     {
         this.m_BasePoint = (e as DisplayBase).BasePoint;
     }
 }
Пример #26
0
 public Element GetConnectedElement(Element e)
 {
     if (this.Element1 == e)
     {
         return this.Element2;
     }
     if (this.Element2 == e)
     {
         return this.Element1;
     }
     return null;
 }