/// <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(); } }
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(); }
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); }
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..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSharpDevelopErrorHandler = UseExceptionBox; #endif Assembly exe = typeof(StartUp).Assembly; //startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.ApplicationRootPath = 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), "StarUp" + 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(), "StarUp" + 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)); } } StartUpHost host = new StartUpHost(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(StartupArguments startupArguments) { #if DEBUG // The output encoding differs based on whether the app 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. // 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 the application doesn't have a console appended } #endif Current.Log.Info(string.Format("Starting {0}...", startupArguments.ApplicationName)); Altaxo.Main.Services.IAutoUpdateInstallationService updateInstaller = null; try { var startupSettings = new StartupSettings(startupArguments.ApplicationName, startupArguments.StartupArgs, startupArguments.RequestedFileList, startupArguments.ParameterList); #if DEBUG startupSettings.UseExceptionBoxForErrorHandler = UseExceptionBox(startupArguments.StartupArgs); #endif Assembly thisAssembly = typeof(StartupMain).Assembly; startupSettings.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(thisAssembly.Location), ".."); startupSettings.AllowUserAddIns = true; string configDirectory = System.Configuration.ConfigurationManager.AppSettings["settingsPath"]; if (string.IsNullOrEmpty(configDirectory)) { string relativeConfigDirectory = System.Configuration.ConfigurationManager.AppSettings["relativeSettingsPath"]; if (string.IsNullOrEmpty(relativeConfigDirectory)) { startupSettings.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), startupArguments.ApplicationName); } else { startupSettings.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), startupArguments.ApplicationName, relativeConfigDirectory); } } else { startupSettings.ConfigDirectory = Path.Combine(Path.GetDirectoryName(thisAssembly.Location), configDirectory); } startupSettings.AddAddInsFromDirectory(Path.Combine(startupSettings.ApplicationRootPath, "AddIns")); // allows testing addins without having to install them, by providing them in a command line const string addinCommandStart = "addindir:"; foreach (string parameter in startupSettings.ParameterList) { if (parameter.StartsWith(addinCommandStart, StringComparison.OrdinalIgnoreCase)) { startupSettings.AddAddInsFromDirectory(parameter.Substring(addinCommandStart.Length)); } } // Start ServiceSystem, PropertyService, ResourceService, Load Addins InitializeApplication(startupSettings); // initialize core, load all addins if (startupSettings.RequestedFileList.Length > 0) { if (LoadFilesInPreviousInstance(startupSettings.RequestedFileList)) { Current.Log.Info("Aborting startup, arguments will be handled by previous instance"); return; } } updateInstaller = Altaxo.Current.GetService <Altaxo.Main.Services.IAutoUpdateInstallationService>(); if (null != updateInstaller) { if (updateInstaller.Run(true, startupArguments.StartupArgs)) { return; } } // Start Com var comManager = Altaxo.Current.GetService <Altaxo.Main.IComManager>(); if (null != comManager) { if (!comManager.ProcessStartupArguments(startupArguments.StartupArgs)) { return; } } RunWorkbench( startupSettings, () => { var splashScreen = SplashScreenForm.SplashScreen; if (splashScreen != null) { splashScreen.BeginInvoke(new MethodInvoker(splashScreen.Dispose)); SplashScreenForm.SplashScreen = null; } }, null); } finally { Current.Log.Info("Leaving RunApplication()"); } updateInstaller?.Run(false, null); }
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()"); } }
/// <summary> /// 运行应用程序。 /// </summary> static void RunApplication() { // The output encoding differs based on whether FanHai Gui Framework 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 SolarViewerFramework. #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 FanHai Gui Framework doesn't have a console } #endif LoggingService.Info("Starting MES Gui Framework..."); try { StartupSettings startup = new StartupSettings(); #if DEBUG startup.UseSolarViewerFrameworkErrorHandler = !Debugger.IsAttached; #endif Assembly exe = typeof(SolarViewerFrameworkMain).Assembly; startup.ApplicationRootPath = Path.GetDirectoryName(exe.Location); startup.AllowUserAddIns = true; string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; //如果在config文件中没有配置settingsPath或配置的字符串为空。 if (String.IsNullOrEmpty(configDirectory)) { startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CHINT/AMES.1.0"); } 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(), "FanHai.Hemera.Gui.StartUp" + RevisionClass.MainVersion); #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")); foreach (string parameter in SplashScreenForm.GetParameterList()) {//如果参数以addindir:开头,将同样载入插件 if (parameter.StartsWith("addindir:", StringComparison.OrdinalIgnoreCase)) { startup.AddAddInsFromDirectory(parameter.Substring(9)); } } startup.ResourceAssemblyName = exe.FullName; SolarViewerHost host = new SolarViewerHost(AppDomain.CurrentDomain, startup); //隐藏启动画面 if (SplashScreenForm.SplashScreen != null) { SplashScreenForm.SplashScreen.Hide(); } string[] fileList = SplashScreenForm.GetRequestedFileList(); if (fileList.Length > 0) { } 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]); } //登陆对话框 LoginDialog login = new LoginDialog(); login.ShowDialog(); if (LoginDialog.flag) { LoggingService.CloseCmd(); return; } host.RunWorkbench(workbenchSettings); } finally { //清除注册时间。 IChannel[] channels = ChannelServices.RegisteredChannels; foreach (IChannel eachChannel in channels) { ChannelServices.UnregisterChannel(eachChannel); } LoggingService.Info("Leaving RunApplication()"); } }