Exemplo n.º 1
0
        public void OnDragBegin(DragBeginEventArgs e)
        {
            if (this.nodePath == null)
            {
                return;
            }
            List <DataSchemaItem> list1 = new List <DataSchemaItem>(Enumerable.OfType <DataSchemaItem>((IEnumerable)this.SelectionContext));

            if (list1.Count <= 0 || list1.Count != this.SelectionContext.Count || !list1.Contains(this))
            {
                return;
            }
            DataSchemaNode            parent         = list1[0].DataSchemaNode.Parent;
            DataSourceNode            dataSourceNode = list1[0].DataSourceNode;
            List <DataSchemaNodePath> list2          = new List <DataSchemaNodePath>();

            list2.Add(list1[0].nodePath.AbsolutePath);
            for (int index = 1; index < list1.Count; ++index)
            {
                if (parent != list1[index].DataSchemaNode.Parent || dataSourceNode != list1[index].DataSourceNode)
                {
                    return;
                }
                list2.Add(list1[index].nodePath.AbsolutePath);
            }
            DataSchemaNodePathCollection nodePathCollection = new DataSchemaNodePathCollection((IEnumerable <DataSchemaNodePath>)list2);

            using (DataBindingDragDropManager.GetDragDropToken())
            {
                int num = (int)DragSourceHelper.DoDragDrop(e.DragSource, (object)nodePathCollection, DragDropEffects.Copy | DragDropEffects.Move);
            }
        }
Exemplo n.º 2
0
        public override IDropAction CreateInstance(DragDropContext context)
        {
            this.CheckNullArgument((object)context, "context");
            TypeAsset result1 = (TypeAsset)null;

            if (DragSourceHelper.FirstDataOfType <TypeAsset>(context.Data, ref result1) && PlatformTypes.IsEffectType((ITypeId)result1.Type))
            {
                ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)result1, context);
                if (insertionPoint != null)
                {
                    return((IDropAction) new DropEffectAssetAction(result1, insertionPoint));
                }
            }
            DocumentNodeMarkerSortedList result2 = (DocumentNodeMarkerSortedList)null;

            if (DragSourceHelper.FirstDataOfType <DocumentNodeMarkerSortedList>(context.Data, ref result2) && result2.Count == 1)
            {
                DocumentNodeMarker marker = result2.MarkerAt(0);
                if (marker != null && marker.Node != null && PlatformTypes.IsEffectType((ITypeId)marker.Node.Type))
                {
                    SceneViewModel viewModel = context.Target.TimelineItemManager.ViewModel;
                    SceneNode      sceneNode = SceneNode.FromMarker <SceneNode>(marker, viewModel);
                    if (sceneNode != null)
                    {
                        ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)sceneNode, context);
                        if (insertionPoint != null)
                        {
                            return((IDropAction) new DropEffectSceneNodeAction(sceneNode, insertionPoint));
                        }
                    }
                }
            }
            return((IDropAction)null);
        }
Exemplo n.º 3
0
        private DataBindingDragDropModel GetDragFeedback(DragEventArgs args)
        {
            DataSchemaNodePathCollection result = (DataSchemaNodePathCollection)null;

            if (!DragSourceHelper.FirstDataOfType <DataSchemaNodePathCollection>(args.Data, ref result) || result == null)
            {
                return((DataBindingDragDropModel)null);
            }
            SceneNode sceneNode = (SceneNode)this.ActiveView.GetSelectableElementAtPoint(args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer), SelectionFor3D.None, false, false);

            if (sceneNode == null)
            {
                sceneNode = (SceneNode)this.ActiveSceneViewModel.FindPanelClosestToActiveEditingContainer();
                if (sceneNode == null)
                {
                    return((DataBindingDragDropModel)null);
                }
            }
            if (PlatformTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)sceneNode.Type))
            {
                sceneNode = sceneNode.GetLocalValueAsSceneNode(FrameworkTemplateElement.VisualTreeProperty);
                if (sceneNode == null)
                {
                    return((DataBindingDragDropModel)null);
                }
            }
            BindingSceneInsertionPoint insertionPoint = new BindingSceneInsertionPoint(sceneNode, (IProperty)null, -1);

            return(DataBindingDragDropManager.GetDragFeedback(result, insertionPoint, DataBindingDragDropFlags.ArtboardDefault, Keyboard.Modifiers));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        private static Asset GetAssetFromDropData(IDataObject dataObj)
        {
            Asset result = (Asset)null;

            if (DragSourceHelper.FirstDataOfType <Asset>(dataObj, ref result))
            {
                return(result);
            }
            return((Asset)null);
        }
