public ZipNShareConfigDialog(ZipNShareTools toolsPage) : this() { this.toolsPage = toolsPage; ZipNShareConfigViewModel model = (ZipNShareConfigViewModel)this.DataContext; model.PropertyChanged += model_PropertyChanged; model.Initialize(toolsPage); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void OptionsMenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; ZipNShareTools toolsPage = (ZipNShareTools)GetDialogPage(typeof(ZipNShareTools)); ZipNShareConfigDialog dialog = new ZipNShareConfigDialog(toolsPage); bool dialogResult = (bool)dialog.ShowDialog(); if (dialogResult && dialog.TriggerRun) { ArchiveFiles(); } }
private void ArchiveFiles() { ZipNShareTools toolsPage = (ZipNShareTools)GetDialogPage(typeof(ZipNShareTools)); string exclusions = string.Empty; exclusions = string.Concat(toolsPage.Exceptions); string folderName = toolsPage.OutputFolder; DTE devenv = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; int numberOfFiles = 0; if (devenv.Solution.Count > 0) { Solution soln = devenv.Solution; string fullName = soln.FullName; string solutionFolder = Path.GetDirectoryName(soln.FullName); string solutionName = Path.GetFileNameWithoutExtension(soln.FullName); numberOfFiles = Archiving.ZipSolution.CreateArchive(solutionFolder, toolsPage.Exceptions, toolsPage.OutputFileName.Replace("%SOLUTION_NAME%", solutionName), toolsPage.OutputFolder, toolsPage.OverwriteZipFileIfExists); } IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( 0, ref clsid, "ZipNShare", string.Format(CultureInfo.CurrentCulture, "FolderName: {0} {1}Exclusions: {2} {1}Number of Files Zipped: {3}", folderName, Environment.NewLine, exclusions, numberOfFiles), string.Empty, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_INFO, 0, // false out numberOfFiles)); }