OpenBve.formMain.ShowVersionDialog C# (CSharp) Méthode

ShowVersionDialog() private static méthode

private static ShowVersionDialog ( System.Version &minimumVersion, System.Version &maximumVersion, string currentVersion, string label ) : DialogResult
minimumVersion System.Version
maximumVersion System.Version
currentVersion string
label string
Résultat DialogResult
		private static DialogResult ShowVersionDialog(ref Version minimumVersion, ref Version maximumVersion, string currentVersion, string label)
		{
			System.Drawing.Size size = new System.Drawing.Size(300, 80);
			Form inputBox = new Form
			{
				FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog,
				MaximizeBox = false,
				MinimizeBox = false,
				StartPosition = FormStartPosition.CenterScreen,
				ClientSize = size,
				Text = Interface.GetInterfaceString("packages_list_version")
			};

			System.Windows.Forms.Label minLabel = new Label
			{
				Text = Interface.GetInterfaceString("packages_list_minimum"),
				Location = new System.Drawing.Point(5, 6),
			};
			inputBox.Controls.Add(minLabel);

			System.Windows.Forms.TextBox textBox = new TextBox
			{
				Size = new System.Drawing.Size(size.Width - 110, 23),
				Location = new System.Drawing.Point(105, 5),
				Text = currentVersion
			};
			inputBox.Controls.Add(textBox);

			System.Windows.Forms.Label maxLabel = new Label
			{
				Text = Interface.GetInterfaceString("packages_list_maximum"),
				Location = new System.Drawing.Point(5, 26),
			};
			inputBox.Controls.Add(maxLabel);

			System.Windows.Forms.TextBox textBox2 = new TextBox
			{
				Size = new System.Drawing.Size(size.Width - 110, 23),
				Location = new System.Drawing.Point(105, 25),
				Text = currentVersion
			};
			inputBox.Controls.Add(textBox2);

			Button okButton = new Button
			{
				DialogResult = System.Windows.Forms.DialogResult.OK,
				Name = "okButton",
				Size = new System.Drawing.Size(75, 23),
				Text = Interface.GetInterfaceString("packages_button_ok"),
				Location = new System.Drawing.Point(size.Width - 80 - 80, 49)
			};
			inputBox.Controls.Add(okButton);

			Button cancelButton = new Button
			{
				DialogResult = System.Windows.Forms.DialogResult.Cancel,
				Name = "cancelButton",
				Size = new System.Drawing.Size(75, 23),
				Text = Interface.GetInterfaceString("packages_button_cancel"),
				Location = new System.Drawing.Point(size.Width - 80, 49)
			};
			inputBox.Controls.Add(cancelButton);

			inputBox.AcceptButton = okButton;
			inputBox.CancelButton = cancelButton;
			inputBox.AcceptButton = okButton;
			inputBox.CancelButton = cancelButton;
			DialogResult result = inputBox.ShowDialog();
			try
			{
				if (textBox.Text == String.Empty || textBox.Text == @"0")
				{
					minimumVersion = null;
				}
				else
				{
					minimumVersion = Version.Parse(textBox.Text);	
				}
				if (textBox2.Text == String.Empty || textBox2.Text == @"0")
				{
					maximumVersion = null;
				}
				else
				{
					maximumVersion = Version.Parse(textBox2.Text);
				}
			}
			catch
			{
				MessageBox.Show(Interface.GetInterfaceString("packages_creation_version_invalid"));
			}
			return result;
		}
formMain