예제 #1
0
 /// <summary>
 /// Raises the DragCompleted event.
 /// </summary>
 /// <param name="args">Information about the event.</param>
 private static void OnDragCompleted(DragDropCompletedEventArgs args)
 {
     _dragOperationInProgress = null;
     EventHandler<DragDropCompletedEventArgs> handler = DragDropCompleted;
     if (handler != null)
     {
         handler(null, args);
     }
 }
예제 #2
0
        public PinboardControl()
        {
            InitializeComponent();

            bufferContext = new BufferedGraphicsContext();
            SizeGraphicsBuffer();
            SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            SetStyle(ControlStyles.DoubleBuffer, false);

            dragOp = DragOperation.None;
            nextRectNum = 0;
        }
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			if (dataObject is SystemFile) {
				FilePath targetPath = ShowAllFilesBuilderExtension.GetFolderPath (CurrentNode.DataItem);
				return ((SystemFile)dataObject).Path.ParentDirectory != targetPath || operation == DragOperation.Copy;
			}
			return false;
		}
예제 #4
0
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			if (operation == DragOperation.Move) {
				WorkspaceItem it = dataObject as WorkspaceItem;
				if (it != null) {
					Workspace ws = (Workspace) CurrentNode.DataItem;
					return it != ws && !ws.Items.Contains (it);
				}
			}
			return false;
		}
		public override bool CanDropNode (object dataObject, DragOperation operation, DropPosition pos)
		{
			object parent1 = CurrentNode.GetParentDataItem (typeof(Extension), false);
			if (parent1 == null)
				parent1 = CurrentNode.GetParentDataItem (typeof(ExtensionPoint), false);
			
			ITreeNavigator nav = CurrentNode.Clone ();
			if (!nav.MoveToObject (dataObject))
				return false;
			object parent2 = nav.GetParentDataItem (parent1.GetType (), false);
			if (parent2 != parent1)
				return false;
			
			return true;
		}
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			return (dataObject is SolutionItem && ((ProjectFile) CurrentNode.DataItem).DependsOnFile == null);
		}
		// Currently only accepts packages and projects that compile into a static library
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			if (dataObject is Package)
				return true;
			
			if (dataObject is CProject) {
				CProject project = (CProject)dataObject;
				
				if (((ProjectPackageCollection)CurrentNode.DataItem).Project.Equals (project))
					return false;
				
				CProjectConfiguration config = (CProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
				
				if (config.CompileTarget != CBinding.CompileTarget.Bin)
					return true;
			}
			
			return false;
		}
예제 #8
0
		public virtual void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation, DropPosition position)
		{
			cachedPosition = position;
			OnMultipleNodeDrop (dataObjects, operation);
		}
예제 #9
0
		public virtual bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
		{
			cachedPosition = position;
			return CanDropMultipleNodes (dataObjects, operation);
		}
