Пример #1
0
    /// <summary>
    /// This method will be called when the user has finished drawing a ghost rectangle or bundle
    /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
    /// </summary>
    protected override void GhostDrawingComplete() {
      if ((IsActive == false) ||
          (started == false)) {
        return;
      }

      try {
        SimpleEllipse shape = new SimpleEllipse(this.Controller.Model);
        shape.Width = (int)Rectangle.Width;
        shape.Height = (int)Rectangle.Height;
        AddShapeCommand cmd = new AddShapeCommand(
            this.Controller,
            shape,
            new Point((int)Rectangle.X, (int)Rectangle.Y));
        this.Controller.UndoManager.AddUndoCommand(cmd);
        cmd.Redo();
      }
      catch {
        base.Controller.DeactivateTool(this);
        Controller.View.Invalidate();
        throw;
      }

      //base.Controller.DeactivateTool(this);
    }
Пример #2
0
        /// <summary>
        /// This method will be called when the user has finished drawing a ghost rectangle or bundle
        /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
        /// </summary>
        protected override void GhostDrawingComplete()
        {
            if ((IsActive == false) ||
                (started == false))
            {
                return;
            }

            try {
                SimpleEllipse shape = new SimpleEllipse(this.Controller.Model);
                shape.Width  = (int)Rectangle.Width;
                shape.Height = (int)Rectangle.Height;
                AddShapeCommand cmd = new AddShapeCommand(
                    this.Controller,
                    shape,
                    new Point((int)Rectangle.X, (int)Rectangle.Y));
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
            }
            catch {
                base.Controller.DeactivateTool(this);
                Controller.View.Invalidate();
                throw;
            }

            //base.Controller.DeactivateTool(this);
        }
    /// <summary>
    /// This method will be called when the user has finished drawing a ghost rectangle or bundle
    /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
    /// </summary>
    protected override void GhostDrawingComplete() {

      try {
        ComplexRectangle shape = new ComplexRectangle(this.Controller.Model);
        shape.Width = (int)Rectangle.Width;
        shape.Height = (int)Rectangle.Height;
        AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, new Point((int)Rectangle.X, (int)Rectangle.Y));
        this.Controller.UndoManager.AddUndoCommand(cmd);
        cmd.Redo();
      }
      catch {
        base.Controller.DeactivateTool(this);
        Controller.View.Invalidate();
        throw;
      }

      //base.Controller.DeactivateTool(this);
    }
        /// <summary>
        /// This method will be called when the user has finished drawing a ghost rectangle or bundle
        /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
        /// </summary>
        protected override void GhostDrawingComplete()
        {
            try {
                ComplexRectangle shape = new ComplexRectangle(this.Controller.Model);
                shape.Width  = (int)Rectangle.Width;
                shape.Height = (int)Rectangle.Height;
                AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, new Point((int)Rectangle.X, (int)Rectangle.Y));
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
            }
            catch {
                base.Controller.DeactivateTool(this);
                Controller.View.Invalidate();
                throw;
            }

            //base.Controller.DeactivateTool(this);
        }
Пример #5
0
        /// <summary>
        /// On dragdrop.
        /// </summary>
        /// <param name="e">The <see cref="T:KeyEventArgs"/> instance containing the event data.</param>
        public void OnDragDrop(DragEventArgs e)
        {
            Control     control     = (Control)this.Controller.ParentControl;
            Point       p           = control.PointToClient(new Point(e.X, e.Y));
            IShape      shape       = null;
            IDataObject iDataObject = e.Data;

            if (iDataObject.GetDataPresent(typeof(string)))
            {
                foreach (string shapeType in Enum.GetNames(typeof(ShapeTypes)))
                {
                    if (shapeType.ToString().ToLower() == iDataObject.GetData(typeof(string)).ToString().ToLower())
                    {
                        shape = ShapeFactory.GetShape(shapeType);
                        break;
                    }
                }
            }

            if (iDataObject.GetDataPresent(typeof(Bitmap)))
            {
                return;
            }

            if (shape != null)
            {
                shape.Move(new Point(p.X, p.Y));


                //ComplexRectangle shape = new ComplexRectangle();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                //TextLabel shape = new TextLabel();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, p);
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
                feedbackCursor = null;
            }
        }
