Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Remove all rungs from the diagram
 /// </summary>
 public void Clear()
 {
     Rungs.Clear();
     LogicalDiagram.Clear();
 }