Drag and Drop VS 2010 Extension Warning File?

I am wondering if anyone knows the extension that issues a warning if you drag the file to another folder through the VS 2010 solution. Many times I will be in a file, and my computer may lag for a second, and suddenly the file is now in some other folder, and I can’t even notice it.

+6
source share
2 answers

There is a Visual Studio extension called VSCommands 2010 that has the Prevent accidental drag and drop feature in Solution Explorer.

enter image description here

Edit This feature is part of the Pro package, which is not free.

+7
source

I don’t know the free Visual Studio extension that would do this, but here is a C # Addin sample demonstrating how to connect to the global deletion and renaming of files in Visual Studio. It is based on the IVsTrackProjectDocumentsEvents2 interface .

You will need to extend the two OnQueryxxx methods to suit your needs.

using System; using System.Diagnostics; using EnvDTE; using EnvDTE80; using Extensibility; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; namespace MyAddin1 { public class Connect : IDTExtensibility2, IVsTrackProjectDocumentsEvents2 { private uint _trackerCookie; public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; // the Addin project needs assembly references to Microsoft.VisualStudio.Shell, Microsoft.VisualStudio.Shell.Interop && Microsoft.VisualStudio.OLE.Interop // any version should do ServiceProvider sp = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_applicationObject); IVsTrackProjectDocuments2 tracker = (IVsTrackProjectDocuments2)sp.GetService(typeof(SVsTrackProjectDocuments)); // ask VS to notify us of files & directories changes tracker.AdviseTrackProjectDocumentsEvents(this, out _trackerCookie); } public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom) { if (_trackerCookie != 0) { // we quit, tell VS not to notify us anymore ServiceProvider sp = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_applicationObject); IVsTrackProjectDocuments2 tracker = (IVsTrackProjectDocuments2)sp.GetService(typeof(SVsTrackProjectDocuments)); tracker.UnadviseTrackProjectDocumentsEvents(_trackerCookie); _trackerCookie = 0; } } public int OnQueryRenameFiles(IVsProject pProject, int cFiles, string[] rgszMkOldNames, string[] rgszMkNewNames, VSQUERYRENAMEFILEFLAGS[] rgFlags, VSQUERYRENAMEFILERESULTS[] pSummaryResult, VSQUERYRENAMEFILERESULTS[] rgResults) { Trace.WriteLine("OnQueryRenameFiles pProject:" + pProject + " old[0]:" + rgszMkOldNames[0] + " new[0]:" + rgszMkNewNames[0]); // TODO: implement this (I have assumed cFiles is 1 here) if (!NotRenameOk(old[0], new[0]) { rgResults[0] = VSQUERYRENAMEFILERESULTS.VSQUERYRENAMEFILERESULTS_RenameNotOK; // nope, it not ok } return 0; } public int OnQueryRemoveFiles(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSQUERYREMOVEFILEFLAGS[] rgFlags, VSQUERYREMOVEFILERESULTS[] pSummaryResult, VSQUERYREMOVEFILERESULTS[] rgResults) { Trace.WriteLine("OnQueryRemoveFiles pProject:" + pProject + " file[0]:" + rgpszMkDocuments[0]); // TODO: needs to be implemented, use rgResults to tell VS if it ok or not return 0; } // other IVsTrackProjectDocumentsEvents2 methods implementation omitted for brevity... 
0
source

Source: https://habr.com/ru/post/909682/


All Articles