Пример #6
0
        /// <summary>
        /// This method will be called when the user has finished drawing a ghost rectangle or bundle
        /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
        /// </summary>
        protected override void GhostDrawingComplete()
        {
            try
            {
                TextOnly shape = new TextOnly(this.Controller.Model);
                shape.Width = (int) Rectangle.Width;
                shape.Height = (int) Rectangle.Height;
                shape.Text = "New label";

                AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, new Point((int) Rectangle.X, (int)Rectangle.Y));
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
                TextEditor.GetEditor(shape);
                TextEditor.Show();
            }
            catch
            {
                base.Controller.DeactivateTool(this);
                Controller.View.Invalidate();
                throw;
            }

            base.Controller.DeactivateTool(this);
        }
Пример #7
0
    /// <summary>
    /// On dragdrop.
    /// </summary>
    /// <param name="e">The <see cref="T:KeyEventArgs"/> instance containing the event data.</param>
    public bool OnDragDrop(DragEventArgs e) {
      Control control = (Control)this.Controller.ParentControl;
      Point p = control.PointToClient(new Point(e.X, e.Y));
      IShape shape = null;
      IDataObject iDataObject = e.Data;
      string text;

      if (iDataObject.GetDataPresent("IShape")) {
        shape = (IShape)iDataObject.GetData("IShape");
        shape.Model = Controller.Model;
      } else if (iDataObject.GetDataPresent(typeof(string))) {
        text = iDataObject.GetData(
                typeof(string)).ToString();

        //foreach (string shapeType in Enum.GetNames(typeof(ShapeTypes)))
        //{
        //    if (shapeType.ToString().ToLower() == text.ToLower())
        //    {
        //        shape = ShapeFactory.GetShape(shapeType);
        //        break;
        //    }
        //}

        // If our shape is still null, then the text being dragged
        // onto the canvas is not the name of a shape, so add a
        // TextOnly shape with the text.
        //if (shape == null)
        //{
        //    shape = new TextOnly(Controller.Model);
        //    (shape as TextOnly).Text = text;
        //}

        shape = new TextOnly(Controller.Model);
        (shape as TextOnly).Text = text;
      } else if (iDataObject.GetDataPresent(DataFormats.FileDrop)) {
        try {
          string[] files = (string[])iDataObject.GetData(
              DataFormats.FileDrop);

          foreach (string fileName in files) {
            FileInfo info = new FileInfo(fileName);

            if (info.Exists) {
              FileShape fileShape = new FileShape(fileName);
              AddShapeCommand cmd = new AddShapeCommand(
                  this.Controller,
                  fileShape,
                  p);
              this.Controller.UndoManager.AddUndoCommand(cmd);
              cmd.Redo();
              p.Offset(20, 20);
            }
          }

          feedbackCursor = null;
        }
        catch {
        }
      } else if (iDataObject.GetDataPresent(typeof(Bitmap))) {
        // Doesn't support dropping images yet - having problems
        // getting images off the clipboard.
        shape = new ImageShape(Controller.Model);
        (shape as ImageShape).Image =
            (Image)iDataObject.GetData(typeof(Bitmap));
        return true;
      }

      if (shape != null) {
        shape.MoveBy(new Point(p.X, p.Y));


        //ComplexRectangle shape = new ComplexRectangle();
        //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
        //shape.Text = "Just an example, work in progress.";

        //TextLabel shape = new TextLabel();
        //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
        //shape.Text = "Just an example, work in progress.";

        AddShapeCommand cmd = new AddShapeCommand(
            this.Controller,
            shape,
            p);
        this.Controller.UndoManager.AddUndoCommand(cmd);
        cmd.Redo();
        feedbackCursor = null;
        return true;
      }

      // The drop event wasn't handled here.
      return false;
    }