Exemplo n.º 6
0
        private void HandleDragDelta(object sender, DragContainerEventArgs e)
        {
            // Don't actually start the drag unless the mouse has moved for enough away
            // from the initial MouseDown point.
            Point currentPoint = e.CurrentPosition;

            if (Math.Abs(currentPoint.X - dragStartPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
                Math.Abs(currentPoint.Y - dragStartPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
            {
                this.isMouseDown = false;

                // Since we have to have the data before the drag starts, we don't allow a drag for data that
                // is not cached to avoid blocking the UI while the data is fetched before the drag starts.
                if (IsDataAvailable())
                {
                    IsInDrag = true;

                    int width  = (int)this.RenderSize.Width;
                    int height = (int)this.RenderSize.Height;

                    RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96.0, 96.0, PixelFormats.Pbgra32); // TODO: use actual dpi.
                    rtb.Render(this);

                    ConstrainSize(ref width, ref height, 200);
                    BitmapSource ghostImage = ResizeImage(rtb, width, height);

                    this.CaptureMouse();
                    Point mousePoint = new Point(0.5 * width, 0.5 * height);

#if USE_STANDARD_DRAGDROP
                    var dataObject = new System.Windows.DataObject();
                    var items      = GetData();
                    foreach (var item in items)
                    {
                        dataObject.SetData(item.Key, item.Value);
                    }

                    DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Copy);
#else
                    try
                    {
                        DragSourceHelper.DoDragDrop(this, ghostImage, mousePoint, DragDropEffects.Copy, GetData());
                    }
                    catch (COMException)
                    {
                        // DragDropLib is buggy. Fail silently if this happens.
                    }
#endif

                    this.ReleaseMouseCapture();

                    IsInDrag = false;
                }
            }
        }
Exemplo n.º 7
0
 public override void OnDragBegin(DragBeginEventArgs e)
 {
     if (!e.Handled && this.TimelineTreeRow != null && (!this.TimelineTreeRow.IsEditingTitle && this.TimelineItem != null) && this.TimelineItem.CanDrag())
     {
         object dragData = this.TimelineItem.DragData;
         if (dragData != null)
         {
             int num = (int)DragSourceHelper.DoDragDrop((UIElement)this.TimelineTreeRow, dragData, DragDropEffects.All);
         }
         e.Handled = true;
     }
     base.OnDragBegin(e);
 }
Exemplo n.º 8
0
        private void DoDragDrop(UIElement sourceElement)
        {
            if (!this.isValid)
            {
                return;
            }
            ICommand startDragCommand = Asset.GetStartDragCommand((DependencyObject)sourceElement);

            if (startDragCommand != null)
            {
                startDragCommand.Execute((object)this);
            }
            int num = (int)DragSourceHelper.DoDragDrop(sourceElement, (object)this, DragDropEffects.All);
        }
        public override IDropAction CreateInstance(DragDropContext context)
        {
            this.CheckNullArgument((object)context, "context");
            DataSchemaNodePathCollection result = (DataSchemaNodePathCollection)null;

            if (DragSourceHelper.FirstDataOfType <DataSchemaNodePathCollection>(context.Data, ref result))
            {
                BindingSceneInsertionPoint insertionPoint = context.Target.GetInsertionPoint((object)result, context) as BindingSceneInsertionPoint;
                if (insertionPoint != null && insertionPoint.SceneNode != null)
                {
                    return((IDropAction) new DropBindingAction(result, insertionPoint));
                }
            }
            return((IDropAction)null);
        }
Exemplo n.º 10
0
        public override IDropAction CreateInstance(DragDropContext context)
        {
            this.CheckNullArgument((object)context, "context");
            Asset result = (Asset)null;

            if (DragSourceHelper.FirstDataOfType <Asset>(context.Data, ref result))
            {
                ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)result, context);
                if (insertionPoint != null)
                {
                    return((IDropAction) new DropAssetAction(result, insertionPoint));
                }
            }
            return((IDropAction)null);
        }
