コード例 #1
0
        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();
        }
コード例 #2
0
 /// <summary>
 /// paste
 /// </summary>
 public void Paste()
 {
     if (CanPaste)
     {
         UndoService.BeginTransaction("Paste");
         if (DoPaste())
         {
             UndoService.Commit();
         }
         else
         {
             UndoService.Current.Rollback();
         }
     }
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 public override void OnMouseUp(Canvas drawArea, MouseEventArgs e)
 {
     UndoService.Commit();
 }
コード例 #5
0
 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();
 }
コード例 #6
0
            private void MouseUp(object sender, MouseEventArgs e)
            {
                _layerCtrl.OnLayerMouseUp(sender, e);

                UndoService.Commit();
            }
コード例 #7
0
        //mouse button is released
        public override void OnMouseUp(Canvas drawArea, MouseEventArgs e)
        {
            if (selectMode == SelectionMode.MulitSelection)
            {
                return;
            }

            int zoom = drawArea.Document.Zoom;

            if (selectMode == SelectionMode.NetSelection)
            {
                // Group selection
                drawArea.Document.SelectInRectangle(drawArea.NetRectangle);

                selectMode = SelectionMode.None;
                drawArea.DrawNetRectangle = false;

                UndoService.Commit();
            }
            if (resizedObject != null ||
                selectMode == SelectionMode.Size
                )
            {
                // after resizing
                if (resizedObject != null)
                {
                    resizedObject.BeginEdit();
                    if (resizedObject is ShapePaint)
                    {
                        ; // resizedObject.SetVirtualBounds();
                    }
                    else
                    {
                        resizedObject.VirtualBounds = resizedObject.FormatBoundsByZoom(resizedObject.VirtualBounds, zoom);
                    }

                    resizedObject.EndEdit();
                    resizedObject = null;
                }

                selectMode = SelectionMode.None;
                UndoService.Commit();
            }

            if (selectMode == SelectionMode.Move)
            {
                foreach (ShapeBase sb in drawArea.Document.SelectedShapes)
                {
                    sb.BeginEdit();
                    if (sb is ShapeFigure
                        //|| sb is ShapeLine
                        )
                    {
                        sb.SetVirtualBounds();
                    }
                    else if (sb.Type != ShapeType.Line)
                    {
                        sb.VirtualBounds = sb.FormatBoundsByZoom(sb.VirtualBounds, zoom);
                    }

                    sb.EndEdit();
                }
                selectMode = SelectionMode.None;

                Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                for (int i = drawArea.Document.Count - 1; i >= 0; i--)
                {
                    if (drawArea.Document[i].HitTest(point) == 0)
                    {
                        ShapeBase so = drawArea.Document[i];
                        if (so != null)
                        {
                            // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                            if ((Control.ModifierKeys != Keys.Control || Control.ModifierKeys != Keys.Shift) && so.IsSelected && startPoint == lastPoint)
                            {
                                drawArea.Document.CancelSelect(true);
                                so.IsSelected = true;
                            }
                        }
                        break;
                    }
                }

                UndoService.Commit();
            }

            drawArea.Capture = false;
            drawArea.Refresh();
            lastPoint = drawArea.BackTrackMouse(e.Location);
        }