Example #1
0
 void boxClicked(Box box, MouseButtonEventArgs e)
 {
     if (selectedBox == null)
     {
         selectedBox = box;
         selectedBox.rect.Fill = selectedBrush;
     }
     else
     {
         edges.Add(new Edge { From = selectedBox, To = box });
         selectedBox.rect.Fill = normalBrush;
         selectedBox = null;
     }
     e.Handled = true;
     Redraw();
 }
Example #2
0
 void canvas_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (selectedBox != null)
     {
         selectedBox.rect.Fill = normalBrush;
         selectedBox.Left = Mouse.GetPosition(canvas).X;
         selectedBox.Top = Mouse.GetPosition(canvas).Y;
         selectedBox = null;
     }
     Redraw();
 }
Example #3
0
 void RandomizeBoxes()
 {
     Random r = new Random();
     for (int i = 0; i < numRect; i++) {
         Box box = new Box(r.Next(0, (int)canvas.ActualWidth - 100), r.Next(0, (int)canvas.ActualHeight - 100), 60, 90);
         boxes.Add(box);
         box.rect.Fill = normalBrush;
         box.rect.MouseUp += delegate(object s, MouseButtonEventArgs eA) { boxClicked(box, eA); };
     }
 }