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

Commit 10ccaf6

Browse files
committed
Grid columns width changes are now saved in user settings.
1 parent 799ba7f commit 10ccaf6

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>
@@ -923,6 +932,27 @@ private void btnOpenLogFolder_Click(object sender, EventArgs e)
923932
LaunchExplorer(logfolder);
924933
}
925934
}
935+
936+
private void gridRecent_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
937+
{
938+
List<int> gridWidths = new List<int>(Properties.Settings.Default.gridColumnWidths);
939+
// restore data grid view widths
940+
var colum = gridRecent.Columns[0];
941+
int a = Properties.Settings.Default.gridColumnWidths.Length;
942+
for (int i = 0; i < gridRecent.Columns.Count; ++i)
943+
{
944+
if (Properties.Settings.Default.gridColumnWidths.Length > i)
945+
{
946+
gridWidths[i] = gridRecent.Columns[i].Width;
947+
}
948+
else
949+
{
950+
gridWidths.Add(gridRecent.Columns[i].Width);
951+
}
952+
}
953+
Properties.Settings.Default.gridColumnWidths = gridWidths.ToArray();
954+
Properties.Settings.Default.Save();
955+
}
926956
#endregion UI events
927957

928958
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)