public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"QtGuiApplication"; } data.ClassName = className; data.BaseClass = @"QMainWindow"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.UiFile = data.ClassName + @".ui"; data.QrcFile = data.ClassName + @".qrc"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new GuiPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt GUI Application Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; replacements["$DefaultApplicationIcon$"] = string.Empty; replacements["$centralwidget$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; replacements["$qrcfilename$"] = data.QrcFile; if (data.BaseClass == "QMainWindow") { replacements["$centralwidget$"] = "\r\n <widget class=\"QMenuBar\" name=\"menuBar\" />" + "\r\n <widget class=\"QToolBar\" name=\"mainToolBar\" />" + "\r\n <widget class=\"QWidget\" name=\"centralWidget\" />" + "\r\n <widget class=\"QStatusBar\" name=\"statusBar\" />"; } if (data.AddDefaultAppIcon) { replacements["$DefaultApplicationIcon$"] = "<None Include=\"gui.ico\" />"; } if (vi.isWinRT()) { replacements["$QtWinRT$"] = "true"; var projDir = replacements["$destinationdirectory$"]; var qmakeTmpDir = Path.Combine(projDir, "qmake_tmp"); Directory.CreateDirectory(qmakeTmpDir); var dummyPro = Path.Combine(qmakeTmpDir, string.Format("{0}.pro", replacements["$projectname$"])); File.WriteAllText(dummyPro, "SOURCES = main.cpp\r\n"); var qmake = new QMake(null, dummyPro, false, vi); qmake.RunQMake(); var assetsDir = Path.Combine(qmakeTmpDir, "assets"); if (Directory.Exists(assetsDir)) { Directory.Move(assetsDir, Path.Combine(projDir, "assets")); } var manifestFile = Path.Combine(qmakeTmpDir, "Package.appxmanifest"); if (File.Exists(manifestFile)) { File.Move(manifestFile, Path.Combine(projDir, "Package.appxmanifest")); } var projFile = Path.Combine(qmakeTmpDir, string.Format("{0}.vcxproj", replacements["$projectname$"])); var proj = MsBuildProject.Load(projFile); replacements["$MinimumVisualStudioVersion$"] = proj.GetProperty("MinimumVisualStudioVersion"); replacements["$ApplicationTypeRevision$"] = proj.GetProperty("ApplicationTypeRevision"); replacements["$WindowsTargetPlatformVersion$"] = proj.GetProperty("WindowsTargetPlatformVersion"); replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; replacements["$WindowsTargetPlatformMinVersion$"] = proj.GetProperty("WindowsTargetPlatformMinVersion"); replacements["$Link_TargetMachine$"] = proj.GetProperty("Link", "TargetMachine"); Directory.Delete(qmakeTmpDir, true); } #if (VS2017 || VS2015) else { string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); var safeprojectname = replacements["$safeprojectname$"]; safeprojectname = Regex.Replace(safeprojectname, @"[^a-zA-Z0-9_]", string.Empty); safeprojectname = Regex.Replace(safeprojectname, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(safeprojectname, null); if (result != ValidationResult.ValidResult) { safeprojectname = @"QtClassLibrary"; } try { data.ClassName = safeprojectname; data.ClassHeaderFile = safeprojectname + @".h"; data.ClassSourceFile = safeprojectname + @".cpp"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"This wizard generates a Qt Class Library project. The " + @"resulting library is linked dynamically with Qt." + System.Environment.NewLine + System.Environment.NewLine + @"To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new LibraryClassPage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"This wizard generates a Qt Class Library project. The " + @"resulting library is linked dynamically with Qt.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = QtModuleInfo.IsInstalled(@"QtCore"), CancelButtonEnabled = true } }) { Title = @"Qt Class Library Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception(@"Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$saveglobal$"] = safeprojectname.ToLower(); projectDefine = safeprojectname.ToUpper() + @"_LIB"; replacements["$pro_lib_define$"] = projectDefine; replacements["$pro_lib_export$"] = safeprojectname.ToUpper() + @"_EXPORT"; if (vi.isWinRT()) { replacements["$QtWinRT$"] = "true"; } #if (VS2017 || VS2015) string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); className = Regex.Replace(className, @"[pP][lL][uU][gG][iI][nN]$", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"MyDesignerWidget"; } data.ClassName = className; data.BaseClass = @"QWidget"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.PluginClass = className + @"Plugin"; data.PluginHeaderFile = data.PluginClass + @".h"; data.PluginSourceFile = data.PluginClass + @".cpp"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"This wizard generates a custom designer widget which can be " + @"used in Qt Designer or Visual Studio." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new DesignerPage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"This wizard generates a custom designer widget which can be " + @"used in Qt Designer or Visual Studio.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt Custom Designer Widget" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = version.Replace(".", string.Empty); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$plugin_class$"] = data.PluginClass; replacements["$pluginsourcefilename$"] = data.PluginSourceFile; replacements["$pluginheaderfilename$"] = data.PluginHeaderFile; replacements["$plugin_json$"] = data.PluginClass.ToLower() + @".json"; replacements["$objname$"] = char.ToLower(data.ClassName[0]) + data.ClassName .Substring(1); replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); var versionMgr = QtVersionManager.The(); var versionName = versionMgr.GetDefaultVersion(); var versionInfo = VersionInformation.Get(versionMgr.GetInstallPath(versionName)); if (versionInfo.isWinRT()) { MessageBox.Show( string.Format( "The Qt ActiveQt Server project type is not available\r\n" + "for the currently selected Qt version ({0}).", versionName), "Project Type Not Available", MessageBoxButtons.OK, MessageBoxIcon.Error); iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { // midl.exe does not support spaces in project name. Fails while generating the // IDL file (library attribute), e.g. 'library Active QtServer1Lib' is illegal. if (replacements["$safeprojectname$"].Contains(" ")) { throw new QtVSException("Project name shall not contain spaces."); } safeprojectname = replacements["$safeprojectname$"]; var result = new ClassNameValidationRule().Validate(safeprojectname, null); if (result != ValidationResult.ValidResult) { safeprojectname = @"ActiveQtServer"; } data.ClassName = safeprojectname; data.ClassHeaderFile = safeprojectname + @".h"; data.ClassSourceFile = safeprojectname + @".cpp"; data.UiFile = data.ClassName + @".ui"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"This wizard generates a Qt ActiveQt server project. It " + @"creates a simple ActiveQt widget with the required files." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ServerPage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"This wizard generates a Qt ActiveQt server project. It " + @"creates a simple ActiveQt widget with the required files.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt ActiveQt Server Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; replacements["$Platform$"] = versionInfo.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; safeprojectname = data.LowerCaseFileNames ? safeprojectname.ToLower() : safeprojectname; replacements["$pro_name$"] = safeprojectname; #if (VS2017 || VS2015) string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"QtGuiApplication"; } data.ClassName = className; data.BaseClass = @"QMainWindow"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.UiFile = data.ClassName + @".ui"; data.QrcFile = data.ClassName + @".qrc"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new GuiPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt GUI Application Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = version.Replace(".", string.Empty); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; replacements["$DefaultApplicationIcon$"] = string.Empty; replacements["$centralwidget$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; replacements["$qrcfilename$"] = data.QrcFile; if (data.BaseClass == "QMainWindow") { replacements["$centralwidget$"] = "\r\n <widget class=\"QMenuBar\" name=\"menuBar\" />" + "\r\n <widget class=\"QToolBar\" name=\"mainToolBar\" />" + "\r\n <widget class=\"QWidget\" name=\"centralWidget\" />" + "\r\n <widget class=\"QStatusBar\" name=\"statusBar\" />"; } if (data.AddDefaultAppIcon) { replacements["$DefaultApplicationIcon$"] = "<None Include=\"gui.ico\" />"; } } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public WizardResult Run(EnvDTE.DTE dte, string name, string location) { IVsUIShell iVsUIShell = null; ServiceProvider serviceProvider = null; try { serviceProvider = new ServiceProvider(dte as IServiceProvider); iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; } catch { return(WizardResult.Exception); } iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); var addClassPage = new AddClassPage { Location = location }; var wizard = new WizardWindow(new List <WizardPage> { addClassPage }) { Width = 955, Height = 660, MinWidth = 800, MinHeight = 450, Title = @"Add Class - " + name, MaxWidth = double.PositiveInfinity, MaxHeight = double.PositiveInfinity, ResizeMode = System.Windows.ResizeMode.CanResize }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.GetValueOrDefault(false)) { return(WizardResult.Canceled); } IClassWizard classWizard = null; switch (addClassPage.Class.Kind) { case ClassKind.Gui: classWizard = new GuiClassWizard(); break; case ClassKind.Core: classWizard = new CoreClassWizard(); break; default: throw new System.Exception("Unexpected class kind."); } var className = addClassPage.Class.DefaultName; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = string.Empty; } classWizard.Run(dte, className, addClassPage.Location); } catch { return(WizardResult.Exception); } finally { iVsUIShell.EnableModeless(1); } return(WizardResult.Finished); }