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; } }
protected override void GhostDrawingComplete() { 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); }
protected override void GhostDrawingComplete() { try { SimpleRectangle shape = new SimpleRectangle(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); }
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"; shape.ShapeColor = Color.WhiteSmoke; 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); }
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"; shape.ShapeColor = Color.WhiteSmoke; 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); }
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 (DragHelp.DraggedShape != null) { shape = DragHelp.DraggedShape; Netron.NetronLight.DragHelp.DraggedShape = null; } else 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; } } } else 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; } }