Exemplo n.º 11
0
        private void SetSource(TimelineDragDescriptor descriptor)
        {
            DocumentNodeMarkerSortedList result1 = (DocumentNodeMarkerSortedList)null;

            if (DragSourceHelper.FirstDataOfType <DocumentNodeMarkerSortedList>(descriptor.SourceObject, ref result1))
            {
                if (result1.Count == 1 && descriptor.TargetItem != null)
                {
                    if (!this.SetSource((object)descriptor.TargetItem.TimelineItemManager.ViewModel.GetSceneNode(result1.MarkerAt(0).Node)))
                    {
                        ;
                    }
                }
                else
                {
                    this.SourceName = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.DragMultipleItemsFormat, new object[1]
                    {
                        (object)result1.Count
                    });
                    this.SourceType = string.Empty;
                }
            }
            else
            {
                Asset result2 = (Asset)null;
                if (DragSourceHelper.FirstDataOfType <Asset>(descriptor.SourceObject, ref result2) && this.SetSource((object)result2))
                {
                    return;
                }
                DataSchemaNodePathCollection result3 = (DataSchemaNodePathCollection)null;
                if (DragSourceHelper.FirstDataOfType <DataSchemaNodePathCollection>(descriptor.SourceObject, ref result3))
                {
                    this.SetDataBinding(descriptor.UserData as DataBindingDragDropModel);
                }
                else
                {
                    this.SourceName = this.SourceType = string.Empty;
                }
            }
        }
Exemplo n.º 12
0
        public override IDropAction CreateInstance(DragDropContext context)
        {
            this.CheckNullArgument((object)context, "context");
            DocumentNodeMarkerSortedList result = (DocumentNodeMarkerSortedList)null;

            if (DragSourceHelper.FirstDataOfType <DocumentNodeMarkerSortedList>(context.Data, ref result))
            {
                ISceneInsertionPoint insertionPoint = this.GetInsertionPoint((object)result, context);
                if (insertionPoint != null)
                {
                    foreach (DocumentNodeMarker documentNodeMarker in result.Markers)
                    {
                        if (documentNodeMarker.Node != null && documentNodeMarker.Node.Type != null && !insertionPoint.CanInsert((ITypeId)documentNodeMarker.Node.Type))
                        {
                            return((IDropAction)null);
                        }
                    }
                    return((IDropAction) new DropMarkerListAction(result, insertionPoint));
                }
            }
            return((IDropAction)null);
        }
Exemplo n.º 13
0
        protected virtual bool OnDragOver(DragEventArgs args)
        {
            DataSchemaNodePathCollection result = (DataSchemaNodePathCollection)null;

            if (DragSourceHelper.FirstDataOfType <DataSchemaNodePathCollection>(args.Data, ref result) && !(this is DataBindingToolBehavior))
            {
                this.PushBehavior((ToolBehavior) new DataBindingToolBehavior(this.ToolBehaviorContext));
            }
            else if (args.Data.GetDataPresent("ResourceEntryItem", true) && !(this is ResourceToolBehavior))
            {
                this.PushBehavior((ToolBehavior) new ResourceToolBehavior(this.ToolBehaviorContext));
            }
            else if (args.Data.GetDataPresent(DataFormats.FileDrop) || args.Data.GetDataPresent("BlendProjectItem") && !(this is FileDropToolBehavior))
            {
                this.PushBehavior((ToolBehavior) new FileDropToolBehavior(this.ToolBehaviorContext));
            }
            else if (AssetDropToolBehavior.CanHandleDropData(args.Data) && !(this is AssetDropToolBehavior))
            {
                this.PushBehavior((ToolBehavior) new AssetDropToolBehavior(this.ToolBehaviorContext));
            }
            return(false);
        }
Exemplo n.º 14
0
        /// <summary>
        ///   Triggered when a handler item is being dragged
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="eventArgs">Event arguments</param>
        private void OnHandlerItemDrag(object sender, ItemDragEventArgs eventArgs)
        {
            // retrieve all the selected (and the dragging) item
            var items = new List <ListViewItem> {
                (ListViewItem)eventArgs.Item
            };

            // add remaining items
            foreach (ListViewItem item in this.handlerListView.SelectedItems)
            {
                if (!items.Contains(item))
                {
                    items.Add(item);
                }
            }

            // perform drag drop with a list of handler type names
            DragSourceHelper.DoDragDrop(this.handlerListView,
                                        this.handlerIconList.Images[items.First().ImageIndex] as Bitmap,
                                        Point.Empty,
                                        DragDropEffects.Copy,
                                        new KeyValuePair <string, object>(DataFormats.Serializable,
                                                                          items.Select(i => i.Tag.ToString()).ToList()));
        }