@@ -36,6 +36,8 @@ private void Form1_Load(object sender, EventArgs e)
3636 Start ( ) ;
3737 }
3838
39+
40+
3941 void Start ( )
4042 {
4143 SetStatus ( "Initializing ..." ) ;
@@ -110,9 +112,6 @@ void Start()
110112 // preselect grid
111113 gridRecent . Select ( ) ;
112114
113- // subscribe to columnwidthchange event, so that can save column sizes
114- this . gridRecent . ColumnWidthChanged += new System . Windows . Forms . DataGridViewColumnEventHandler ( this . gridRecent_ColumnWidthChanged ) ;
115-
116115 // get previous version build info string
117116 // this string is release tag for latest release when this app was compiled
118117 using ( Stream stream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( "UnityLauncher." + "PreviousVersion.txt" ) )
@@ -887,35 +886,6 @@ private void btnOpenLogFolder_Click(object sender, EventArgs e)
887886 }
888887 }
889888
890- private void gridRecent_ColumnWidthChanged ( object sender , DataGridViewColumnEventArgs e )
891- {
892- List < int > gridWidths ;
893- if ( Properties . Settings . Default . gridColumnWidths != null )
894- {
895- gridWidths = new List < int > ( Properties . Settings . Default . gridColumnWidths ) ;
896- }
897- else
898- {
899- gridWidths = new List < int > ( ) ;
900- }
901-
902- // restore data grid view widths
903- var colum = gridRecent . Columns [ 0 ] ;
904- for ( int i = 0 ; i < gridRecent . Columns . Count ; ++ i )
905- {
906- if ( Properties . Settings . Default . gridColumnWidths != null && Properties . Settings . Default . gridColumnWidths . Length > i )
907- {
908- gridWidths [ i ] = gridRecent . Columns [ i ] . Width ;
909- }
910- else
911- {
912- gridWidths . Add ( gridRecent . Columns [ i ] . Width ) ;
913- }
914- }
915- Properties . Settings . Default . gridColumnWidths = gridWidths . ToArray ( ) ;
916- Properties . Settings . Default . Save ( ) ;
917- }
918-
919889 private void btnOpenUpdateWebsite_Click ( object sender , EventArgs e )
920890 {
921891 var selected = gridUnityUpdates ? . CurrentCell ? . RowIndex ;
@@ -1025,8 +995,16 @@ private void btnBrowseForProject_Click(object sender, EventArgs e)
1025995 BrowseForExistingProjectFolder ( ) ;
1026996 }
1027997
998+ private void Form1_FormClosing ( object sender , FormClosingEventArgs e )
999+ {
1000+ SaveSettingsOnExit ( ) ;
1001+ }
1002+
10281003 #endregion UI events
10291004
1005+
1006+
1007+
10301008 // displays version selector to upgrade project
10311009 void UpgradeProject ( )
10321010 {
@@ -1237,5 +1215,37 @@ void BrowseForExistingProjectFolder()
12371215 gridRecent . Rows [ 0 ] . Selected = true ;
12381216 }
12391217 }
1240- }
1241- }
1218+
1219+ private void SaveSettingsOnExit ( )
1220+ {
1221+ // save list column widths
1222+ List < int > gridWidths ;
1223+ if ( Properties . Settings . Default . gridColumnWidths != null )
1224+ {
1225+ gridWidths = new List < int > ( Properties . Settings . Default . gridColumnWidths ) ;
1226+ }
1227+ else
1228+ {
1229+ gridWidths = new List < int > ( ) ;
1230+ }
1231+
1232+ // restore data grid view widths
1233+ var colum = gridRecent . Columns [ 0 ] ;
1234+ for ( int i = 0 ; i < gridRecent . Columns . Count ; ++ i )
1235+ {
1236+ if ( Properties . Settings . Default . gridColumnWidths != null && Properties . Settings . Default . gridColumnWidths . Length > i )
1237+ {
1238+ gridWidths [ i ] = gridRecent . Columns [ i ] . Width ;
1239+ }
1240+ else
1241+ {
1242+ gridWidths . Add ( gridRecent . Columns [ i ] . Width ) ;
1243+ }
1244+ }
1245+ Properties . Settings . Default . gridColumnWidths = gridWidths . ToArray ( ) ;
1246+ Properties . Settings . Default . Save ( ) ;
1247+ }
1248+
1249+
1250+ } // class Form
1251+ } // namespace
0 commit comments