예제 #10
0
        async System.Threading.Tasks.Task DropNode(HashSet <SolutionItem> projectsToSave, object dataObject, HashSet <ProjectFile> groupedFiles, DragOperation operation)
        {
            FilePath targetDirectory = GetFolderPath(CurrentNode.DataItem);
            FilePath source;
            string   what;
            Project  targetProject = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            Project  sourceProject;
            IEnumerable <ProjectFile> groupedChildren = null;

            if (dataObject is ProjectFolder)
            {
                source        = ((ProjectFolder)dataObject).Path;
                sourceProject = ((ProjectFolder)dataObject).Project;
                what          = Path.GetFileName(source);
            }
            else if (dataObject is ProjectFile)
            {
                ProjectFile file = (ProjectFile)dataObject;

                // if this ProjectFile is one of the grouped files being pulled in by a parent being copied/moved, ignore it
                if (groupedFiles.Contains(file))
                {
                    return;
                }

                if (file.DependsOnFile != null && operation == DragOperation.Move)
                {
                    // unlink this file from its parent (since its parent is not being moved)
                    file.DependsOn = null;

                    // if moving a linked file into its containing folder, simply unlink it from its parent
                    if (file.FilePath.ParentDirectory == targetDirectory)
                    {
                        projectsToSave.Add(targetProject);
                        return;
                    }
                }

                sourceProject = file.Project;
                if (sourceProject != null && file.IsLink)
                {
                    source = sourceProject.BaseDirectory.Combine(file.ProjectVirtualPath);
                }
                else
                {
                    source = file.FilePath;
                }
                groupedChildren = file.DependentChildren;
                what            = null;
            }
            else if (dataObject is Gtk.SelectionData)
            {
                SelectionData data = (SelectionData)dataObject;
                if (data.Type != "text/uri-list")
                {
                    return;
                }
                string sources = System.Text.Encoding.UTF8.GetString(data.Data);
                Console.WriteLine("text/uri-list:\n{0}", sources);
                string[] files = sources.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < files.Length; n++)
                {
                    Uri uri = new Uri(files[n]);
                    if (uri.Scheme != "file")
                    {
                        return;
                    }
                    if (Directory.Exists(uri.LocalPath))
                    {
                        return;
                    }
                    files[n] = uri.LocalPath;
                }

                IdeApp.ProjectOperations.AddFilesToProject(targetProject, files, targetDirectory);
                projectsToSave.Add(targetProject);
                return;
            }
            else if (dataObject is SolutionFolderFileNode)
            {
                var sff = (SolutionFolderFileNode)dataObject;
                sff.Parent.Files.Remove(sff.FileName);

                await IdeApp.ProjectOperations.SaveAsync(sff.Parent.ParentSolution);

                source        = ((SolutionFolderFileNode)dataObject).FileName;
                sourceProject = null;
                what          = null;
            }
            else
            {
                return;
            }

            var targetPath = targetDirectory.Combine(source.FileName);

            // If copying to the same directory, make a copy with a different name
            if (targetPath == source)
            {
                targetPath = ProjectOperations.GetTargetCopyName(targetPath, dataObject is ProjectFolder);
            }

            var targetChildPaths = groupedChildren != null?groupedChildren.Select(child => {
                var targetChildPath = targetDirectory.Combine(child.FilePath.FileName);

                if (targetChildPath == child.FilePath)
                {
                    targetChildPath = ProjectOperations.GetTargetCopyName(targetChildPath, false);
                }

                return(targetChildPath);
            }).ToList() : null;

            if (dataObject is ProjectFolder)
            {
                string q;
                if (operation == DragOperation.Move)
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Move))
                    {
                        return;
                    }
                }
                else
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Copy))
                    {
                        return;
                    }
                }
            }
            else if (dataObject is ProjectFile)
            {
                var items = Enumerable.Repeat(targetPath, 1);
                if (targetChildPaths != null)
                {
                    items = items.Concat(targetChildPaths);
                }

                foreach (var file in items)
                {
                    if (File.Exists(file))
                    {
                        if (!MessageService.Confirm(GettextCatalog.GetString("The file '{0}' already exists. Do you want to overwrite it?", file.FileName), AlertButton.OverwriteFile))
                        {
                            return;
                        }
                    }
                }
            }

            var filesToSave = new List <Document> ();

            foreach (Document doc in IdeApp.Workbench.Documents)
            {
                if (doc.IsDirty && doc.IsFile)
                {
                    if (doc.Name == source || doc.Name.StartsWith(source + Path.DirectorySeparatorChar))
                    {
                        filesToSave.Add(doc);
                    }
                    else if (groupedChildren != null)
                    {
                        foreach (ProjectFile f in groupedChildren)
                        {
                            if (doc.Name == f.Name)
                            {
                                filesToSave.Add(doc);
                            }
                        }
                    }
                }
            }

            if (filesToSave.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Document doc in filesToSave)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(",\n");
                    }
                    sb.Append(Path.GetFileName(doc.Name));
                }

                string question;

                if (operation == DragOperation.Move)
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the move operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString());
                    }
                }
                else
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the copy operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString());
                    }
                }
                AlertButton noSave = new AlertButton(GettextCatalog.GetString("Don't Save"));
                AlertButton res    = MessageService.AskQuestion(question, AlertButton.Cancel, noSave, AlertButton.Save);
                if (res == AlertButton.Cancel)
                {
                    return;
                }
                if (res == AlertButton.Save)
                {
                    try {
                        foreach (Document doc in filesToSave)
                        {
                            doc.Save();
                        }
                    } catch (Exception ex) {
                        MessageService.ShowError(GettextCatalog.GetString("Save operation failed."), ex);
                        return;
                    }
                }
            }

            if (operation == DragOperation.Move && sourceProject != null)
            {
                projectsToSave.Add(sourceProject);
            }
            if (targetProject != null)
            {
                projectsToSave.Add(targetProject);
            }

            bool move   = operation == DragOperation.Move;
            var  opText = move ? GettextCatalog.GetString("Moving files...") : GettextCatalog.GetString("Copying files...");

            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor(opText, Stock.StatusSolutionOperation, true)) {
                // If we drag and drop a node in the treeview corresponding to a directory, do not move
                // the entire directory. We should only move the files which exist in the project. Otherwise
                // we will need a lot of hacks all over the code to prevent us from incorrectly moving version
                // control related files such as .svn directories

                // Note: if we are transferring a ProjectFile, this will copy/move the ProjectFile's DependentChildren as well.
                IdeApp.ProjectOperations.TransferFiles(monitor, sourceProject, source, targetProject, targetPath, move, sourceProject != null);
            }
        }
