private void ClipChanged()
            {
                IDataObject iData = ClipboardWrapper.GetDataObject();

                if (iData == null)
                {
                    return;
                }

                ClipboardFormat?format = null;

                foreach (var f in formats)
                {
                    if (iData.GetDataPresent(f))
                    {
                        format = (ClipboardFormat)Enum.Parse(typeof(ClipboardFormat), f);
                        break;
                    }
                }

                object data = iData.GetData(format.ToString());

                if (data == null || format == null)
                {
                    return;
                }

                if (OnClipboardChange != null)
                {
                    OnClipboardChange((ClipboardFormat)format, data);
                }
            }
Exemple #2
0
        public static void DoPaste(ISolutionFolderNode folderNode)
        {
            if (!DoEnablePaste(folderNode))
            {
                LoggingService.Warn("SolutionFolderNode.DoPaste: Pasting was not enabled.");
                return;
            }

            ExtTreeNode folderTreeNode = (ExtTreeNode)folderNode;
            IDataObject dataObject     = ClipboardWrapper.GetDataObject();

            if (dataObject.GetDataPresent(typeof(ISolutionFolder).ToString()))
            {
                string          guid           = dataObject.GetData(typeof(ISolutionFolder).ToString()).ToString();
                ISolutionFolder solutionFolder = folderNode.Solution.GetSolutionFolder(guid);
                if (solutionFolder != null)
                {
                    folderNode.Container.AddFolder(solutionFolder);
                    ExtTreeView treeView = (ExtTreeView)folderTreeNode.TreeView;
                    foreach (ExtTreeNode node in treeView.CutNodes)
                    {
                        ExtTreeNode oldParent = node.Parent as ExtTreeNode;
                        node.Remove();

                        node.AddTo(folderTreeNode);
                        if (oldParent != null)
                        {
                            oldParent.Refresh();
                        }
                    }
                    ProjectService.SaveSolution();
                }
            }
            folderTreeNode.Expand();
        }
Exemple #3
0
        public static bool DoEnablePaste(ISolutionFolderNode container)
        {
            IDataObject dataObject = ClipboardWrapper.GetDataObject();

            if (dataObject == null)
            {
                return(false);
            }
            if (dataObject.GetDataPresent(typeof(ISolutionFolder).ToString()))
            {
                string          guid           = dataObject.GetData(typeof(ISolutionFolder).ToString()).ToString();
                ISolutionFolder solutionFolder = container.Solution.GetSolutionFolder(guid);
                if (solutionFolder == null || solutionFolder == container)
                {
                    return(false);
                }
                if (solutionFolder is ISolutionFolderContainer)
                {
                    return(solutionFolder.Parent != container &&
                           !((ISolutionFolderContainer)solutionFolder).IsAncestorOf(container.Folder));
                }
                else
                {
                    return(solutionFolder.Parent != container);
                }
            }
            return(false);
        }
Exemple #4
0
        public override void Paste()
        {
            IDataObject dataObject = ClipboardWrapper.GetDataObject();

            if (dataObject == null)
            {
                return;
            }

            if (dataObject.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])dataObject.GetData(DataFormats.FileDrop);
                foreach (string fileName in files)
                {
                    if (System.IO.Directory.Exists(fileName))
                    {
                        if (!FileUtility.IsBaseDirectory(fileName, Directory))
                        {
                            CopyDirectoryHere(fileName, false);
                        }
                    }
                    else
                    {
                        CopyFileHere(fileName, false);
                    }
                }
            }
            else if (dataObject.GetDataPresent(typeof(FileNode)))
            {
                FileOperationClipboardObject clipboardObject = (FileOperationClipboardObject)dataObject.GetData(typeof(FileNode).ToString());

                if (File.Exists(clipboardObject.FileName))
                {
                    CopyFileHere(clipboardObject.FileName, clipboardObject.PerformMove);
                    if (clipboardObject.PerformMove)
                    {
                        Clipboard.Clear();
                    }
                }
            }
            else if (dataObject.GetDataPresent(typeof(DirectoryNode)))
            {
                FileOperationClipboardObject clipboardObject = (FileOperationClipboardObject)dataObject.GetData(typeof(DirectoryNode).ToString());

                if (System.IO.Directory.Exists(clipboardObject.FileName))
                {
                    CopyDirectoryHere(clipboardObject.FileName, clipboardObject.PerformMove);
                    if (clipboardObject.PerformMove)
                    {
                        Clipboard.Clear();
                    }
                }
            }
            ProjectService.SaveSolution();
        }
Exemple #5
0
        public void Paste()
        {
            if (resourceEditor.ResourceList.WriteProtected)
            {
                return;
            }

            IDataObject dob = ClipboardWrapper.GetDataObject();

            if (dob == null)
            {
                return;
            }

            if (dob.GetDataPresent(typeof(Hashtable).FullName))
            {
                Hashtable tmphash = (Hashtable)dob.GetData(typeof(Hashtable));
                foreach (DictionaryEntry entry in tmphash)
                {
                    object       resourceValue = GetClonedResource(entry.Value);
                    ResourceItem item;

                    if (!resourceEditor.ResourceList.Resources.ContainsKey((string)entry.Key))
                    {
                        item = new ResourceItem(entry.Key.ToString(), resourceValue);
                    }
                    else
                    {
                        int    count       = 1;
                        string newNameBase = entry.Key.ToString() + " ";
                        string newName     = newNameBase + count.ToString();

                        while (resourceEditor.ResourceList.Resources.ContainsKey(newName))
                        {
                            count++;
                            newName = newNameBase + count.ToString();
                        }
                        item = new ResourceItem(newName, resourceValue);
                    }
                    resourceEditor.ResourceList.Resources.Add(item.Name, item);
                    resourceEditor.ResourceList.OnChanged();
                }
                resourceEditor.ResourceList.InitializeListView();
            }
        }
 public static bool DoEnablePaste(ISolutionFolderNode container)
 {
     return(DoEnablePaste(container, ClipboardWrapper.GetDataObject()));
 }