示例#1
0
        protected override bool OnDragOver(DragEventArgs args)
        {
            if (this.dragSource == null)
            {
                this.dragSource = Enumerable.First <IDragSource>(DragSourceHelper.DataOfType <IDragSource>(args.Data));
                this.dragSource.GiveFeedback += new GiveFeedbackEventHandler(this.DragSourceGiveFeedback);
            }
            this.dragCursor = (Cursor)null;
            args.Effects    = DragDropEffects.None;
            DataBindingDragDropModel dragFeedback = this.GetDragFeedback(args);

            if (dragFeedback == null || !dragFeedback.CheckDropFlags(DataBindingDragDropFlags.SetBinding | DataBindingDragDropFlags.CreateElement, false))
            {
                this.previewHighlighter.Option = HighlightOption.Default;
                this.previewHighlighter.InsertionPointPreview = (ISceneInsertionPoint)null;
                this.FeedbackAdorner.Text = string.Empty;
                this.FeedbackAdorner.CloseAdorner();
                base.OnDragOver(args);
                return(true);
            }
            if (dragFeedback.CheckDropFlags(DataBindingDragDropFlags.CreateElement))
            {
                if (!((SceneElement)dragFeedback.TargetNode).IsEffectiveRoot)
                {
                    this.previewHighlighter.Option = HighlightOption.Insert;
                    this.previewHighlighter.InsertionPointPreview = (ISceneInsertionPoint)dragFeedback.InsertionPoint;
                }
                else
                {
                    this.previewHighlighter.Option = HighlightOption.Default;
                    this.previewHighlighter.InsertionPointPreview = (ISceneInsertionPoint)null;
                }
                args.Effects    = DragDropEffects.Copy;
                this.dragCursor = DataBindingModeModel.Instance.NormalizedMode != DataBindingMode.Details ? ToolCursors.DataBindingMasterAddCursor : ToolCursors.DataBindingDetailsAddCursor;
            }
            else
            {
                this.previewHighlighter.Option = HighlightOption.Preview;
                this.previewHighlighter.InsertionPointPreview = (ISceneInsertionPoint)dragFeedback.InsertionPoint;
                args.Effects    = DragDropEffects.Move;
                this.dragCursor = DataBindingModeModel.Instance.NormalizedMode != DataBindingMode.Details ? ToolCursors.DataBindingMasterCursor : ToolCursors.DataBindingDetailsCursor;
            }
            if (DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details)
            {
                this.FeedbackAdorner.Background = this.detailsBackground;
            }
            else
            {
                this.FeedbackAdorner.Background = this.masterBackground;
            }
            this.FeedbackAdorner.Text = dragFeedback.Tooltip;
            this.SetTextCuePosition(args.GetPosition((IInputElement)this.ActiveView.Artboard.ContentArea));
            this.FeedbackAdorner.DrawAdorner(this.OpenFeedback());
            this.CloseFeedback();
            DataBindingToolBehavior.PokeWpfToRefresh();
            base.OnDragOver(args);
            return(true);
        }
示例#2
0
        private void ApplyRules(DataBindingDragDropFlags filteredDragFlags)
        {
            this.ApplyRulesInternal(this.DragModel, filteredDragFlags);
            if (!this.ShouldTryDropOnAncestorPanel(filteredDragFlags))
            {
                return;
            }
            DataBindingDragDropModel ancestorPanelModel = this.DragModel.AncestorPanelModel;

            if (ancestorPanelModel == null || ancestorPanelModel == this.DragModel)
            {
                return;
            }
            DataBindingDragDropFlags filteredDragFlags1 = filteredDragFlags & ~DataBindingDragDropFlags.SetBinding;

            this.ApplyRulesInternal(ancestorPanelModel, filteredDragFlags1);
            if (!ancestorPanelModel.CheckDropFlags(DataBindingDragDropFlags.CreateElement))
            {
                return;
            }
            this.DragModel = ancestorPanelModel;
        }
示例#3
0
        protected override bool OnDrop(DragEventArgs args)
        {
            this.previewHighlighter.Option = HighlightOption.Default;
            this.previewHighlighter.InsertionPointPreview = (ISceneInsertionPoint)null;
            this.FeedbackAdorner.CloseAdorner();
            DataBindingDragDropModel dragFeedback = this.GetDragFeedback(args);
            bool flag = false;

            if (dragFeedback != null && dragFeedback.CheckDropFlags(DataBindingDragDropFlags.SetBinding | DataBindingDragDropFlags.CreateElement, false))
            {
                Point position = args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer);
                this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
                Point artboardSnappedDropPoint = this.ToolBehaviorContext.SnappingEngine.SnapPoint(position, EdgeFlags.TopLeft) * this.ActiveView.GetComputedTransformFromRoot((SceneElement)dragFeedback.TargetNode);
                this.ToolBehaviorContext.SnappingEngine.Stop();
                flag = DataBindingDragDropManager.Drop(dragFeedback, artboardSnappedDropPoint);
            }
            if (!this.IsSuspended)
            {
                this.PopSelf();
            }
            return(flag);
        }