예제 #11
0
 public override bool CanDropNode(object dataObject, DragOperation operation)
 {
     return(dataObject is SolutionItem && ((ProjectFile)CurrentNode.DataItem).DependsOnFile == null);
 }
예제 #12
0
 public override bool CanHandleDropFromChild(object [] dataObjects, DragOperation operation, DropPosition position)
 {
     return(CanHandleDropFromChild(dataObjects, position));
 }
예제 #13
0
 public override bool CanHandleDropFromChild(object [] dataObjects, DragOperation operation, DropPosition position)
 {
     return(ProjectFolderCommandHandler.CanHandleDropFromChild(dataObjects, position));
 }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeNodeDragData"/> class.
 /// </summary>
 /// <param name="treeNode">The tree node being dragged.</param>
 /// <param name="node">The file system node being dragged.</param>
 /// <param name="dragOperation">The desired drag operation.</param>
 /// <exception cref="ArgumentNullException">Thrown when the <paramref name="treeNode"/>, or the <paramref name="node"/> parameter is <b>null</b>.</exception>
 public TreeNodeDragData(KryptonTreeNode treeNode, IFileExplorerNodeVm node, DragOperation dragOperation)
 {
     TreeNode      = treeNode ?? throw new ArgumentNullException(nameof(treeNode));
     Node          = node ?? throw new ArgumentNullException(nameof(node));
     DragOperation = dragOperation;
 }
		public override bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation, DropPosition position)
		{
			foreach (object dataObject in dataObjects) 
				if (dataObjects is GuiProjectFolder)
					return false;
			
			return base.CanDropMultipleNodes (dataObjects, operation, position);
		}
예제 #16
0
		public virtual bool CanDropNode (object dataObject, DragOperation operation, DropPosition position)
		{
			if (position == DropPosition.Into)
				return CanDropNode (dataObject, operation);
			else
				return false;
		}
예제 #17
0
        private void Chessboard_MouseUp(object sender, MouseEventArgs e)
        {
            Cursor = Cursors.Default;
            if (DragDropOperation.DraggedPiece != null && DragDropOperation.DraggedPiece.Kind != ChessPieceKind.None)
            {
                if (e.X > DigitAreaWidth && e.X < this.Width && e.Y < Height - LetterAreaHeight && e.Y > 0)
                {
                    //  Drops a piece on the board
                    var destinationSquare = (BoardDirection == BoardDirection.BlackOnTop ?
                                             new ChessSquare((ChessFile)((e.X - DigitAreaWidth) / SquareWidth), (ChessRank)(7 - (e.Y / SquareHeight))) :
                                             new ChessSquare((ChessFile)(7 - (e.X - DigitAreaWidth) / SquareWidth), (ChessRank)(e.Y / SquareHeight)));
                    var moveValidationResult = ChessEngine.GetMoveValidity(DragDropOperation.Origin, destinationSquare);
                    if (moveValidationResult.IsValid)
                    {
                        var promotionCancelled = false;
                        if (moveValidationResult.MoveKind.HasFlag(ChessMoveType.Promotion))
                        {
                            var pieceChooser = new FrmPromotion(ChessEngine.Turn);
                            promotionCancelled = pieceChooser.ShowDialog() != DialogResult.OK;
                            moveValidationResult.PromotedTo = pieceChooser.ChoosePiece;
                        }
                        if (!promotionCancelled)
                        {
                            moveValidationResult.ToSAN = ChessEngine.MoveToSAN(moveValidationResult);   //  Update the SAN after promotion
                            MovePiece(moveValidationResult);

                            OnPieceMoved?.Invoke(this, moveValidationResult);
                            if (ChessEngine.IsCheckmate)
                            {
                                OnCheckmate?.Invoke(this, new EventArgs());
                            }
                            else if (ChessEngine.IsCheck)
                            {
                                OnCheck?.Invoke(this, new EventArgs());
                            }
                            else if (ChessEngine.IsDraw)
                            {
                                OnDraw?.Invoke(this, new EventArgs());
                            }
                        }
                        else
                        {
                            Invalidate();
                        }
                    }
                    else
                    {
                        Invalidate();
                    }
                }
                else
                {
                    //  Drops a piece outside of the board
                    ChessEngine.RemovePieceAt(DragDropOperation.Origin);
                    Invalidate();
                    OnPieceRemoved?.Invoke(this, DragDropOperation.Origin, DragDropOperation.DraggedPiece, e.Location);
                }
            }
            DragDropOperation = new DragOperation(null, null);
            OnSquareUnselected?.Invoke(this, new EventArgs());
        }
