Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit 5cfc7de

Browse files
authored
Merge pull request #29 from geo-at-github/master
Changes in grid column width are now saved in user settings as int[].
2 parents eb83828 + ee15620 commit 5cfc7de

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

UnityLauncher/App.config

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
<setting name="closeAfterProject" serializeAs="String">
3434
<value>True</value>
3535
</setting>
36+
<setting name="gridColumnWidths" serializeAs="Xml">
37+
<value>
38+
<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
40+
</ArrayOfInt>
41+
</value>
42+
</setting>
3643
</UnityLauncher.Properties.Settings>
3744
</userSettings>
3845
</configuration>

UnityLauncher/Form1.cs

+30
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ void Start()
8888

8989
// preselect grid
9090
gridRecent.Select();
91+
92+
this.gridRecent.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridRecent_ColumnWidthChanged);
9193
}
9294

9395
void LoadSettings()
@@ -101,6 +103,13 @@ void LoadSettings()
101103
lstRootFolders.Items.AddRange(Properties.Settings.Default.rootFolders.Cast<string>().ToArray());
102104
// update packages folder listbox
103105
lstPackageFolders.Items.AddRange(Properties.Settings.Default.packageFolders.Cast<string>().ToArray());
106+
107+
// restore data grid view widths
108+
int[] gridColumnWidths = Properties.Settings.Default.gridColumnWidths;
109+
for ( int i=0; i< gridColumnWidths.Length; ++i )
110+
{
111+
gridRecent.Columns[i].Width = gridColumnWidths[i];
112+
}
104113
}
105114

106115
/// <summary>
@@ -926,6 +935,27 @@ private void btnOpenLogFolder_Click(object sender, EventArgs e)
926935
LaunchExplorer(logfolder);
927936
}
928937
}
938+
939+
private void gridRecent_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
940+
{
941+
List<int> gridWidths = new List<int>(Properties.Settings.Default.gridColumnWidths);
942+
// restore data grid view widths
943+
var colum = gridRecent.Columns[0];
944+
int a = Properties.Settings.Default.gridColumnWidths.Length;
945+
for (int i = 0; i < gridRecent.Columns.Count; ++i)
946+
{
947+
if (Properties.Settings.Default.gridColumnWidths.Length > i)
948+
{
949+
gridWidths[i] = gridRecent.Columns[i].Width;
950+
}
951+
else
952+
{
953+
gridWidths.Add(gridRecent.Columns[i].Width);
954+
}
955+
}
956+
Properties.Settings.Default.gridColumnWidths = gridWidths.ToArray();
957+
Properties.Settings.Default.Save();
958+
}
929959
#endregion UI events
930960

931961
void OpenReleaseNotes(string version)

UnityLauncher/Properties/Settings.Designer.cs

+18-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityLauncher/Properties/Settings.settings

+6
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@
2121
<Setting Name="closeAfterProject" Type="System.Boolean" Scope="User">
2222
<Value Profile="(Default)">True</Value>
2323
</Setting>
24+
<Setting Name="gridColumnWidths" Type="System.String" Scope="User">
25+
<Value Profile="(Default)">
26+
&lt;ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
27+
&lt;/ArrayOfInt&gt;
28+
</Value>
29+
</Setting>
2430
</Settings>
2531
</SettingsFile>

0 commit comments

Comments
 (0)