示例#1
0
 //This button resizes the selected shapes or group according to what is entered in the text boxes
 private void Resize_Click(object sender, RoutedEventArgs e)
 {
     if (RHeight.Text != "" && RWidth.Text != "")
     {
         foreach (int c in selected)
         {
             Composite newcomposite  = group.FindID(c).Copy();
             Resize    resizeAction  = new Resize(newcomposite, Convert.ToDouble(RHeight.Text), Convert.ToDouble(RWidth.Text));
             Replace   replaceAction = new Replace(group, newcomposite, c);
             actionmanager.takeAction(resizeAction);
             actionmanager.takeAction(replaceAction);
             actionmanager.executeActions();
         }
         Update(true);
         Update(false);
     }
 }
示例#2
0
 private void mouseMove(object sender, PointerRoutedEventArgs e)
 {
     //If the move tool is selected, this makes it possible to drag a selection
     if (tool == "Move" && dragStart != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         timeindex--;;
         Update(false);
         var p2 = e.GetCurrentPoint(paintSurface);
         foreach (int tag in selected)
         {
             Composite tmp           = group.FindID(tag).Copy();
             Move      moveAction    = new Move(tmp, p2.Position.X - dragStart.Position.X, p2.Position.Y - dragStart.Position.Y);
             Replace   replaceAction = new Replace(group, tmp, tag);
             actionmanager.takeAction(moveAction);
             actionmanager.takeAction(replaceAction);
         }
         actionmanager.executeActions();
         Update(true);
         Update(false);
     }
     //If the rectangle or ellipse tool is selected, then this creates the shape
     else if ((tool == "Rectangle" || tool == "Ellipse") && dragStart != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         Undo_Click(sender, e);
         itemcount++;
         Composite newshape = new Composite(itemcount, tool);
         newshape.height = Math.Abs(dragStart.Position.Y - e.GetCurrentPoint(paintSurface).Position.Y);
         newshape.width  = Math.Abs(dragStart.Position.X - e.GetCurrentPoint(paintSurface).Position.X);
         newshape.x      = ReturnSmallest(dragStart.Position.X, e.GetCurrentPoint(paintSurface).Position.X);
         newshape.y      = ReturnSmallest(dragStart.Position.Y, e.GetCurrentPoint(paintSurface).Position.Y);
         Add addAction = new Add(group, newshape);
         actionmanager.takeAction(addAction);
         actionmanager.executeActions();
         Update(true);
         Update(false);
     }
 }