예제 #18
0
		public virtual void OnNodeDrop (object dataObjects, DragOperation operation, DropPosition position)
		{
			OnNodeDrop (dataObjects, operation);
		}
예제 #19
0
 public override bool CanDropNode(object dataObject, DragOperation operation)
 {
     return(dataObject is ProjectReference || dataObject is Project);
 }
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			return dataObject is ProjectReference || dataObject is Project;
		}
예제 #21
0
        public override void OnNodeDrop(object dataObject, DragOperation operation)
        {
            // It allows dropping either project references or projects.
            // Dropping a project creates a new project reference to that project

            DotNetProject project = dataObject as DotNetProject;

            if (project != null)
            {
                ProjectReference pr = new ProjectReference(project);
                DotNetProject    p  = CurrentNode.GetParentDataItem(typeof(DotNetProject), false) as DotNetProject;
                if (ProjectReferencesProject(project, p.Name))
                {
                    return;
                }
                p.References.Add(pr);
                IdeApp.ProjectOperations.Save(p);
                return;
            }

            // It's dropping a ProjectReference object.

            ProjectReference pref = dataObject as ProjectReference;
            ITreeNavigator   nav  = CurrentNode;

            if (operation == DragOperation.Move)
            {
                NodePosition pos = nav.CurrentPosition;
                nav.MoveToObject(dataObject);
                DotNetProject p = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject;
                nav.MoveToPosition(pos);
                DotNetProject p2 = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject;

                p.References.Remove(pref);

                // Check if there is a cyclic reference after removing from the source project
                if (pref.ReferenceType == ReferenceType.Project)
                {
                    DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject;
                    if (pdest == null || ProjectReferencesProject(pdest, p2.Name))
                    {
                        // Restore the dep
                        p.References.Add(pref);
                        return;
                    }
                }

                p2.References.Add(pref);
                IdeApp.ProjectOperations.Save(p);
                IdeApp.ProjectOperations.Save(p2);
            }
            else
            {
                nav.MoveToParent(typeof(DotNetProject));
                DotNetProject p = nav.DataItem as DotNetProject;

                // Check for cyclic referencies
                if (pref.ReferenceType == ReferenceType.Project)
                {
                    DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject;
                    if (pdest == null || ProjectReferencesProject(pdest, p.Name))
                    {
                        return;
                    }
                }
                p.References.Add((ProjectReference)pref.Clone());
                IdeApp.ProjectOperations.Save(p);
            }
        }
예제 #22
0
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			return (dataObject is SolutionItem) || (dataObject is IFileItem);
		}
예제 #23
0
 public virtual void OnNodeDrop(object dataObjects, DragOperation operation)
 {
 }
