private void ConfigureEnviorenment() { if (_sdHost != null) { return; } //TODO AA : review initialisation _startupSettings = new StartupSettings { ApplicationName = "CustomSharpDevelop", AllowUserAddIns = true, ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop3.0"), DataDirectory = _sdDataDir, ApplicationRootPath = _sdRootDir }; //TODO AA : implement loading custom addin configuration _startupSettings.AddAddInsFromDirectory(Path.Combine(_sdAddInDir, "AddIns")); //Loading customised #D config file _startupSettings.AddAddInFile(Path.Combine(Application.StartupPath, SDConfigFile)); AppDomain.CurrentDomain.AssemblyResolve += LoadAssemlbyFromProductInstallationFolder; _sdHost = new SharpDevelopHost(AppDomain.CurrentDomain, _startupSettings); _workbenchSettings = new WorkbenchSettings(); assignHandlers(); }
/// <summary> /// Preparing IDE host enviorenment part 2 /// </summary> private void ConfigureEnviorenment() { Console.WriteLine("ConfigureEnviorenment()"); if (host == null) { startup = new StartupSettings { ApplicationName = "zebSharpDevelop", AllowUserAddIns = true, ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop3.0"), DataDirectory = dataDir, ApplicationRootPath = baseDir }; startup.AddAddInsFromDirectory(addInDir); //Loading customised #D config file startup.AddAddInFile(Path.Combine(Application.StartupPath, sdConfigFile)); var currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += LoadAssemlbyFromProductInstallationFolder; host = new SharpDevelopHost(AppDomain.CurrentDomain, startup) { InvokeTarget = invokeTarget }; assignHandlers(); workbenchSettings = new WorkbenchSettings(); } }
public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } startup.ConfigDirectory = properties.ConfigDirectory; startup.DataDirectory = properties.DataDirectory; if (properties.PropertiesName != null) { startup.PropertiesName = properties.PropertiesName; } // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); MenuCommand.LinkCommandCreator = delegate(string link) { return new LinkCommand(link); }; StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); // Register events to marshal back Project.ProjectService.StartBuild += delegate { this.callback.StartBuild(); }; Project.ProjectService.EndBuild += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
void UnloadHostDomainButtonClick(object sender, System.EventArgs e) { unloadHostDomainButton.Enabled = false; host.UnloadDomain(); host = null; // disable the group box so no events are fired groupBox1.Enabled = false; }
void RunWorkbench(WorkbenchSettings wbSettings) { if (host == null) { StartupSettings startup = new StartupSettings(); startup.ApplicationName = "HostedSharpDevelop"; startup.DataDirectory = Path.Combine(Path.GetDirectoryName(typeof(SharpDevelopHost).Assembly.Location), "../data"); string sdaDir = Path.Combine(Path.GetDirectoryName(typeof(MainForm).Assembly.Location), "SdaAddIns"); startup.AddAddInFile(Path.Combine(sdaDir, "SdaBase.addin")); host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); host.InvokeTarget = this; host.BeforeRunWorkbench += delegate { groupBox1.Enabled = true; }; host.WorkbenchClosed += delegate { groupBox1.Enabled = false; runButton.Enabled = true; }; } host.RunWorkbench(wbSettings); }
private void ConfigureEnviorenment() { if (host != null) { return; } startup = new StartupSettings { AllowUserAddIns = true, DataDirectory = dataDir }; startup.AddAddInsFromDirectory(addInDir); host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); workbenchSettings = new WorkbenchSettings(); RunIDE(); }
void RunWorkbench(WorkbenchSettings wbSettings) { if (host == null) { StartupSettings startup = new StartupSettings(); startup.ApplicationName = "HostedSharpDevelop"; startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode\\HostedSharpDevelop4"); startup.DataDirectory = Path.Combine(Path.GetDirectoryName(typeof(SharpDevelopHost).Assembly.Location), "../data"); string sdaAddInDir = Path.Combine(Path.GetDirectoryName(typeof(MainForm).Assembly.Location), "SdaAddIns"); startup.AddAddInsFromDirectory(sdaAddInDir); host = new SharpDevelopHost(startup); host.InvokeTarget = this; host.BeforeRunWorkbench += delegate { groupBox1.Enabled = true; }; host.WorkbenchClosed += delegate { groupBox1.Enabled = false; }; } host.RunWorkbench(wbSettings); }
void RunWorkbench(WorkbenchSettings wbSettings) { if (host == null) { StartupSettings startup = new StartupSettings(); startup.ApplicationName = "HostedSharpDevelop"; startup.DataDirectory = Path.Combine(Path.GetDirectoryName(typeof(SharpDevelopHost).Assembly.Location), "../data"); string sdaDir = Path.Combine(Path.GetDirectoryName(typeof(MainForm).Assembly.Location), "SdaAddIns"); startup.AddAddInFile(Path.Combine(sdaDir, "SdaBase.addin")); host = new SharpDevelopHost(startup); host.InvokeTarget = this; host.BeforeRunWorkbench += delegate { groupBox1.Enabled = true; }; host.WorkbenchClosed += delegate { groupBox1.Enabled = false; runButton.Enabled = true; }; } host.RunWorkbench(wbSettings); }
static void RunApplication() { // The output encoding differs based on whether SharpDevelop is a console app (debug mode) // or Windows app (release mode). Because this flag also affects the default encoding // when reading from other processes' standard output, we explicitly set the encoding to get // consistent behaviour in debug and release builds of SharpDevelop. #if DEBUG // Console apps use the system's OEM codepage, windows apps the ANSI codepage. // We'll always use the Windows (ANSI) codepage. try { Console.OutputEncoding = System.Text.Encoding.Default; } catch (IOException) { // can happen if SharpDevelop doesn't have a console } #endif LoggingService.Info("Starting TickZoomGUI..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = !Debugger.IsAttached; #endif Assembly exe = typeof(SharpDevelopMain).Assembly; startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), @"..\..\..\SODA"); startup.AllowUserAddIns = true; string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; if (String.IsNullOrEmpty(configDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TickZoom/TickZoomGUI"); } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); } startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "TickZoomIDE1.0.X.X"); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif } else if (startup.DomPersistencePath == "none") { startup.DomPersistencePath = null; } startup.AddAddInFile("AddIns/TickZoomGUI.addin"); // startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, @"AddIns\AddIns")); // startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); // allows testing addins without having to install them foreach (string parameter in SplashScreenForm.GetParameterList()) { if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } }
private static void RunApplication() { #if ModifiedForAltaxo var originalUICulture = System.Globalization.CultureInfo.CurrentUICulture; var originalCulture = System.Globalization.CultureInfo.CurrentCulture; #endif // The output encoding differs based on whether SharpDevelop is a console app (debug mode) // or Windows app (release mode). Because this flag also affects the default encoding // when reading from other processes' standard output, we explicitly set the encoding to get // consistent behaviour in debug and release builds of SharpDevelop. #if DEBUG // Console apps use the system's OEM codepage, windows apps the ANSI codepage. // We'll always use the Windows (ANSI) codepage. try { Console.OutputEncoding = System.Text.Encoding.Default; } catch (IOException) { // can happen if SharpDevelop doesn't have a console } #endif LoggingService.Info("Starting SharpDevelop..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = UseExceptionBox; #endif Assembly exe = typeof(SharpDevelopMain).Assembly; startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.AllowUserAddIns = true; string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; if (String.IsNullOrEmpty(configDirectory)) { #if ModifiedForAltaxo startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Altaxo\\Altaxo4"); startup.ResourceAssemblyName = "AltaxoStartup"; ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("Resources.AltaxoString", exe)); ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("Resources.AltaxoBitmap", exe)); #else startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); #endif } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); } startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif } else if (startup.DomPersistencePath == "none") { startup.DomPersistencePath = null; } startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); // allows testing addins without having to install them foreach (string parameter in SplashScreenForm.GetParameterList()) { if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; #if ModifiedForAltaxo Altaxo.Settings.CultureSettingsAtStartup.StartupUICultureInfo = originalUICulture; Altaxo.Settings.CultureSettingsAtStartup.StartupDocumentCultureInfo = originalCulture; Altaxo.Current.SetPropertyService(new Altaxo.Main.Services.PropertyService()); Altaxo.Main.Commands.AutostartCommand.EarlyRun(CommandLineArgs); if (Altaxo.Serialization.AutoUpdates.UpdateInstallerStarter.Run(true, SharpDevelopMain.CommandLineArgs)) return; var comManager = new Altaxo.Com.ComManager(new Altaxo.Com.AltaxoComApplicationAdapter()); Altaxo.Current.SetComManager(comManager); comManager.ProcessArguments(CommandLineArgs); if (comManager.ApplicationShouldExitAfterProcessingArgs) return; var altaxoWb = new Altaxo.Gui.SharpDevelop.AltaxoSDWorkbench(); Altaxo.Current.SetWorkbench(altaxoWb); WorkbenchSingleton.InitializeWorkbench(altaxoWb, new ICSharpCode.SharpDevelop.Gui.AvalonDockLayout()); new Altaxo.Main.Commands.AutostartCommand().Run(); if (comManager.ApplicationWasStartedWithEmbeddingArg) { //System.Diagnostics.Debugger.Launch(); comManager.StartLocalServer(); } #endif WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } #if ModifiedForAltaxo Altaxo.Serialization.AutoUpdates.UpdateInstallerStarter.Run(false, null); #endif }
static void RunApplication() { LoggingService.Info("Starting SharpDevelop..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = !Debugger.IsAttached; #endif Assembly exe = typeof(SharpDevelopMain).Assembly; startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.AllowUserAddIns = true; #if ModifiedForAltaxo startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Altaxo/Altaxo2"); startup.ResourceAssemblyName = "AltaxoStartup"; #else startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop2.1"); #endif startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); #if ModifiedForAltaxo ResourceService.LoadUserStrings("AltaxoString.resources"); ResourceService.LoadUserIcons("AltaxoBitmap.resources"); #endif string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; #if ModifiedForAltaxo WorkbenchSingleton.InitializeWorkbench(typeof(Altaxo.Gui.SharpDevelop.AltaxoSDWorkbench)); Altaxo.Current.SetWorkbench((Altaxo.Gui.Common.IWorkbench)WorkbenchSingleton.Workbench); new Altaxo.Main.Commands.AutostartCommand().Run(); #endif WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; workbenchSettings.UseTipOfTheDay = true; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } }
static void RunApplication() { // The output encoding differs based on whether SharpDevelop is a console app (debug mode) // or Windows app (release mode). Because this flag also affects the default encoding // when reading from other processes' standard output, we explicitly set the encoding to get // consistent behaviour in debug and release builds of SharpDevelop. #if DEBUG // Console apps use the system's OEM codepage, windows apps the ANSI codepage. // We'll always use the Windows (ANSI) codepage. try { Console.OutputEncoding = System.Text.Encoding.Default; } catch (IOException) { // can happen if SharpDevelop doesn't have a console } #endif //LoggingService的内部变量负责输出 LoggingService.Info("Starting SharpDevelop..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = UseExceptionBox; #endif //获取包含SharpDevelopMain类型的程序集 Assembly实例 Assembly exe = typeof(SharpDevelopMain).Assembly; //exe.Location 可执行程序的位置 //可执行程序的上级目录 ApplicationRootPath startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.AllowUserAddIns = true; string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; //此处是对软件的配置信息目录进行处理的部分 if (String.IsNullOrEmpty(configDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop" + RevisionClass.Major); } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); } startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif } else if (startup.DomPersistencePath == "none") { startup.DomPersistencePath = null; } //Addin 目录 startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); // allows testing addins without having to install them foreach (string parameter in SplashScreenForm.GetParameterList()) { if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } //以上将startup这个实例对象进行设置 作为后续调用的参数 //AppDomain 是一个独立的环境 应用程序在其中执行 //在当前环境中,执行另外一段程序集, 有点类似linux的Fork,创建一个进程后 //在进程环境中执行exec系列函数,去执行其他程序 SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } SDTraceListener.Install(); host.RunWorkbench(workbenchSettings); //启动编程界面 } finally { LoggingService.Info("Leaving RunApplication()"); } }
public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { // Initialize the most important services: var container = new SharpDevelopServiceContainer(ServiceSingleton.FallbackServiceProvider); container.AddService(typeof(IMessageService), new SDMessageService()); container.AddService(typeof(ILoggingService), new log4netLoggingService()); ServiceSingleton.ServiceProvider = container; LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } string configDirectory = properties.ConfigDirectory; string dataDirectory = properties.DataDirectory; string propertiesName; if (properties.PropertiesName != null) { propertiesName = properties.PropertiesName; } else { propertiesName = properties.ApplicationName + "Properties"; } if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } if (configDirectory == null) configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), properties.ApplicationName); var propertyService = new PropertyService( DirectoryName.Create(configDirectory), DirectoryName.Create(dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")), propertiesName); startup.StartCoreServices(propertyService); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); SD.ResourceService.RegisterNeutralStrings(new ResourceManager("ICSharpCode.SharpDevelop.Resources.StringResources", exe)); SD.ResourceService.RegisterNeutralImages(new ResourceManager("ICSharpCode.SharpDevelop.Resources.BitmapResources", exe)); CommandWrapper.LinkCommandCreator = (link => new LinkCommand(link)); CommandWrapper.WellKnownCommandCreator = Core.Presentation.MenuService.GetKnownCommand; CommandWrapper.RegisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested += eh); CommandWrapper.UnregisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested -= eh); StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(configDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(configDirectory, "AddInInstallTemp"), Path.Combine(configDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); ((AssemblyParserService)SD.AssemblyParserService).DomPersistencePath = properties.DomPersistencePath; // Register events to marshal back Project.ProjectService.BuildStarted += delegate { this.callback.StartBuild(); }; Project.ProjectService.BuildFinished += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
static void RunApplication() { // The output encoding differs based on whether SharpDevelop is a console app (debug mode) // or Windows app (release mode). Because this flag also affects the default encoding // when reading from other processes' standard output, we explicitly set the encoding to get // consistent behaviour in debug and release builds of SharpDevelop. #if DEBUG // Console apps use the system's OEM codepage, windows apps the ANSI codepage. // We'll always use the Windows (ANSI) codepage. try { Console.OutputEncoding = System.Text.Encoding.Default; } catch (IOException) { // can happen if SharpDevelop doesn't have a console } #endif LoggingService.Info("Starting SharpDevelop..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = UseExceptionBox; #endif Assembly exe = typeof(SharpDevelopMain).Assembly; startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.AllowUserAddIns = true; string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; if (String.IsNullOrEmpty(configDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode/SharpDevelop" + RevisionClass.Major); } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); } startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.Major + "." + RevisionClass.Minor); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif } else if (startup.DomPersistencePath == "none") { startup.DomPersistencePath = null; } startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); // allows testing addins without having to install them foreach (string parameter in SplashScreenForm.GetParameterList()) { if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } SDTraceListener.Install(); host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } }
public void RunApplication() { // The output encoding differs based on whether SharpDevelop is a console app (debug mode) // or Windows app (release mode). Because this flag also affects the default encoding // when reading from other processes' standard output, we explicitly set the encoding to get // consistent behaviour in debug and release builds of SharpDevelop. #if DEBUG // Console apps use the system's OEM codepage, windows apps the ANSI codepage. // We'll always use the Windows (ANSI) codepage. try { Console.OutputEncoding = System.Text.Encoding.Default; } catch (IOException) { // can happen if SharpDevelop doesn't have a console } #endif LoggingService.Info("Starting up {0}", ApplicationName); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = UseExceptionBox; #endif Assembly exe = typeof(SharpDevelopMain).Assembly; if (String.IsNullOrEmpty(AppPath)) { startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); } else { startup.ApplicationRootPath = AppPath; } startup.AllowUserAddIns = AllowUserAddIns; LoggingService.Debug("ApplicationRootPath has been set to [{0}]", startup.ApplicationRootPath); if (String.IsNullOrEmpty(ConfigDirectory)) { ConfigDirectory = ConfigurationManager.AppSettings["settingsPath"]; } if (String.IsNullOrEmpty(ConfigDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), (ApplicationName ?? "DesignerStudio") + RevisionClass.Major); } else { startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), ConfigDirectory); } LoggingService.Debug("ConfigDirectory location has been set to [{0}]", startup.ConfigDirectory); if (String.IsNullOrEmpty(DomPersistencePath)) { DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; } startup.DomPersistencePath = DomPersistencePath; if (string.IsNullOrEmpty(startup.DomPersistencePath)) { startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), (ApplicationName ?? "DesignerStudio") + RevisionClass.Major + "." + RevisionClass.Minor); #if DEBUG startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); #endif } else if (startup.DomPersistencePath == "none") { startup.DomPersistencePath = null; } LoggingService.Debug("DomPersistencePath has been set to [{0}]", startup.DomPersistencePath); if (String.IsNullOrEmpty(AddinsPath)) { AddinsPath = "AddIns"; } startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, AddinsPath)); // allows testing addins without having to install them foreach (string parameter in SplashScreenForm.GetParameterList()) { if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } if (!String.IsNullOrEmpty(ResourceAssemblyName)) { startup.ResourceAssemblyName = ResourceAssemblyName; LoggingService.Debug("ResourceAssemblyName has been set to [{0}]", ResourceAssemblyName); } LoggingService.Info("Init SharpDevelopHost with AppDomain[{0}]", AppDomain.CurrentDomain.ToString()); SharpDevelopHost host = new SharpDevelopHost(AppDomain.CurrentDomain, startup); string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { if (LoadFilesInPreviousInstance(fileList)) { LoggingService.Info("Aborting startup, arguments will be handled by previous instance"); return; } } host.BeforeRunWorkbench += delegate { if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.BeginInvoke(new MethodInvoker(SplashScreenForm.SplashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }; WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } SDTraceListener.Install(); host.RunWorkbench(workbenchSettings); } finally { LoggingService.Info("Leaving RunApplication()"); } }