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); }
private void UpdateLastCut(DataObject thisCut) { if (this.lastCut != null && thisCut != this.lastCut && this.lastCut.GetDataPresent(typeof(CutBuffer.ProjectCopyInformation))) { CutBuffer.ProjectCopyInformation data = (CutBuffer.ProjectCopyInformation) this.lastCut.GetData(typeof(CutBuffer.ProjectCopyInformation)); if (data.IsCut) { IProject project = this.Services.ProjectManager().CurrentSolution.Projects.FindMatchByUrl <IProject>(data.ProjectUrl); if (project != null) { foreach (CutBuffer.ItemCopyInformation item in data.Items) { IProjectItem projectItem = project.FindItem(DocumentReference.Create(item.ItemUrl)); if (projectItem == null) { continue; } projectItem.IsCut = false; } } } } this.lastCut = thisCut; }
public ProjectCopyInformation(CutBuffer.ProjectCopyInformation copy) { this.isCut = copy.IsCut; this.projectUrl = copy.ProjectUrl; this.items = copy.items; }
public void Paste() { IProject project = this.Services.ProjectManager().ItemSelectionSet.SelectedProjects.SingleOrNull <IProject>(); if (project == null) { return; } CutBuffer.ProjectCopyInformation copyInformation = this.GetCopyInformation(); if (copyInformation == null) { CutBuffer.AddImageDataFromClipboard(this.Services.ProjectManager(), project); } else { IProject project1 = null; if (copyInformation.IsCut) { project1 = this.Services.ProjectManager().CurrentSolution.Projects.FindMatchByUrl <IProject>(copyInformation.ProjectUrl); } if (copyInformation.Items != null && copyInformation.Items.Count > 0) { string str = this.Services.ProjectManager().TargetFolderForProject(project); if (str != null) { IEnumerable <CutBuffer.CopyInformation> copyInformations = copyInformation.Items.Where <CutBuffer.ItemCopyInformation>((CutBuffer.ItemCopyInformation itemToCopy) => { if (project1 == null) { return(true); } return(!Microsoft.Expression.Framework.Documents.PathHelper.ArePathsEquivalent(Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(itemToCopy.ItemUrl), str)); }).Select <CutBuffer.ItemCopyInformation, CutBuffer.CopyInformation>((CutBuffer.ItemCopyInformation itemToCopy) => new CutBuffer.CopyInformation(itemToCopy.ItemUrl, this.DetermineFileUrlForCopy(itemToCopy.ItemUrl, str))); if (!this.CopyItems(project, copyInformations)) { return; } } if (project1 != null) { foreach (CutBuffer.ItemCopyInformation item in copyInformation.Items) { IProjectItem projectItem = project1.FindItem(DocumentReference.Create(item.ItemUrl)); if (projectItem == null) { continue; } if (Microsoft.Expression.Framework.Documents.PathHelper.ArePathsEquivalent(Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(item.ItemUrl), str)) { projectItem.IsCut = false; } else { IProjectItem codeBehindItem = projectItem.CodeBehindItem; if (codeBehindItem != null) { IProject project2 = project1; IProjectItem[] projectItemArray = new IProjectItem[] { codeBehindItem }; project2.RemoveItems(true, projectItemArray); } IProject project3 = project1; IProjectItem[] projectItemArray1 = new IProjectItem[] { projectItem }; project3.RemoveItems(true, projectItemArray1); } } ClipboardService.SetDataObject(new DataObject()); this.LastCut = null; return; } } } }