예제 #24
0
        void DropNode(Set <SolutionEntityItem> projectsToSave, object dataObject, DragOperation operation)
        {
            FilePath targetPath = GetFolderPath(CurrentNode.DataItem);
            FilePath source;
            string   what;
            Project  targetProject = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            Project  sourceProject;

            System.Collections.Generic.IEnumerable <ProjectFile> groupedChildren = null;

            if (dataObject is ProjectFolder)
            {
                source        = ((ProjectFolder)dataObject).Path;
                sourceProject = ((ProjectFolder)dataObject).Project;
                what          = Path.GetFileName(source);
            }
            else if (dataObject is ProjectFile)
            {
                ProjectFile file = (ProjectFile)dataObject;
                sourceProject = file.Project;
                if (sourceProject != null && file.IsLink)
                {
                    source = sourceProject.BaseDirectory.Combine(file.ProjectVirtualPath);
                }
                else
                {
                    source = file.FilePath;
                }
                groupedChildren = file.DependentChildren;
                what            = null;
            }
            else if (dataObject is Gtk.SelectionData)
            {
                SelectionData data = (SelectionData)dataObject;
                if (data.Type != "text/uri-list")
                {
                    return;
                }
                string   sources = System.Text.Encoding.UTF8.GetString(data.Data);
                string[] files   = sources.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < files.Length; n++)
                {
                    Uri uri = new Uri(files[n]);
                    if (uri.Scheme != "file")
                    {
                        return;
                    }
                    if (Directory.Exists(uri.LocalPath))
                    {
                        return;
                    }
                    files[n] = uri.LocalPath;
                }

                IdeApp.ProjectOperations.AddFilesToProject(targetProject, files, targetPath);
                projectsToSave.Add(targetProject);
                return;
            }
            else
            {
                return;
            }

            targetPath = targetPath.Combine(source.FileName);
            // If copying to the same directory, make a copy with a different name
            if (targetPath == source)
            {
                targetPath = ProjectOperations.GetTargetCopyName(targetPath, dataObject is ProjectFolder);
            }

            if (dataObject is ProjectFolder)
            {
                string q;
                if (operation == DragOperation.Move)
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetPath.ParentDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Move))
                    {
                        return;
                    }
                }
                else
                {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    }
                    else
                    {
                        q = GettextCatalog.GetString("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetPath.ParentDirectory.FileName);
                    }
                    if (!MessageService.Confirm(q, AlertButton.Copy))
                    {
                        return;
                    }
                }
            }
            else if (dataObject is ProjectFile)
            {
                if (File.Exists(targetPath))
                {
                    if (!MessageService.Confirm(GettextCatalog.GetString("The file '{0}' already exists. Do you want to overwrite it?", targetPath.FileName), AlertButton.OverwriteFile))
                    {
                        return;
                    }
                }
            }

            ArrayList filesToSave = new ArrayList();

            foreach (Document doc in IdeApp.Workbench.Documents)
            {
                if (doc.IsDirty && doc.IsFile)
                {
                    if (doc.Name == source || doc.Name.StartsWith(source + Path.DirectorySeparatorChar))
                    {
                        filesToSave.Add(doc);
                    }
                    else if (groupedChildren != null)
                    {
                        foreach (ProjectFile f in groupedChildren)
                        {
                            if (doc.Name == f.Name)
                            {
                                filesToSave.Add(doc);
                            }
                        }
                    }
                }
            }

            if (filesToSave.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Document doc in filesToSave)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(",\n");
                    }
                    sb.Append(Path.GetFileName(doc.Name));
                }

                string question;

                if (operation == DragOperation.Move)
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the move operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString());
                    }
                }
                else
                {
                    if (filesToSave.Count == 1)
                    {
                        question = GettextCatalog.GetString("Do you want to save the file '{0}' before the copy operation?", sb.ToString());
                    }
                    else
                    {
                        question = GettextCatalog.GetString("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString());
                    }
                }
                AlertButton noSave = new AlertButton(GettextCatalog.GetString("Don't Save"));
                AlertButton res    = MessageService.AskQuestion(question, AlertButton.Cancel, noSave, AlertButton.Save);
                if (res == AlertButton.Cancel)
                {
                    return;
                }
                else if (res == AlertButton.Save)
                {
                    try {
                        foreach (Document doc in filesToSave)
                        {
                            doc.Save();
                        }
                    } catch (Exception ex) {
                        MessageService.ShowException(ex, GettextCatalog.GetString("Save operation failed."));
                        return;
                    }
                }
            }

            if (operation == DragOperation.Move && sourceProject != null)
            {
                projectsToSave.Add(sourceProject);
            }
            if (targetProject != null)
            {
                projectsToSave.Add(targetProject);
            }

            using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Copying files..."), MonoDevelop.Ide.Gui.Stock.CopyIcon, true))
            {
                // If we drag and drop a node in the treeview corresponding to a directory, do not move
                // the entire directory. We should only move the files which exist in the project. Otherwise
                // we will need a lot of hacks all over the code to prevent us from incorrectly moving version
                // control related files such as .svn directories
                bool move = operation == DragOperation.Move;
                IdeApp.ProjectOperations.TransferFiles(monitor, sourceProject, source, targetProject, targetPath, move, true);
            }
        }
예제 #25
0
 public virtual void OnMultipleNodeDrop(object[] dataObjects, DragOperation operation, DropPosition position)
 {
     cachedPosition = position;
     OnMultipleNodeDrop(dataObjects, operation);
 }
