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 ctlWindowWidth_TextChanged(object sender, EventArgs e) { m_widthBeingEdited = true; // Update the height textbox int newWidth; if (int.TryParse(ctlWindowWidth.Text, out newWidth)) { //GameWindowStartingWidth = newWidth; if (!m_heightBeingEdited) { ctlWindowHeight.Text = DfoLauncher.GetHeightFromWidth(newWidth).ToString(); // Update the slider //newWidth = newWidth.Clamp( ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum ); ctlWindowSizeSlider.Value = newWidth.Clamp(ctlWindowSizeSlider.Minimum, ctlWindowSizeSlider.Maximum); } } m_widthBeingEdited = false; }
private void ctlWindowSizeSlider_ValueChanged(object sender, EventArgs e) { if (!m_widthBeingEdited && !m_heightBeingEdited) { int newWidth = ctlWindowSizeSlider.Value; int widthFromTextbox; bool textboxHasInt = int.TryParse(ctlWindowWidth.Text, out widthFromTextbox); if (!textboxHasInt || widthFromTextbox != newWidth) { ctlWindowWidth.Text = newWidth.ToString(); } int newHeight = DfoLauncher.GetHeightFromWidth(ctlWindowSizeSlider.Value); int heightFromTextbox; textboxHasInt = int.TryParse(ctlWindowHeight.Text, out heightFromTextbox); if (!textboxHasInt || heightFromTextbox != newHeight) { ctlWindowHeight.Text = newHeight.ToString(); } } }