Пример #8
0
        /// <summary>
        /// On dragdrop.
        /// </summary>
        /// <param name="e">The <see cref="T:KeyEventArgs"/> instance containing the event data.</param>
        public bool OnDragDrop(DragEventArgs e)
        {
            Control     control     = (Control)this.Controller.ParentControl;
            Point       p           = control.PointToClient(new Point(e.X, e.Y));
            IShape      shape       = null;
            IDataObject iDataObject = e.Data;
            string      text;

            if (iDataObject.GetDataPresent("IShape"))
            {
                shape       = (IShape)iDataObject.GetData("IShape");
                shape.Model = Controller.Model;
            }
            else if (iDataObject.GetDataPresent(typeof(string)))
            {
                text = iDataObject.GetData(
                    typeof(string)).ToString();

                //foreach (string shapeType in Enum.GetNames(typeof(ShapeTypes)))
                //{
                //    if (shapeType.ToString().ToLower() == text.ToLower())
                //    {
                //        shape = ShapeFactory.GetShape(shapeType);
                //        break;
                //    }
                //}

                // If our shape is still null, then the text being dragged
                // onto the canvas is not the name of a shape, so add a
                // TextOnly shape with the text.
                //if (shape == null)
                //{
                //    shape = new TextOnly(Controller.Model);
                //    (shape as TextOnly).Text = text;
                //}

                shape = new TextOnly(Controller.Model);
                (shape as TextOnly).Text = text;
            }
            else if (iDataObject.GetDataPresent(DataFormats.FileDrop))
            {
                try {
                    string[] files = (string[])iDataObject.GetData(
                        DataFormats.FileDrop);

                    foreach (string fileName in files)
                    {
                        FileInfo info = new FileInfo(fileName);

                        if (info.Exists)
                        {
                            FileShape       fileShape = new FileShape(fileName);
                            AddShapeCommand cmd       = new AddShapeCommand(
                                this.Controller,
                                fileShape,
                                p);
                            this.Controller.UndoManager.AddUndoCommand(cmd);
                            cmd.Redo();
                            p.Offset(20, 20);
                        }
                    }

                    feedbackCursor = null;
                }
                catch {
                }
            }
            else if (iDataObject.GetDataPresent(typeof(Bitmap)))
            {
                // Doesn't support dropping images yet - having problems
                // getting images off the clipboard.
                shape = new ImageShape(Controller.Model);
                (shape as ImageShape).Image =
                    (Image)iDataObject.GetData(typeof(Bitmap));
                return(true);
            }

            if (shape != null)
            {
                shape.MoveBy(new Point(p.X, p.Y));


                //ComplexRectangle shape = new ComplexRectangle();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                //TextLabel shape = new TextLabel();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                AddShapeCommand cmd = new AddShapeCommand(
                    this.Controller,
                    shape,
                    p);
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
                feedbackCursor = null;
                return(true);
            }

            // The drop event wasn't handled here.
            return(false);
        }
Пример #9
0
        /// <summary>
        /// On dragdrop.
        /// </summary>
        /// <param name="e">The <see cref="T:KeyEventArgs"/> instance containing the event data.</param>
        public void OnDragDrop(DragEventArgs e)
        {
            Control control = (Control)this.Controller.ParentControl;
            Point p = control.PointToClient(new Point(e.X, e.Y));
            IShape shape = null;
            IDataObject iDataObject = e.Data;

            if(iDataObject.GetDataPresent(typeof(string)))
            {
                foreach(string shapeType in Enum.GetNames(typeof(ShapeTypes)))
                {
                    if(shapeType.ToString().ToLower() == iDataObject.GetData(typeof(string)).ToString().ToLower())
                    {
                        shape = ShapeFactory.GetShape(shapeType);
                        break;
                    }
                }
            }

            if(iDataObject.GetDataPresent(typeof(Bitmap)))
            {

                return;

            }

            if(shape != null)
            {
                shape.Move(new Point(p.X, p.Y));

                //ComplexRectangle shape = new ComplexRectangle();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                //TextLabel shape = new TextLabel();
                //shape.Rectangle = new Rectangle(p.X, p.Y, 150, 70);
                //shape.Text = "Just an example, work in progress.";

                AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, p);
                this.Controller.UndoManager.AddUndoCommand(cmd);
                cmd.Redo();
                feedbackCursor = null;
            }
        }