Example #1
0
 /// <summary>
 /// Metoda aktualizująca rozmieszczenie każdej z linii po przemieszczeniu bloku
 /// </summary>
 /// <param name="listBlocks"></param>
 public void MyUpdate(ref ListCanvasBlocks listBlocks)
 {
     if (listBlocks.Count > 0)
     {
         for (int i = 0; i < Count; i++)
         {
             var temp1 = listBlocks.TryGetElementWithId(this[i].BeginId);
             var temp2 = listBlocks.TryGetElementWithId(this[i].EndId);
             //if (temp1 == null || temp2 == null)
             //{
             //    this.RemoveAt(i);
             //    i--;
             //    continue;
             //}
             if (temp1.Shape == Helper.Shape.Decision)
             {
                 this[i].BeginPoint = (this[i].IsTrue)?temp1.PointOutput1:temp1.PointOutput2;
             }
             else
             {
                 this[i].BeginPoint = temp1.PointOutput1;
             }
             this[i].EndPoint = temp2.PointInput;
         }
     }
 }
Example #2
0
        /// <summary>
        /// Metoda dodająca linię do listy
        /// </summary>
        /// <param name="e"></param>
        /// <param name="shapeToDraw"></param>
        /// <param name="listBlocks"></param>
        public void MyAdd(Point e, ref Helper.Shape shapeToDraw, ref ListCanvasBlocks listBlocks)
        {
            var temp = listBlocks.TryGetElementContainingPoint(e);

            if (temp != null)
            {
                if (Count > 0 && base[0].EndPoint == Point.Empty) //input
                {
                    if (temp.Shape == Helper.Shape.Start)         //start nie może mieć wejscia
                    {
                        MessageBox.Show("Blok startu nie może mieć linii wejścia");
                    }
                    else if (this[0].BeginId == temp.ID) //wyjscie na wejscie - zapetlenie
                    {
                        MessageBox.Show("Nie możesz połączyć wyjścia bloku z jego wejściem - Zapętlenie");
                    }
                    else
                    {
                        this[0].EndPoint = temp.PointInput;
                        this[0].EndId    = temp.ID;
                        UndoRedo.Push(new List <UndoRedoItem>()
                        {
                            new UndoRedoItem(MyAction.Add, null, this.ToListHistory(0))
                        });
                        shapeToDraw = Helper.Shape.Nothing;
                    }
                }
                else //output
                {
                    if (temp.Shape == Helper.Shape.End)//start nie może mieć wejscia
                    {
                        MessageBox.Show("Blok Końca nie może mieć linii wyjścia");
                    }
                    else if (temp.Shape == Helper.Shape.Decision)
                    {
                        DialogResult dialogResult =
                            MessageBox.Show("Czy ma być to linia dla prawdy (true)", "", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            OverrideLine(false, temp);
                            Insert(0, new MyLine(temp.PointOutput1, temp.ID, true));
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                            OverrideLine(true, temp);
                            Insert(0, new MyLine(temp.PointOutput2, temp.ID, false));
                        }
                    }
                    else
                    {
                        OverrideLine(false, temp);
                        Insert(0, new MyLine(temp.PointOutput1, temp.ID));
                    }
                }
            }
        }