Exemple #1
0
        private static void AddToCutList(IProjectItem item, List <CutBuffer.ItemCopyInformation> cutList, bool isCut)
        {
            bool flag  = false;
            int  count = cutList.Count - 1;

            while (count >= 0)
            {
                string itemUrl = cutList[count].ItemUrl;
                if (itemUrl == item.DocumentReference.Path)
                {
                    flag = true;
                    break;
                }
                else if (!itemUrl.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) || !item.DocumentReference.Path.StartsWith(itemUrl, StringComparison.OrdinalIgnoreCase))
                {
                    if (item.DocumentReference.Path.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) && itemUrl.StartsWith(item.DocumentReference.Path, StringComparison.OrdinalIgnoreCase))
                    {
                        cutList.RemoveAt(count);
                    }
                    count--;
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                if (!item.DocumentReference.Path.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
                {
                    foreach (IProjectItem child in item.Children)
                    {
                        CutBuffer.AddToCutList(child, cutList, isCut);
                    }
                }
                string       path           = null;
                IProjectItem codeBehindItem = item.CodeBehindItem;
                if (codeBehindItem != null)
                {
                    path = codeBehindItem.DocumentReference.Path;
                }
                cutList.Add(new CutBuffer.ItemCopyInformation(item.DocumentReference.Path, path));
                item.IsCut = isCut;
            }
        }
Exemple #2
0
        private void CutCopy(bool isCut)
        {
            if (this.Services.ProjectManager().ItemSelectionSet.IsEmpty)
            {
                return;
            }
            IProject project = this.Services.ProjectManager().ItemSelectionSet.SelectedProjects.SingleOrNull <IProject>();

            if (project == null)
            {
                return;
            }
            this.UpdateLastCut(null);
            List <CutBuffer.ItemCopyInformation> itemCopyInformations = new List <CutBuffer.ItemCopyInformation>();

            foreach (IProjectItem projectItem in this.Services.ProjectManager().ItemSelectionSet.Selection.OfType <IProjectItem>())
            {
                if (isCut && projectItem.IsLinkedFile || !projectItem.FileExists || projectItem.IsVirtual || projectItem is AssemblyReferenceProjectItem)
                {
                    continue;
                }
                CutBuffer.AddToCutList(projectItem, itemCopyInformations, isCut);
            }
            string[] itemUrl = new string[itemCopyInformations.Count];
            for (int i = 0; i < itemCopyInformations.Count; i++)
            {
                itemUrl[i] = itemCopyInformations[i].ItemUrl;
            }
            DataObject dataObject = new DataObject();

            dataObject.SetData(typeof(string[]), itemUrl);
            dataObject.SetData(DataFormats.FileDrop, itemUrl);
            dataObject.SetData(new CutBuffer.ProjectCopyInformation(isCut, project.DocumentReference.Path, itemCopyInformations));
            ClipboardService.SetDataObject(dataObject);
            this.LastCut = dataObject;
        }