Пример #1
0
        internal static void AddItemsToDocument(SceneView view, IEnumerable <IProjectItem> importedItems, Point dropPoint, ISceneInsertionPoint insertionPoint)
        {
            bool flag = false;

            if (importedItems == null || !Enumerable.Any <IProjectItem>(importedItems))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = view.ViewModel.CreateEditTransaction(StringTable.DropElementsIntoSceneUndo))
            {
                foreach (IProjectItem projectItem in importedItems)
                {
                    if (FileDropToolBehavior.CanInsertTo(view, projectItem, insertionPoint))
                    {
                        FileDropToolBehavior.AddToDocument(view, projectItem, dropPoint, insertionPoint);
                    }
                    else
                    {
                        flag = true;
                    }
                }
                editTransaction.Commit();
            }
            if (!flag)
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = StringTable.DragInsertionContainedIllegalItemsMessage,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Exclamation
            };
            int num = (int)view.ViewModel.DesignerContext.MessageDisplayService.ShowMessage(args);
        }
Пример #2
0
        protected override bool OnDrop(DragEventArgs args)
        {
            ISceneInsertionPoint dropInsertionPoint = this.DragDropInsertionPoint;
            Point position = args.GetPosition((IInputElement)this.ActiveView.ViewRootContainer);

            this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            Point point     = this.ToolBehaviorContext.SnappingEngine.SnapPoint(position, EdgeFlags.All);
            Point dropPoint = this.ActiveView.TransformPointFromRoot(dropInsertionPoint.SceneElement, point);

            this.ToolBehaviorContext.SnappingEngine.Stop();
            SafeDataObject safeDataObject = new SafeDataObject(args.Data);

            using (TemporaryCursor.SetWaitCursor())
            {
                if (safeDataObject.GetDataPresent(DataFormats.FileDrop))
                {
                    FileDropToolBehavior.AddItemsToDocument(this.ActiveView, this.ActiveSceneViewModel.DesignerContext.ActiveProject.AddItems(Enumerable.Select <string, DocumentCreationInfo>((IEnumerable <string>) this.dropUtility.GetSupportedFiles(args.Data), (Func <string, DocumentCreationInfo>)(file => new DocumentCreationInfo()
                    {
                        SourcePath = file
                    }))), dropPoint, dropInsertionPoint);
                }
                else if (safeDataObject.GetDataPresent("BlendProjectItem"))
                {
                    ItemSelectionSet itemSelectionSet = (ItemSelectionSet)safeDataObject.GetData("BlendProjectItem");
                    using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction(StringTable.DropProjectItemIntoSceneUndo))
                    {
                        foreach (IProjectItem projectItem in itemSelectionSet.Selection)
                        {
                            FileDropToolBehavior.AddToDocument(this.ActiveView, projectItem, dropPoint, dropInsertionPoint);
                        }
                        editTransaction.Commit();
                    }
                }
            }
            if (!this.IsSuspended)
            {
                this.PopSelf();
            }
            return(true);
        }