private void ctlWindowHeight_Leave(object sender, EventArgs e) { // Update the slider (and indirectly, the width textbox) int newHeight; if (int.TryParse(ctlWindowHeight.Text, out newHeight)) { int width; bool widthSuccess = int.TryParse(ctlWindowWidth.Text, out width); int newWidth = 0; if (widthSuccess && DfoLauncher.GetHeightFromWidth(width) == newHeight) { newWidth = width; } else { newWidth = DfoLauncher.GetWidthFromHeight(newHeight); } newWidth = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum); ctlWindowSizeSlider.Value = newWidth; // Set the text to a canonical text for the width ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value).ToString(); } else { // invalid input, reset text to the slider value ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value).ToString(); } }
private void ctlWindowHeight_TextChanged(object sender, EventArgs e) { m_heightBeingEdited = true; // Update the width textbox int newHeight; if (int.TryParse(ctlWindowHeight.Text, out newHeight)) { //GameWindowStartingWidth = GetWidthFromHeight( newHeight ); if (!m_widthBeingEdited) { int width; bool widthSuccess = int.TryParse(ctlWindowWidth.Text, out width); if (!widthSuccess || DfoLauncher.GetHeightFromWidth(width) != newHeight) { ctlWindowWidth.Text = DfoLauncher.GetWidthFromHeight(newHeight).ToString(); // Update the slider int newWidth; if (int.TryParse(ctlWindowWidth.Text, out newWidth)) { newWidth = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum); ctlWindowSizeSlider.Value = newWidth; } } } } m_heightBeingEdited = false; }
/// <summary> /// /// </summary> /// <param name="args"></param> /// <exception cref="Ndesk.Options.OptionException">Badly-formatted arguments</exception> public CommandLineArgs( string[] args ) { if ( args.Length == 0 ) { Gui = true; } else { Gui = false; } ShowHelp = false; ShowVersion = false; OptionSet optionSet = GetOptionSet(); optionSet.Parse( args ); // Set width or height if the user only explicitly set one. This prevents width from being // specified on command-line and height being specified in saved settings if ( Settings.GameWindowWidth != null && Settings.GameWindowHeight == null ) { Settings.GameWindowHeight = DfoLauncher.GetHeightFromWidth( Settings.GameWindowWidth.Value ); } else if ( Settings.GameWindowWidth == null && Settings.GameWindowHeight != null ) { Settings.GameWindowWidth = DfoLauncher.GetWidthFromHeight( Settings.GameWindowHeight.Value ); } }
private void ctlMainForm_Load(object sender, EventArgs e) { Logging.Log.Debug("Loading main window."); Rectangle primaryScreenSize = Screen.PrimaryScreen.Bounds; Logging.Log.DebugFormat("Primary screen size is {0}x{1}", primaryScreenSize.Width, primaryScreenSize.Height); int maxWidth = Math.Min(primaryScreenSize.Width, DfoLauncher.GetWidthFromHeight(primaryScreenSize.Height)); ctlWindowSizeSlider.Minimum = DfoLauncher.DefaultGameWindowWidth; ctlWindowSizeSlider.Maximum = Math.Max(maxWidth, DfoLauncher.DefaultGameWindowWidth); Logging.Log.DebugFormat("Allowable game window width: {0}-{1}", ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum); // Initialize window size UI ctlWindowSizeSlider_ValueChanged(ctlWindowSizeSlider, EventArgs.Empty); // Bind switchable files to checkboxes IDictionary <string, CheckBox> switchableFileCheckboxes = GetSwitchableCheckboxes(); foreach (ISwitchableFile switchableFile in m_parsedArgs.Settings.SwitchableFiles.Values) { if (switchableFileCheckboxes.ContainsKey(switchableFile.Name)) { SwitchableFiles.Add(switchableFile.Name, new CheckboxSwitchableFile(switchableFileCheckboxes[switchableFile.Name], switchableFile)); } else { // Hmmm...No UI binding for a switchable file. Add it as a switchable file and let // setting/command-line behavior take effect. SwitchableFiles.Add(switchableFile.Name, new PlainUiSwitchableFile(switchableFile)); } } m_savedSettings = SettingsLoader.Load(); ApplySettingsAndArguments(); FixSwitchableFilesIfNeeded(); ctlUsername.Select(); Logging.Log.Debug("Main window loaded."); }