internal int ShowSetupWindow(SetupContextForWindows setupContext) { int level = 0; try { level = OpenMainWindow().ShowSetupWindow(setupContext); } catch (Exception exception) { ErrorMessage(exception.Message); } return(level); }
protected override int DoInitialSetupImpl(CommandSettings settings) { // argument checks CommandForWindowsGUISettings actualSettings = settings as CommandForWindowsGUISettings; if (actualSettings == null) { throw new ArgumentException($"It must be an instance of {nameof(CommandForWindowsGUISettings)} class.", nameof(settings)); } // create context SetupContextForWindows setupContext = new SetupContextForWindows(actualSettings, this); bool needSetup = (settings.InitialSetupLevel == 0) || setupContext.NeedSetup; // Note that it returns the latest level if no need to setup, it sets 'InitialSetupLevel' settings up-to-date return(needSetup? this.app.ShowSetupWindow(setupContext): SetupContext.LatestInitialSetupLevel); }
internal int ShowSetupWindow(SetupContextForWindows setupContext) { // argument checks Debug.Assert(setupContext != null); // state checks Debug.Assert(this.Command.IsProxyRunning == false); // open the setup window as dialog int currentLevel = setupContext.Settings.InitialSetupLevel; bool result = false; this.showingSetupWindow = true; try { SetupWindow window = new SetupWindow(this.Command, setupContext); window.Owner = this; result = (window.ShowDialog() ?? false); } finally { this.showingSetupWindow = false; } return(result? SetupContextForWindows.LatestInitialSetupLevel: currentLevel); }
internal SetupWindow(Command command, SetupContextForWindows setupContext) { // argument checks if (command == null) { throw new ArgumentNullException(nameof(command)); } if (setupContext == null) { throw new ArgumentNullException(nameof(setupContext)); } CommandForWindowsSettings settings = setupContext.Settings; // initialize members this.Command = command; this.SetupContext = setupContext; // initialize components InitializeComponent(); // Authentication Proxy tab SystemSettingsSwitcherForWindowsSettings systemSettingsSwitcherSettings = settings.SystemSettingsSwitcher; if (setupContext.NeedActualProxy) { StringBuilder buf = new StringBuilder(Windows.Properties.Resources.Setup_AuthenticationProxy_Description_NeedToChange); if (setupContext.IsDefaultActualProxyProvided) { buf.AppendLine(); buf.AppendLine(); buf.Append(Windows.Properties.Resources.Setup_Description_DefaultValueProvided); } this.authenticationProxyDescriptionTextBlock.Text = buf.ToString(); if (systemSettingsSwitcherSettings.ActualProxy == null) { systemSettingsSwitcherSettings.ActualProxy = setupContext.CreateActualProxySettings(); } } else { this.authenticationProxyDescriptionTextBlock.Text = Windows.Properties.Resources.Setup_Description_NoNeedToChange; if (setupContext.ProxyDetected == false && systemSettingsSwitcherSettings.ActualProxy == null) { systemSettingsSwitcherSettings.ActualProxy = setupContext.CreateActualProxySettings(); } } this.actualProxy.SystemSettingsSwitcherSettings = systemSettingsSwitcherSettings; // System Settings Switch tab this.systemSettingsSwitcher.SystemSettingsSwitcherSettings = settings.SystemSettingsSwitcher; if (setupContext.NeedProxyOverride) { this.systemSettingsSwitcherDescriptionTextBlock.Text = Windows.Properties.Resources.Setup_Description_Confirm; } else { this.systemSettingsSwitcherDescriptionTextBlock.Text = Windows.Properties.Resources.Setup_Description_NoNeedToChange; } // Test tab this.testDescriptionTextBlock.Text = Windows.Properties.Resources.Setup_Test_Description; this.targetUrlTextBox.Text = SystemSettingsSwitcher.GetTestUrl(); // Finish tab string description = string.Concat(Windows.Properties.Resources.Setup_Finishing_Description, Environment.NewLine, Environment.NewLine, Properties.Resources.SetupWindow_finishingDescriptionTextBox_Text_Addition); this.finishingDescriptionTextBlock.Text = description; UpdateUIState(); return; }