/// <summary> /// Raises the on error. /// </summary> /// <param name="ex">The ex.</param> private void RaiseOnError(Exception ex) { ErrorOccuredDelegate tmp = this.OnError; if (tmp != null) { this.OnError(ex); } }
public MainWindow() { IMessageFilter oldFilter; CoRegisterMessageFilter(new RetryMessageFilter(), out oldFilter); System.Type type = null; RegistryKey masterKey = null; if (type == null) { type = System.Type.GetTypeFromProgID("VisualStudio.DTE.14.0"); masterKey = Registry.CurrentUser.OpenSubKey(MainWindow.VS2015_REGISTRY_KEYPATH); } if (type == null) { type = System.Type.GetTypeFromProgID("VisualStudio.DTE.12.0"); masterKey = Registry.CurrentUser.OpenSubKey(MainWindow.VS2013_REGISTRY_KEYPATH); } if (type == null) { type = System.Type.GetTypeFromProgID("VisualStudio.DTE.11.0"); masterKey = Registry.CurrentUser.OpenSubKey(MainWindow.VS2012_REGISTRY_KEYPATH); } if (type == null) { type = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0"); masterKey = Registry.CurrentUser.OpenSubKey(MainWindow.VS2010_REGISTRY_KEYPATH); } if (type == null || Activator.CreateInstance(type, true) == null) { MessageBox.Show(Assembly.GetExecutingAssembly().GetName().Name + " requires Visual Studio 2010, 2012, 2013, 2015 Professional or Community. It cannot work with Visual C# Express.", "", MessageBoxButton.OK, MessageBoxImage.Error); System.Environment.Exit(11); } if (masterKey != null) { SolutionGenerator.ProjectTemplateLocation = masterKey.GetValue(MainWindow.VS_USERPROJECTTEMPLATEPATH_REGISTRY_KEYNAME, "").ToString(); } if (string.IsNullOrEmpty(SolutionGenerator.ProjectTemplateLocation)) { MessageBox.Show(Assembly.GetExecutingAssembly().GetName().Name + " cannot find Visual Studio registry information. Have you run Visual Studio at least once?", "", MessageBoxButton.OK, MessageBoxImage.Error); System.Environment.Exit(11); } InitializeComponent(); errorWindow = new ErrorWindow(this); errorwindowdel = errorWindow.Display; erroroccureddel = this.SetError; for (int i = 0; i <= 24; ++i) { SolutionGenerator.AddonEventSelection[i] = false; } // Store AddOn events enum map for easier access later SolutionGenerator.AddonEvents = new Dictionary <int, string>(); SolutionGenerator.AddonEvents.Add(0, "OBJEVENT_CREATED"); SolutionGenerator.AddonEvents.Add(1, "OBJEVENT_ATTR"); SolutionGenerator.AddonEvents.Add(2, "OBJEVENT_REGISTRY"); SolutionGenerator.AddonEvents.Add(3, "OBJEVENT_NEWCHILD"); SolutionGenerator.AddonEvents.Add(4, "OBJEVENT_RELATION"); SolutionGenerator.AddonEvents.Add(5, "OBJEVENT_PROPERTIES"); SolutionGenerator.AddonEvents.Add(6, "OBJEVENT_SUBT_INST"); SolutionGenerator.AddonEvents.Add(7, "OBJEVENT_PARENT"); SolutionGenerator.AddonEvents.Add(8, "OBJEVENT_LOSTCHILD"); SolutionGenerator.AddonEvents.Add(9, "OBJEVENT_REFERENCED"); SolutionGenerator.AddonEvents.Add(10, "OBJEVENT_CONNECTED"); SolutionGenerator.AddonEvents.Add(11, "OBJEVENT_SETINCLUDED"); SolutionGenerator.AddonEvents.Add(12, "OBJEVENT_REFRELEASED"); SolutionGenerator.AddonEvents.Add(13, "OBJEVENT_DISCONNECTED"); SolutionGenerator.AddonEvents.Add(14, "OBJEVENT_SETEXCLUDED"); SolutionGenerator.AddonEvents.Add(15, "OBJEVENT_MARKEDRO"); SolutionGenerator.AddonEvents.Add(16, "OBJEVENT_MARKEDRW"); SolutionGenerator.AddonEvents.Add(17, "OBJEVENT_OPENMODEL"); SolutionGenerator.AddonEvents.Add(18, "OBJEVENT_SELECT"); SolutionGenerator.AddonEvents.Add(19, "OBJEVENT_DESELECT"); SolutionGenerator.AddonEvents.Add(20, "OBJEVENT_MOUSEOVER"); SolutionGenerator.AddonEvents.Add(21, "OBJEVENT_CLOSEMODEL"); SolutionGenerator.AddonEvents.Add(22, "OBJEVENT_USERBITS"); SolutionGenerator.AddonEvents.Add(23, "OBJEVENT_PRE_DESTROYED"); SolutionGenerator.AddonEvents.Add(24, "OBJEVENT_DESTROYED"); SolutionGenerator.mw = this; // Generate Guid this.txb_Guid.Text = Guid.NewGuid().ToString().ToUpper(); // Get Visual Studio Project folder if (masterKey == null) { this.txb_TargetFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); } else { // this registry value is missing if the user never started devenv.exe this.txb_TargetFolder.Text = masterKey.GetValue(MainWindow.VS_PROJECTFOLDER_REGISTRY_KEYNAME, Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)).ToString(); masterKey.Close(); } this.txb_TargetFolder.ToolTip = this.txb_TargetFolder.Text; }