private void OnLayerDragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.Copy) { return; } var fmts = e.Data.GetFormats(); if (fmts == null || fmts.Length != 1) { return; } LayerEffect effect = e.Data.GetData(fmts[0]) as LayerEffect; CurrentDragLayer = true; CurrentDrag = this; if (effect != null) { //effect.Layer = this._layer.Shape switch (effect.Type) { case EffectType.Entry: effect.Duration = this.ctlEntryEffect.Width == 0 ? 2 : ctlEntryEffect.Effect.Duration; break; case EffectType.Exit: effect.Duration = this.ctlExitEffect.Width == 0 ? 2 : ctlExitEffect.Effect.Duration; break; default: effect.Duration = this.ctlEmphasis.Width == 0 ? 8 : ctlEmphasis.Effect.Duration; break; } //if (effect.Duration == 0) // effect.Duration = 2;//ControlService.SignCombo.Current.Template.Message. 2; ////else //// effect.Duration++; UndoService.BeginTransaction(String.Format("Add a {0} effect", effect.Type)); UndoService.AddLayerEffectAddedAction(effect); AddEffectFromDragDrop(effect); UndoService.Commit(); ControlService.RefreshPropertyGrid(_layer); CurrentDragLayer = false; return; } LayerControl frameLayer = e.Data.GetData(typeof(LayerControl)) as LayerControl; if (frameLayer != null) { OnDragLayer(frameLayer); } EffectContainer.Invalidate(); }
private void MouseDown(object sender, MouseEventArgs e) { UndoService.BeginTransaction("Effect mouse down event."); if (e.Button == MouseButtons.Left) { _lastPoint.X = Cursor.Position.X; _lastPoint.Y = Cursor.Position.Y; } UndoService.AddAction(new EffectMouseEventAction(_layerCtrl)); }
public override void OnMouseDown(Canvas drawArea, MouseEventArgs e) { UndoService.BeginTransaction("Add a line"); Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); SignType sign = drawArea.MessageControl.Sign.Type; int zoom = drawArea.Document.Zoom; Point s = p.PointMultiplyDouble(1d / zoom); ShapeLine line = new ShapeLine(zoom, s, new Point(s.X + 1, s.Y + 1), drawArea.Document.CurrentShapePaintInfo, sign); AddNewObject(drawArea, line); }
/// <summary> /// paste /// </summary> public void Paste() { if (CanPaste) { UndoService.BeginTransaction("Paste"); if (DoPaste()) { UndoService.Commit(); } else { UndoService.Current.Rollback(); } } }
public override void OnMouseDown(Canvas drawArea, MouseEventArgs e) { UndoService.BeginTransaction("Add a Rectangle"); Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); ShapeRectangle shapeRectangle = new ShapeRectangle( drawArea.Document.Zoom , p.X , p.Y , 1 , 1 , drawArea.Document.CurrentShapePaintInfo , drawArea.MessageControl.Sign.Type); AddNewObject(drawArea, shapeRectangle); }
/// <summary> /// Delete Exit Effect /// add by Terry /// </summary> private ToolStripMenuItem DeleteExitEffect() { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = "Delete Exit Effect"; item.Image = Resource.GetImage(Resource.Images.DeleteExitEffect); item.Click += delegate { UndoService.BeginTransaction("Delete a exit effect"); LayerEffect effect = FrameLayer.ExitEffect.Real.Copy(); //FrameLayer.ExitEffect.Name = null; FrameLayer.RemoveEffect(effect.Type); UndoService.AddLayerEffectRemovedAction(FrameLayer, effect); FrameLayer.Invalidate(); UndoService.Commit(); }; Items.Add(item); return(item); }
void OnEffectPropertyChanged(object sender, ProWrite.Entity.PropertyChangedEventArgs e) { UndoService.BeginTransaction("Changed the " + e.Name + " Property"); UndoService.AddPropertyChangedAction(sender, e.Name, e.NewValue, e.OldValue); UndoService.Commit(); }
public override void OnMouseDown(Canvas drawArea, MouseEventArgs e) { Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (e.Button == MouseButtons.Left) { if (e.Button == MouseButtons.Left) { if (drawArea.ShortcutKey == Keys.Control || drawArea.ShortcutKey == Keys.Shift) { selectMode = SelectionMode.MulitSelection; for (int i = drawArea.Document.Count - 1; i >= 0; i--) { int handleNumber = drawArea.Document[i].HitTest(point); if (handleNumber == 0) { drawArea.Document[i].IsSelected = !drawArea.Document[i].IsSelected; break; } } return; } } wasMove = false; selectMode = SelectionMode.None; // Test for resizing for (int i = drawArea.Document.Count - 1; i >= 0; i--) { int handleNumber = drawArea.Document[i].HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; UndoService.BeginTransaction("Resize the shape"); resizedObject = drawArea.Document[i]; resizedObjectHandle = handleNumber; drawArea.Document.CancelSelect(); drawArea.Document[i].IsSelected = true; break; } } // Test for move if (selectMode == SelectionMode.None) { ShapeBase so = null; for (int i = drawArea.Document.Count - 1; i >= 0; i--) { if (drawArea.Document[i].HitTest(point) == 0) { so = drawArea.Document[i]; break; } } if (so != null) { UndoService.BeginTransaction("Move the shape"); selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !so.IsSelected) { drawArea.Document.CancelSelect(true); } // Select clicked object int paintcount = drawArea.Document.ShapeDraw.SelectedShapes.Length; int textcount = (from shape in drawArea.Document where shape.IsSelected && (shape.Type == ShapeType.Text || shape.Type == ShapeType.Time || shape.Type == ShapeType.Temperature || shape.Type == ShapeType.DynamicText) select shape).Count(); LayerControl lc = null; if (so is ShapePaint && paintcount > 0) { so.BeginEdit(); //foreach (ShapeBase sb in drawArea.Document.ShapeDraw.SelectedShapes) // sb.IsSelected = false; so.IsSelected = true; so.EndEdit(); lc = drawArea.MessageControl.GetLayerControl(so); if (lc != null) { lc.IsSelected = so.IsSelected; } } else if ((so.Type == ShapeType.Text || so.Type == ShapeType.Time || so.Type == ShapeType.Temperature || so.Type == ShapeType.DynamicText) && textcount > 0) { so.BeginEdit(); so.IsSelected = true; so.EndEdit(); lc = drawArea.MessageControl.GetLayerControl(so); if (lc != null) { lc.IsSelected = so.IsSelected; } } else { so.IsSelected = true; } drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { //click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.Document.CancelSelect(true); } selectMode = SelectionMode.NetSelection; UndoService.BeginTransaction("Select some shapes"); drawArea.DrawNetRectangle = true; } lastPoint = point; startPoint = point; } else if (e.Button == MouseButtons.Right) { //drawArea.Document.CancelSelect(true); //for (int i = drawArea.Document.Count -1; i >= 0; i--) //{ // if (drawArea.Document[i].HitTest(point) >= 0) // { // drawArea.Document[i].IsSelected = true; // break; // } //} bool emptyInsect = false; foreach (ShapeBase s in drawArea.Document) { if (s.HitTest(point) >= 0) { emptyInsect = true; break; } } if (!emptyInsect) { drawArea.Document.CancelSelect(true); } } drawArea.Capture = true; drawArea.NetRectangle = ShapeControlPaintNew.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); }