Ejemplo n.º 1
0
        // Add new prototype
        public static bool AddPrototype(string shapeName, MyShape shape)
        {
            if (!prototypes.Keys.Contains(shapeName))
            {
                prototypes.Add(shapeName, shape);
                return true;
            }

            return false;
        }
Ejemplo n.º 2
0
 private void createNewShape(MouseButtonEventArgs e)
 {
     // Dùng lớp ShapeFactory để tạo ra đối tượng hình theo ý muốn.
     Point position = e.GetPosition(drawingCanvas);
     myShape = ShapeFactory.GetShape(shapeToDraw);
     myShape.StartPoint = position;
     myShape.EndPoint = position;
     myShape.Draw(drawingCanvas.Children);
 }
Ejemplo n.º 3
0
        private bool addAdornerWhenMouseUp(MouseButtonEventArgs e)
        {
            endPoint = e.GetPosition(drawingCanvas);
            if (selectedUIElement == null)
            {
                if (myShape == null)
                    return false;

                try
                {
                    if (myShape.DrawedElement == null)
                        return false;

                    AddAdorner(myShape.DrawedElement);
                    CommandManager.SnapCanvas(ref drawingCanvas);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "1");
                }
            }
            myShape = null;
            return true;
        }
Ejemplo n.º 4
0
 public static void AddShape(MyShape myShape)
 {
     shapeList.Add(myShape.Handle, myShape);
 }