protected override void OnApply(PageApplyEventArgs e) { var actualPathToExeChanged = false; if (ActualPathToExe != previousActualPathToExe) { actualPathToExeChanged = true; previousActualPathToExe = ActualPathToExe; } if (actualPathToExeChanged) { if (!CommonFileHelper.DoesFileExist(ActualPathToExe)) { e.ApplyBehavior = ApplyKind.Cancel; new FileHelper().PromptForActualExeFile(ActualPathToExe); } } base.OnApply(e); }
private void MenuItemCallback(object sender, EventArgs e) { var dte = (DTE2)ServiceProvider.GetService(typeof(DTE)); try { var actualPathToExeExists = CommonFileHelper.DoesFileExist(VSPackage.Options.ActualPathToExe); bool proceedToExecute = true; if (!actualPathToExeExists) { proceedToExecute = false; FileHelper.PromptForActualExeFile(VSPackage.Options.ActualPathToExe); var newActualPathToExeExists = CommonFileHelper.DoesFileExist(VSPackage.Options.ActualPathToExe); if (newActualPathToExeExists) { proceedToExecute = true; } else { // User somehow managed to browse/select a new location for the exe that doesn't actually exist - virtually impossible, but you never know... OpenInAppHelper.InformUserMissingFile(Caption, VSPackage.Options.ActualPathToExe); } } if (proceedToExecute) { var actualFilesToBeOpened = CommonFileHelper.GetFileNamesToBeOpened(dte); var actualFilesToBeOpenedExist = CommonFileHelper.DoFilesExist(actualFilesToBeOpened); if (!actualFilesToBeOpenedExist) { var missingFileName = CommonFileHelper.GetMissingFileName(actualFilesToBeOpened); OpenInAppHelper.InformUserMissingFile(Caption, missingFileName); } else { var fileQuantityWarningLimitInt = VSPackage.Options.FileQuantityWarningLimitInt; proceedToExecute = false; if (actualFilesToBeOpened.Count() > fileQuantityWarningLimitInt) { proceedToExecute = OpenInAppHelper.ConfirmProceedToExecute(Caption, CommonConstants.ConfirmOpenFileQuantityExceedsWarningLimit); } else { proceedToExecute = true; } if (proceedToExecute) { var typicalFileExtensionAsList = CommonFileHelper.GetTypicalFileExtensionAsList(VSPackage.Options.TypicalFileExtensions); var areTypicalFileExtensions = CommonFileHelper.AreTypicalFileExtensions(actualFilesToBeOpened, typicalFileExtensionAsList); if (!areTypicalFileExtensions) { if (VSPackage.Options.SuppressTypicalFileExtensionsWarning) { proceedToExecute = true; } else { proceedToExecute = OpenInAppHelper.ConfirmProceedToExecute(Caption, CommonConstants.ConfirmOpenNonTypicalFile); } } if (proceedToExecute) { OpenInAppHelper.InvokeCommand(actualFilesToBeOpened, VSPackage.Options.ActualPathToExe); } } } } } catch (Exception ex) { Logger.Log(ex); OpenInAppHelper.ShowUnexpectedError(Caption); } }