public int OnQueryRemoveFiles()

in ArchivedSamples/Source_Control_Provider_Status_Bar_Integration/C#/SccProviderService.cs [903:988]


        public int OnQueryRemoveFiles([InAttribute] IVsProject pProject, [InAttribute] int cFiles, [InAttribute] string[] rgpszMkDocuments, [InAttribute] VSQUERYREMOVEFILEFLAGS[] rgFlags, [OutAttribute] VSQUERYREMOVEFILERESULTS[] pSummaryResult, [OutAttribute] VSQUERYREMOVEFILERESULTS[] rgResults)
        {
            pSummaryResult[0] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveOK;
            if (rgResults != null)
            {
                for (int iFile = 0; iFile < cFiles; iFile++)
                {
                    rgResults[iFile] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveOK;
                }
            }

            try
            {
                IVsSccProject2 sccProject = pProject as IVsSccProject2;
                IVsHierarchy pHier = pProject as IVsHierarchy;
                string projectName = null;
                if (sccProject == null)
                {
                    // This is the solution calling
                    pHier = (IVsHierarchy)_sccProvider.GetService(typeof(SVsSolution));
                    projectName = _sccProvider.GetSolutionFileName();
                }
                else
                {
                    // If the project doesn't support source control, it will be skipped
                    if (sccProject != null)
                    {
                        projectName = _sccProvider.GetProjectFileName(sccProject);
                    }
                }
                
                if (projectName != null)
                {
                    for (int iFile = 0; iFile < cFiles; iFile++)
                    {
                        SccProviderStorage storage = _controlledProjects[pHier] as SccProviderStorage;
                        if (storage != null)
                        {
                            SourceControlStatus status = storage.GetFileStatus(rgpszMkDocuments[iFile]);
                            if (status != SourceControlStatus.scsUncontrolled)
                            {
                                // This is a controlled file, warn the user
                                IVsUIShell uiShell = (IVsUIShell)_sccProvider.GetService(typeof(SVsUIShell));
                                Guid clsid = Guid.Empty;
                                int result = VSConstants.S_OK;
                                string messageText = Resources.ResourceManager.GetString("TPD_DeleteControlledFile"); 
					            string messageCaption = Resources.ResourceManager.GetString("ProviderName");
                                if (uiShell.ShowMessageBox(0, ref clsid,
                                                    messageCaption,
                                                    String.Format(CultureInfo.CurrentUICulture, messageText, rgpszMkDocuments[iFile]),
                                                    string.Empty,
                                                    0,
                                                    OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                                                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                                                    OLEMSGICON.OLEMSGICON_QUERY,
                                                    0,        // false = application modal; true would make it system modal
                                                    out result) != VSConstants.S_OK
                                    || result != (int)DialogResult.Yes)
                                {
                                    pSummaryResult[0] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveNotOK;
                                    if (rgResults != null)
                                    {
                                        rgResults[iFile] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveNotOK;
                                    }
                                    // Don't spend time iterating through the rest of the files once the rename has been cancelled
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                pSummaryResult[0] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveNotOK;
                if (rgResults != null)
                {
                    for (int iFile = 0; iFile < cFiles; iFile++)
                    {
                        rgResults[iFile] = VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveNotOK;
                    }
                }
            }
            
            return VSConstants.S_OK;
        }