예제 #26
0
		public override void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation, DropPosition pos)
		{
			DotNetProject p = (DotNetProject) CurrentNode.GetParentDataItem (typeof(Project), false);
			AddinData adata = p.GetAddinData ();
			
			ExtensionNodeInfo en = (ExtensionNodeInfo) CurrentNode.DataItem;

			foreach (ExtensionNodeInfo newNode in dataObjects) {
				if (newNode.Node.Parent is ExtensionNodeDescription)
					((ExtensionNodeDescription)newNode.Node.Parent).ChildNodes.Remove (en.Node);
				else
					((Extension)newNode.Node.Parent).ExtensionNodes.Remove (newNode.Node);
				InsertNode (adata, en, pos, newNode.Node);
				
				// Add all other nodes after the first node
				en = newNode;
				pos = DropPosition.After;
			}
			
			adata.CachedAddinManifest.Save ();
			adata.NotifyChanged (false);
		}
 public override bool CanDropNode(object dataObject, DragOperation operation)
 {
     return(dataObject is SolutionItem);
 }
예제 #28
0
		public override void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation)
		{
			Set<IWorkspaceFileObject> toSave = new Set<IWorkspaceFileObject> ();
			foreach (object dataObject in dataObjects) {
				Workspace ws = (Workspace) CurrentNode.DataItem;
				WorkspaceItem it = (WorkspaceItem) dataObject;
				
				if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to move the item '{0}' to the workspace '{1}'?", it.Name, ws.Name), AlertButton.Move))
					return;
				
				if (it.ParentWorkspace != null) {
					it.ParentWorkspace.Items.Remove (it);
					ws.Items.Add (it);
					toSave.Add (it.ParentWorkspace);
					toSave.Add (ws);
				} else {
					IdeApp.Workspace.Items.Remove (it);
					ws.Items.Add (it);
					toSave.Add (ws);
				}
			}
			IdeApp.ProjectOperations.Save (toSave);
		}
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			return base.CanDropNode (dataObject, operation);
		}
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			FilePath targetPath = ShowAllFilesBuilderExtension.GetFolderPath (CurrentNode.DataItem);
			Project targetProject = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
			FilePath source = ((SystemFile)dataObject).Path;
			targetPath = targetPath.Combine (source.FileName);
			if (targetPath == source)
				targetPath = ProjectOperations.GetTargetCopyName (targetPath, false);
			
			using (ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString("Copying files..."), Stock.StatusWorking, true))
			{
				bool move = operation == DragOperation.Move;
				IdeApp.ProjectOperations.TransferFiles (monitor, null, source, targetProject, targetPath, move, false);
			}
		}
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			base.OnNodeDrop (dataObject, operation);
		}
예제 #32
0
		public override bool CanDropNode (object dataObject, DragOperation operation)
		{
			return base.CanDropNode (dataObject, operation);
		}
 /// <summary>
 /// Signals to the panel that a drag and drop operation it may have initiated has been completed.
 /// </summary>
 public void FinishDragDrop()
 {
     this.currentDragOperation = DragOperation.None;
 }
예제 #34
0
		public virtual bool CanDropNode (object dataObject, DragOperation operation)
		{
			return false;
		}
 public virtual bool CanDropNode(object dataObject, DragOperation operation)
 {
     return(false);
 }
예제 #36
0
		public virtual bool CanDropMultipleNodes (object[] dataObjects, DragOperation operation)
		{
			foreach (object ob in dataObjects)
				if (!CanDropNode (ob, operation, cachedPosition))
					return false;
			return true;
		}
 public virtual bool CanDropMultipleNodes(object[] dataObjects, DragOperation operation, DropPosition position)
 {
     cachedPosition = position;
     return(CanDropMultipleNodes(dataObjects, operation));
 }
예제 #38
0
		public virtual void OnNodeDrop (object dataObjects, DragOperation operation)
		{
		}
 public virtual void OnNodeDrop(object dataObjects, DragOperation operation, DropPosition position)
 {
     OnNodeDrop(dataObjects, operation);
 }
예제 #40
0
		public virtual void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation)
		{
			foreach (object ob in dataObjects)
				OnNodeDrop (ob, operation, cachedPosition);
		}
