コード例 #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();
        }