Beispiel #1
0
        /// <summary>
        /// Insert an existing rung under an anchor rung
        /// </summary>
        /// <param name="rung">Rung  to be inserted</param>
        /// <param name="anchor">Anchor rung</param>
        public void InsertUnder(RungUI rung, RungUI anchor)
        {
            if (rung == null)
            {
                throw new ArgumentException("Null rung", "rung");
            }
            if (anchor == null)
            {
                throw new ArgumentException("Null rung", "anchor");
            }
            if (anchor == rung)
            {
                throw new ArgumentException("Anchor rung and new rung are the same", "anchor");
            }

            LogicalDiagram.InsertUnder(rung.LogicalRung, anchor.LogicalRung);

            int anchorIndex = Rungs.IndexOf(anchor);

            if (anchorIndex != -1)
            {
                Rungs.Insert(anchorIndex + 1, rung);
                rung.DataTable = DataTable;
            }
            else
            {
                throw new ArgumentException("Anchor rung is not inserted in current diagram", "anchor");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Add an existing rung in the bottom of the diagram
        /// </summary>
        /// <param name="rung">Rung to be inserted</param>
        public void Add(RungUI rung)
        {
            if (rung == null)
            {
                throw new ArgumentException("Null rung", "rung");
            }

            Rungs.Add(rung);
            LogicalDiagram.Add(rung.LogicalRung);
            rung.DataTable = DataTable;
        }
Beispiel #3
0
        /// <summary>
        /// Remove a rung from the ladder diagram
        /// </summary>
        /// <param name="rung">Rung to be removed</param>
        public void Remove(RungUI rung)
        {
            if (rung == null)
            {
                throw new ArgumentException("Null rung", "rung");
            }

            if (Rungs.Contains(rung))
            {
                Rungs.Remove(rung);
                LogicalDiagram.Rungs.Remove(rung.LogicalRung);
            }
            else
            {
                throw new ArgumentException("Rung is not inserted in current diagram", "rung");
            }
        }
Beispiel #4
0
 /// <summary>
 /// Insert a new rung above the anchor rung
 /// </summary>
 /// <param name="anchor">Anchor rung</param>
 public void InsertAbove(RungUI anchor)
 {
     InsertAbove(new RungUI(), anchor);
 }
Beispiel #5
0
 /// <summary>
 /// Insert a new rung under the anchor rung
 /// </summary>
 /// <param name="anchor">Anchor rung</param>
 public void InsertUnder(RungUI anchor)
 {
     InsertUnder(new RungUI(), anchor);
 }