Skip to content

Commit

Permalink
Fix window sizing on Linux for clone/fake dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Jan 25, 2019
1 parent 64a0472 commit c09b6c0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
6 changes: 3 additions & 3 deletions GUI/CloneFakeKspDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions GUI/CloneFakeKspDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace CKAN
/// The GUI implementation of clone and fake.
/// It's a seperate window, handling the whole process.
/// </summary>
public partial class CloneFakeKspDialog : Form
public partial class CloneFakeKspDialog : FormCompatibility
{
private GUIUser user = new GUIUser();
private KSPManager manager;
Expand All @@ -22,12 +22,23 @@ public CloneFakeKspDialog(KSPManager manager)

InitializeComponent();

// Populate the combobox for fake instance.
// Populate the version combobox for fake instance.
List<Versioning.KspVersion> knownVersions = new GameVersionProviders.KspBuildMap(new Win32Registry()).KnownVersions;
knownVersions.Reverse();
comboBoxKspVersion.DataSource = knownVersions;
}

new private void ApplyFormCompatibilityFixes ()
{
const int formWidthDifference = 71;
const int formHeightDifference = 22;

if (!Platform.IsWindows)
{
ClientSize = new System.Drawing.Size(ClientSize.Width + formWidthDifference, ClientSize.Height + formHeightDifference);
}
}

#region clone

/// <summary>
Expand Down Expand Up @@ -108,7 +119,7 @@ private void radioButton_CheckedChanged(object sender, EventArgs e)

/// <summary>
/// User is done. Start cloning or faking, depending on the clicked radio button.
/// Close the window if everythin went right.
/// Close the window if everything went right.
/// </summary>
private async void buttonOK_Click(object sender, EventArgs e)
{
Expand All @@ -128,7 +139,9 @@ private async void buttonOK_Click(object sender, EventArgs e)
string newPath = textBoxNewPath.Text;

// Show progress bar and deactivate controls.
this.Size = new System.Drawing.Size(440, 351);
this.ClientSize = new System.Drawing.Size(424, 317);
ApplyFormCompatibilityFixes();
progressBar.Style = ProgressBarStyle.Marquee;
progressBar.Show();
foreach (Control ctrl in this.Controls)
{
Expand Down Expand Up @@ -241,8 +254,11 @@ private void reactivateDialog()
{
ctrl.Enabled = true;
}
this.Size = new System.Drawing.Size(440, 326);
progressBar.Style = ProgressBarStyle.Continuous;
progressBar.Value = 0;
progressBar.Hide();
this.ClientSize = new System.Drawing.Size(424, 287);
ApplyFormCompatibilityFixes();
}

private void buttonPathBrowser_Click(object sender, EventArgs e)
Expand Down
9 changes: 6 additions & 3 deletions GUI/FormCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@

namespace CKAN
{
/// <summary>
/// Inheriting from this class ensures that forms are equally sized on Windows and on Linux/MacOSX
/// Choose the form size so that it is the right one for Windows.
/// </summary>
public class FormCompatibility : Form
{

// inheriting from this class ensures that forms are equally sized on windows and on linux/ macosx
private const int formWidthDifference = 0;
private const int formHeightDifference = 24;

public void ApplyFormCompatibilityFixes()
{
if (!Platform.IsWindows)
{
ClientSize = new Size(ClientSize.Width, ClientSize.Height + formHeightDifference);
ClientSize = new Size(ClientSize.Width + formWidthDifference, ClientSize.Height + formHeightDifference);
}
}

Expand Down

0 comments on commit c09b6c0

Please sign in to comment.