예제 #41
0
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			SolutionFolder folder = (SolutionFolder) CurrentNode.DataItem;
			if (dataObject is SolutionItem) {
				SolutionItem it = (SolutionItem) dataObject;
				if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to move the item '{0}' to the solution folder '{1}'?", it.Name, folder.Name), AlertButton.Move))
					return;
	
				// If the items belongs to another folder, it will be automatically removed from it
				folder.Items.Add (it);
			}
			else {
				DropFile (folder, (IFileItem) dataObject, operation);
			}
			
		    IdeApp.ProjectOperations.Save (folder.ParentSolution);
		}
		public async override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			// It allows dropping either project references or projects.
			// Dropping a project creates a new project reference to that project
			
			DotNetProject project = dataObject as DotNetProject;
			if (project != null) {
				ProjectReference pr = ProjectReference.CreateProjectReference (project);
				DotNetProject p = CurrentNode.GetParentDataItem (typeof(DotNetProject), false) as DotNetProject;
				// Circular dependencies are not allowed.
				if (HasCircularReference (project, p.Name))
					return;

				// If the reference already exists, bail out
				if (ProjectReferencesProject (p, project.Name))
					return;
				p.References.Add (pr);
				await IdeApp.ProjectOperations.SaveAsync (p);
				return;
			}
			
			// It's dropping a ProjectReference object.
			
			ProjectReference pref = dataObject as ProjectReference;
			ITreeNavigator nav = CurrentNode;

			if (operation == DragOperation.Move) {
				NodePosition pos = nav.CurrentPosition;
				nav.MoveToObject (dataObject);
				DotNetProject p = nav.GetParentDataItem (typeof(DotNetProject), true) as DotNetProject;
				nav.MoveToPosition (pos);
				DotNetProject p2 = nav.GetParentDataItem (typeof(DotNetProject), true) as DotNetProject;
				
				p.References.Remove (pref);

				// Check if there is a cyclic reference after removing from the source project
				if (pref.ReferenceType == ReferenceType.Project) {
					DotNetProject pdest = pref.ResolveProject (p.ParentSolution) as DotNetProject;
					if (pdest == null || ProjectReferencesProject (pdest, p2.Name)) {
						// Restore the dep
						p.References.Add (pref);
						return;
					}
				}
				
				p2.References.Add (pref);
				await IdeApp.ProjectOperations.SaveAsync (p);
				await IdeApp.ProjectOperations.SaveAsync (p2);
			} else {
				nav.MoveToParent (typeof(DotNetProject));
				DotNetProject p = nav.DataItem as DotNetProject;
				
				// Check for cyclic referencies
				if (pref.ReferenceType == ReferenceType.Project) {
					DotNetProject pdest = pref.ResolveProject (p.ParentSolution) as DotNetProject;
					if (pdest == null)
						return;
					if (HasCircularReference (pdest, p.Name))
						return;

					// The reference is already there
					if (ProjectReferencesProject (p, pdest.Name))
						return;
				}
				p.References.Add ((ProjectReference) pref.Clone ());
				await IdeApp.ProjectOperations.SaveAsync (p);
			}
		}
예제 #43
0
		internal static void DropFile (SolutionFolder folder, IFileItem fileItem, DragOperation operation)
		{
			FilePath dest = folder.BaseDirectory.Combine (fileItem.FileName.FileName);
			if (operation == DragOperation.Copy)
				FileService.CopyFile (fileItem.FileName, dest);
			else
				FileService.MoveFile (fileItem.FileName, dest);
			folder.Files.Add (dest);
		}
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			if (dataObject is Package) {
				Package package = (Package)dataObject;
				ITreeNavigator nav = CurrentNode;
				
				CProject dest = nav.GetParentDataItem (typeof(CProject), true) as CProject;
				nav.MoveToObject (dataObject);
				CProject source = nav.GetParentDataItem (typeof(CProject), true) as CProject;
				
				dest.Packages.Add (package);
				IdeApp.ProjectOperations.Save (dest);
				
				if (operation == DragOperation.Move) {
					source.Packages.Remove (package);
					IdeApp.ProjectOperations.Save (source);
				}
			} else if (dataObject is CProject) {
				CProject draggedProject = (CProject)dataObject;
				CProject destProject = (CurrentNode.DataItem as ProjectPackageCollection).Project;
				
				draggedProject.WriteMDPkgPackage (IdeApp.Workspace.ActiveConfiguration);
				
				Package package = new Package (draggedProject);
				
				if (!destProject.Packages.Contains (package)) {				
					destProject.Packages.Add (package);
					IdeApp.ProjectOperations.Save (destProject);
				}
			}
		}
        public override bool CanDropNode(object dataObject, DragOperation operation)
        {
            string targetPath = GetFolderPath (CurrentNode.DataItem);

            if (dataObject is ProjectFile)
                return Path.GetDirectoryName (((ProjectFile)dataObject).Name) != targetPath;
            if (dataObject is ProjectFolder)
                return ((ProjectFolder)dataObject).Path != targetPath;
            return false;
        }
