diff --git a/App.config b/App.config
index ec48b8f4ae..679d3d6abe 100644
--- a/App.config
+++ b/App.config
@@ -1,9 +1,24 @@
+
+
+
+
+
+
+
+
+ 0, 0
+
+
+ 1024, 500
+
+
+
\ No newline at end of file
diff --git a/Main.Designer.cs b/Main.Designer.cs
index cce3a4cb58..5f56bee910 100644
--- a/Main.Designer.cs
+++ b/Main.Designer.cs
@@ -1142,6 +1142,7 @@ private void InitializeComponent()
this.MinimumSize = new System.Drawing.Size(878, 664);
this.Name = "Main";
this.Text = "CKAN-GUI";
+ this.FormClosing += Main_FormClosing;
this.Load += new System.EventHandler(this.Main_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
diff --git a/Main.cs b/Main.cs
index 90f4f2016b..16c3cccdc6 100644
--- a/Main.cs
+++ b/Main.cs
@@ -46,7 +46,7 @@ public partial class Main
public KSP CurrentInstance
{
- get { return manager.CurrentInstance; }
+ get { return manager.CurrentInstance; }
}
public KSPManager Manager
@@ -71,7 +71,7 @@ public Main(string[] cmdlineArgs, GUIUser User, bool showConsole)
controlFactory = new ControlFactory();
Instance = this;
- mainModList = new MainModList(source => UpdateFilters(this));
+ mainModList = new MainModList(source => UpdateFilters(this));
InitializeComponent();
// We need to initialize error dialog first to display errors
@@ -79,7 +79,7 @@ public Main(string[] cmdlineArgs, GUIUser User, bool showConsole)
// We want to check our current instance is null first, as it may
// have already been set by a command-line option.
- Manager = new KSPManager(User);
+ Manager = new KSPManager(User);
if (CurrentInstance == null && manager.GetPreferredInstance() == null)
{
Hide();
@@ -119,7 +119,7 @@ public Main(string[] cmdlineArgs, GUIUser User, bool showConsole)
}
void ModList_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
+ {
ModList_CellContentClick(sender, null);
}
@@ -132,7 +132,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
return true;
case (Keys.Control | Keys.S):
var registry = RegistryManager.Instance(CurrentInstance).registry;
- if (mainModList.ComputeChangeSetFromModList(registry,CurrentInstance).Any())
+ if (mainModList.ComputeChangeSetFromModList(registry, CurrentInstance).Any())
{
ApplyToolButton_Click(null, null);
}
@@ -145,13 +145,34 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
public static Main Instance { get; private set; }
+ private void Main_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ Properties.Settings.Default.MainWindowPos = this.Location;
+
+ // Copy window size to app settings
+ if (this.WindowState == FormWindowState.Normal)
+ {
+ Properties.Settings.Default.MainWindowSize = this.Size;
+ }
+ else
+ {
+ Properties.Settings.Default.MainWindowSize = this.RestoreBounds.Size;
+ }
+
+ // Save settings
+ Properties.Settings.Default.Save();
+ }
+
private void Main_Load(object sender, EventArgs e)
{
- m_UpdateRepoWorker = new BackgroundWorker {WorkerReportsProgress = false, WorkerSupportsCancellation = true};
+ this.Location = Properties.Settings.Default.MainWindowPos;
+ this.Size = Properties.Settings.Default.MainWindowSize;
+
+ m_UpdateRepoWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = true };
m_UpdateRepoWorker.RunWorkerCompleted += PostUpdateRepo;
m_UpdateRepoWorker.DoWork += UpdateRepo;
- m_InstallWorker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true};
+ m_InstallWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
m_InstallWorker.RunWorkerCompleted += PostInstallMods;
m_InstallWorker.DoWork += InstallMods;
@@ -186,9 +207,9 @@ private void Main_Load(object sender, EventArgs e)
}
int i = 0;
- foreach(DataGridViewRow row in ModList.Rows)
+ foreach (DataGridViewRow row in ModList.Rows)
{
- var module = ((GUIMod) row.Tag).ToCkanModule();
+ var module = ((GUIMod)row.Tag).ToCkanModule();
if (identifier == module.identifier)
{
ModList.FirstDisplayedScrollingRowIndex = i;
@@ -205,7 +226,7 @@ private void Main_Load(object sender, EventArgs e)
{
Directory.CreateDirectory(pluginsPath);
}
-
+
m_PluginController = new PluginController(pluginsPath, true);
}
@@ -218,7 +239,7 @@ private void MarkAllUpdatesToolButton_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in ModList.Rows)
{
- var mod = ((GUIMod) row.Tag).ToCkanModule();
+ var mod = ((GUIMod)row.Tag).ToCkanModule();
var registry = RegistryManager.Instance(CurrentInstance).registry;
if (!registry.IsInstalled(mod.identifier))
{
@@ -255,7 +276,7 @@ private void ModList_SelectedIndexChanged(object sender, EventArgs e)
return;
}
- var module = ((GUIMod) selectedItem.Tag).ToCkanModule();
+ var module = ((GUIMod)selectedItem.Tag).ToCkanModule();
if (module == null)
{
return;
@@ -286,20 +307,20 @@ private void FilterByNameTextBox_TextChanged(object sender, EventArgs e)
/// with name begining with the key pressed.
///
private void ModList_KeyPress(object sender, KeyPressEventArgs e)
- {
- var rows = ModList.Rows.Cast().Where(row=>row.Visible);
- var does_name_begin_with_char = new Func(row =>
- {
- var modname = ((GUIMod) row.Tag).ToCkanModule().name;
+ {
+ var rows = ModList.Rows.Cast().Where(row => row.Visible);
+ var does_name_begin_with_char = new Func(row =>
+ {
+ var modname = ((GUIMod)row.Tag).ToCkanModule().name;
var key = e.KeyChar.ToString();
return modname.StartsWith(key, StringComparison.OrdinalIgnoreCase);
});
ModList.ClearSelection();
DataGridViewRow match = rows.FirstOrDefault(does_name_begin_with_char);
if (match != null)
- {
+ {
match.Selected = true;
-
+
if (Util.IsLinux)
{
try
@@ -312,11 +333,11 @@ private void ModList_KeyPress(object sender, KeyPressEventArgs e)
var safe_set_method = vertical_scroll_bar.GetType().GetMethod("SafeValueSet",
BindingFlags.NonPublic | BindingFlags.Instance);
- first_row_index.SetValue(ModList, match.Index);
+ first_row_index.SetValue(ModList, match.Index);
safe_set_method.Invoke(vertical_scroll_bar,
- new object[] {match.Index*match.Height});
+ new object[] { match.Index * match.Height });
}
- catch
+ catch
{
//Compared to crashing ignoring the keypress is fine.
}
@@ -327,10 +348,10 @@ private void ModList_KeyPress(object sender, KeyPressEventArgs e)
{
//Not the best of names. Why not FirstVisableRowIndex?
ModList.FirstDisplayedScrollingRowIndex = match.Index;
- }
- }
-
-
+ }
+ }
+
+
}
///
@@ -339,7 +360,7 @@ private void ModList_KeyPress(object sender, KeyPressEventArgs e)
///
private void ModList_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
-
+
ModList.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
@@ -356,10 +377,10 @@ private void ModList_CellValueChanged(object sender, DataGridViewCellEventArgs e
if (columnIndex < 2)
{
var checkbox = (DataGridViewCheckBoxCell)gridViewCell;
-
- if (columnIndex==0)
+
+ if (columnIndex == 0)
{
- ((GUIMod) row.Tag).IsInstallChecked = (bool) checkbox.Value;
+ ((GUIMod)row.Tag).IsInstallChecked = (bool)checkbox.Value;
}
else if (columnIndex == 1)
{
@@ -386,7 +407,7 @@ private void ModList_CellValueChanged(object sender, DataGridViewCellEventArgs e
return;
}
-
+
if (gridViewCell is DataGridViewLinkCell)
{
var cell = gridViewCell as DataGridViewLinkCell;
@@ -445,7 +466,7 @@ private void ContentsDownloadButton_Click(object sender, EventArgs e)
return;
}
- var module = ((GUIMod) selectedItem.Tag).ToCkanModule();
+ var module = ((GUIMod)selectedItem.Tag).ToCkanModule();
if (module == null)
{
return;
@@ -563,17 +584,17 @@ private void launchKSPToolStripMenuItem_Click(object sender, EventArgs e)
string binary = lst[0];
string args = String.Empty;
- for(int i = 1; i < lst.Length; i++)
+ for (int i = 1; i < lst.Length; i++)
{
args += lst[i] + " ";
}
-
+
try
{
Directory.SetCurrentDirectory(CurrentInstance.GameDir());
Process.Start(binary, args);
}
- catch(Exception exception)
+ catch (Exception exception)
{
GUI.user.RaiseError("Couldn't start KSP. {0}.", exception.Message);
}
@@ -617,7 +638,7 @@ private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
{
m_OpenFileDialog.Filter = "CKAN metadata (*.ckan)|*.ckan";
- if(m_OpenFileDialog.ShowDialog() == DialogResult.OK)
+ if (m_OpenFileDialog.ShowDialog() == DialogResult.OK)
{
var path = m_OpenFileDialog.FileName;
CkanModule module = null;
@@ -626,12 +647,12 @@ private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
{
module = CkanModule.FromFile(path);
}
- catch(Kraken kraken)
+ catch (Kraken kraken)
{
m_User.RaiseError(kraken.Message + ": " + kraken.InnerException.Message);
return;
}
- catch(Exception ex)
+ catch (Exception ex)
{
m_User.RaiseError(ex.Message);
return;
@@ -674,8 +695,8 @@ public class GUIUser : NullUser
public Action displayMessage;
public Action displayError;
public DisplayYesNo displayYesNo;
-
-
+
+
protected override bool DisplayYesNoDialog(string message)
{
if (displayYesNo == null)
@@ -707,6 +728,6 @@ public override int WindowWidth
get { return -1; }
}
-
+
}
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 795b8f3ff0..1475459540 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -12,7 +12,7 @@ namespace CKAN.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -22,5 +22,29 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio
return defaultInstance;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0, 0")]
+ public global::System.Drawing.Point MainWindowPos {
+ get {
+ return ((global::System.Drawing.Point)(this["MainWindowPos"]));
+ }
+ set {
+ this["MainWindowPos"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1024, 500")]
+ public global::System.Drawing.Size MainWindowSize {
+ get {
+ return ((global::System.Drawing.Size)(this["MainWindowSize"]));
+ }
+ set {
+ this["MainWindowSize"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 39645652af..abb7963ad5 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -1,7 +1,12 @@
-
-
-
-
-
-
+
+
+
+
+ 0, 0
+
+
+ 1024, 500
+
+
+
\ No newline at end of file