public static void ShowWnd() { if (_isShown) { return; } _isShown = true; if (Environment.UserInteractive) { if (!ChoServiceCommandLineArgs.HasServiceParams()) { if (ChoApplication.ApplicationMode == ChoApplicationMode.Windows || ChoApplication.ApplicationMode == ChoApplicationMode.Console) { if (!ChoAppFrxSettings.Me.DoNotShowEnvSelectionWnd) { ChoEnvironmentDetails environmentDetails = null; ChoSharedEnvironmentManager sharedEnvironmentManager = new ChoSharedEnvironmentManager(); environmentDetails = ChoEnvironmentSettings.GetEnvironmentDetails(); if (environmentDetails != null) { if (environmentDetails.Freeze) { return; } } if (sharedEnvironmentManager.EnvironmentDetails != null && sharedEnvironmentManager.EnvironmentDetails.Length >= 1) { if (sharedEnvironmentManager.EnvironmentDetails.Length == 1) { return; } ChoChooseEnvironmentFrm frm1 = new ChoChooseEnvironmentFrm(); if (frm1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { Environment.Exit(-101); } } } } } } }
public ChoApplicationHost() { Instance = this; //if (ChoApplication.ApplicationMode == ChoApplicationMode.NA) //if (!ChoApplication.IsInitialized) //{ if (!ChoApplication.InternalEventsSubscriped) { ChoApplication.InternalEventsSubscriped = true; ChoApplication.ApplyGlobalApplicationSettingsOverridesInternal += ((sender, e) => { ChoServiceCommandLineArgs.OverrideFrxParams(e.Value); ApplyGlobalApplicationSettingsOverrides(e.Value); } ); ChoApplication.AfterAppFrxSettingsLoadedInternal += ((sender, e) => { if (e.Value is ChoServiceInstallerSettings) { ChoServiceInstallerSettings o = (ChoServiceInstallerSettings)e.Value; o.BeforeInstall(() => BeforeInstall()); o.AfterInstall(() => AfterInstall()); o.BeforeUninstall(() => BeforeUninstall()); o.AfterUninstall(() => AfterUninstall()); } AfterAppFrxSettingsLoaded(e.Value); } ); ChoApplication.ApplyMetaDataFilePathSettingsOverridesInternal += ((sender, e) => { ApplyMetaDataFilePathSettingsOverrides(e.Value); } ); ChoApplication.AfterNotifyIconConstructedInternal += ((sender, e) => { AfterNotifyIconConstructed(e.Value); } ); } //ChoApplication.ApplyFrxParamsOverridesInternal += ((sender, e) => //{ // ApplyFrxParamsOverrides(e.GlobalApplicationSettings, e.MetaDataFilePathSettings); // if (_initialized) return; // _initialized = true; // ChoServiceCommandLineArgs.OverrideFrxParams(e); //}); if (Environment.UserInteractive) { if (this.GetMainWindowObject() != null) { if (ChoApplication.ApplicationMode == ChoApplicationMode.NA) { if (GetMainWindowObject() is Window || GetMainWindowObject() is Form) { ChoApplication.ApplicationMode = ChoApplicationMode.Windows; if (GetMainWindowObject() is Window) { ChoApplication.WindowsAppType = ChoWindowsAppType.WPF; } else { ChoApplication.WindowsAppType = ChoWindowsAppType.WinForms; } } else { ChoApplication.ApplicationMode = ChoApplicationMode.Console; } } //if (!(this is IChoWindowApp)) // throw new ChoApplicationException("ApplicationHost must derive from IChoWindowApp for Windows application."); } //ChoApplicationMode? applicationMode = ChoFrameworkCmdLineArgs.GetApplicationMode(); //if (applicationMode != null) // ChoApplication.ApplicationMode = applicationMode.Value; if (ChoApplication.ApplicationMode == ChoApplicationMode.Windows) { //if (ChoApplication.WindowsAppType == ChoWindowsAppType.NA) // ChoApplication.ApplicationMode = ChoApplicationMode.Console; } } ChoApplication.FatalApplicationException += FatalApplicationException; //if (Environment.UserInteractive) //{ // if (!ChoServiceCommandLineArgs.HasServiceParams()) // { // if (ChoApplication.ApplicationMode == ChoApplicationMode.Windows) // { // if (!ChoAppFrxSettings.Me.DoNotShowEnvSelectionWnd) // { // ChoChooseEnvironmentFrm.Show(); // //frm1 = new ChoChooseEnvironmentFrm(); // //if (frm1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) // // Environment.Exit(-101); // } // } // } //} //} //else // ApplyFrxParamsOverrides(ChoGlobalApplicationSettings.Me, ChoMetaDataFilePathSettings.Me); //ChoApplication.Initialize(); ChoGlobalApplicationSettings x = ChoGlobalApplicationSettings.Me; ChoApplication.WriteToEventLog(ChoServiceInstallerSettings.Me.ToString()); }