예제 #46
0
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
			Solution sol = CurrentNode.DataItem as Solution;
			if (dataObject is SolutionItem) {
				SolutionItem it = (SolutionItem) dataObject;
				if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to move the item '{0}' to the root node of the solution?", it.Name), AlertButton.Move))
					return;
	
				// If the items belongs to another folder, it will be automatically removed from it
				sol.RootFolder.Items.Add (it);
			}
			else {
				SolutionFolderNodeCommandHandler.DropFile (sol.DefaultSolutionFolder, (IFileItem) dataObject, operation);
			}
			IdeApp.ProjectOperations.Save (sol);
		}
        public override void OnNodeDrop(object dataObject, DragOperation operation)
        {
            string targetPath = GetFolderPath (CurrentNode.DataItem);
            string what, source, where, how;
            Project targetProject = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
            Project sourceProject;

            bool ask;
            if (operation == DragOperation.Move)
                how = GettextCatalog.GetString ("move");
            else
                how = GettextCatalog.GetString ("copy");

            if (dataObject is ProjectFolder) {
                source = ((ProjectFolder) dataObject).Path;
                sourceProject = ((ProjectFolder) dataObject).Project;
                what = string.Format (GettextCatalog.GetString ("the folder '{0}'"), Path.GetFileName(source));
                ask = true;
            }
            else if (dataObject is ProjectFile) {
                source = ((ProjectFile)dataObject).Name;
                sourceProject = ((ProjectFile) dataObject).Project;
                what = string.Format (GettextCatalog.GetString ("the file '{0}'"), Path.GetFileName(source));
                ask = false;
            } else {
                return;
            }

            if (targetPath == targetProject.BaseDirectory)
                where = string.Format (GettextCatalog.GetString ("root folder of project '{0}'"), targetProject.Name);
            else
                where = string.Format (GettextCatalog.GetString ("folder '{0}'"), Path.GetFileName (targetPath));

            if (ask) {
                if (!Runtime.MessageService.AskQuestion (String.Format (GettextCatalog.GetString ("Do you really want to {0} {1} to {2}?"), how, what, where)))
                    return;
            }

            using (IProgressMonitor monitor = Runtime.TaskService.GetStatusProgressMonitor (GettextCatalog.GetString("Copying files ..."), Stock.CopyIcon, true))
            {
                bool move = operation == DragOperation.Move;
                Runtime.ProjectService.TransferFiles (monitor, sourceProject, source, targetProject, targetPath, move, false);
            }
            Runtime.ProjectService.SaveCombine();
        }
		public override void OnNodeDrop (object dataObject, DragOperation operation)
		{
		}
예제 #49
0
        //
        // OnDragDrop event handler. Ends a node dragging
        //
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);

            // Cancel if no node is being dragged
            if (_draggedItems == null)
            {
                _timer.Start();

                return;
            }

            if (drgevent.Effect == DragDropEffects.None)
            {
                // Set drag node and temp drop node to null
                _draggedItems = null;
                _tempDropItem = null;

                // Disable scroll timer
                _timer.Enabled = false;

                _timer.Start();

                return;
            }

            if (InsertionMark.Index == -1)
            {
                _timer.Start();

                return;
            }

            // Get drop item
            ListViewItem dropItem = Items[InsertionMark.Index];

            // Launch the feedback for the drag operation
            ListViewItemDragEventArgs evArgs = new ListViewItemDragEventArgs(ListViewItemDragEventType.DragEnd, ListViewItemDragEventBehavior.PlaceBeforeOrAfterAuto, _draggedItems, dropItem);

            if (DragOperation != null)
            {
                DragOperation(evArgs);

                // Cancel the operation if the user specified so
                if (evArgs.Cancel)
                {
                    _timer.Start();

                    return;
                }
            }

            // If drop node isn't equal to drag node, add drag node as child of drop node
            if (_draggedItems[0] != dropItem)
            {
                int index = InsertionMark.Index;

                SelectedItems.Clear();

                foreach (ListViewItem item in _draggedItems)
                {
                    Items.Remove(item);
                    Items.Add(item);

                    item.Selected = true;
                }

                // Deal with a bug from the framework that adds all items to the end even though you insert
                // them at other indexes by also pushing all items after the current selection to the end

                for (int i = index; i < Items.Count - SelectedItems.Count; i++)
                {
                    ListViewItem item = Items[index];

                    Items.Remove(item);
                    Items.Add(item);
                }

                // Launch the feedback for the drag operation
                evArgs = new ListViewItemDragEventArgs(ListViewItemDragEventType.AfterDragEnd, evArgs.EventBehavior, _draggedItems, dropItem);

                DragOperation?.Invoke(evArgs);

                // Set drag node and temp drop node to null
                _draggedItems = null;
                _tempDropItem = null;

                // Disable scroll timer
                _timer.Enabled = false;
            }

            _timer.Start();
        }