private CutBuffer.ProjectCopyInformation GetCopyInformation() { CutBuffer.ProjectCopyInformation projectCopyInformation = null; SafeDataObject safeDataObject = SafeDataObject.FromClipboard(); if (safeDataObject != null) { if (safeDataObject.GetDataPresent(typeof(CutBuffer.ProjectCopyInformation))) { CutBuffer.ProjectCopyInformation data = safeDataObject.GetData(typeof(CutBuffer.ProjectCopyInformation)) as CutBuffer.ProjectCopyInformation; if (data != null) { projectCopyInformation = new CutBuffer.ProjectCopyInformation(data); } } if (projectCopyInformation == null && safeDataObject.GetDataPresent(DataFormats.FileDrop)) { string[] strArrays = safeDataObject.GetData(DataFormats.FileDrop) as string[]; if (strArrays != null) { projectCopyInformation = new CutBuffer.ProjectCopyInformation(false, null, strArrays); } } if (projectCopyInformation == null && safeDataObject.GetDataPresent(typeof(string[]))) { string[] data1 = safeDataObject.GetData(typeof(string[])) as string[]; if (data1 != null) { projectCopyInformation = new CutBuffer.ProjectCopyInformation(false, null, data1); } } if (projectCopyInformation == null && safeDataObject.GetDataPresent(typeof(string))) { string str = safeDataObject.GetData(typeof(string)) as string; if (str != null) { string[] strArrays1 = new string[] { str }; projectCopyInformation = new CutBuffer.ProjectCopyInformation(false, null, strArrays1); } } } return(projectCopyInformation); }
public static IEnumerable <T> DataOfType <T>(SafeDataObject data) { if (data != null) { T result = default(T); foreach (string format in data.GetFormats()) { if (DragSourceHelper.InternalDataOfType <T>(data.GetData(format), ref result)) { yield return(result); } } } }
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); }