@@ -1213,8 +1213,9 @@ private void saveToolStripMenuItem_Click(object sender, EventArgs e)
12131213 saveDialog . Title = "Save results" ;
12141214 saveDialog . InitialDirectory = @"c:\" ;
12151215 saveDialog . Filter = "CSV files (*.csv)|*.csv|JSON files (*.json)|*.json|All files (*.*)|*.*" ;
1216- saveDialog . FilterIndex = 1 ;
1216+ saveDialog . FilterIndex = 2 ;
12171217 saveDialog . RestoreDirectory = true ;
1218+ saveDialog . InitialDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . Desktop ) ;
12181219 if ( saveDialog . ShowDialog ( ) == DialogResult . OK )
12191220 {
12201221 string filePath = saveDialog . FileName ;
@@ -1237,8 +1238,9 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e)
12371238 importDialog . Title = "Import CSV\\ JSON file" ;
12381239 importDialog . InitialDirectory = @"c:\" ;
12391240 importDialog . Filter = "CSV files (*.csv)|*.csv|JSON files (*.json)|*.json|All files (*.*)|*.*" ;
1240- importDialog . FilterIndex = 1 ;
1241+ importDialog . FilterIndex = 2 ;
12411242 importDialog . RestoreDirectory = true ;
1243+ importDialog . InitialDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . Desktop ) ;
12421244
12431245 if ( importDialog . ShowDialog ( ) == DialogResult . OK )
12441246 {
@@ -1254,6 +1256,9 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e)
12541256 importDataGridViewToJSON ( filePath ) ;
12551257 }
12561258 }
1259+
1260+ // because we import the data without the color.
1261+ this . m_showPermissionColor = false ;
12571262 }
12581263
12591264 // Taken from https://stackoverflow.com/a/26259909/2153777
@@ -1274,7 +1279,7 @@ private void exportDataGridViewToCSV(string filename)
12741279 File . WriteAllText ( filename , dataObject . GetText ( TextDataFormat . CommaSeparatedValue ) . Replace ( "\n " , "" ) ) ;
12751280 }
12761281
1277- // TODO: maybe had option to make it as one line? liki mini JSON?
1282+ // TODO: maybe had option to make it as one line? like mini JSON?
12781283 // less readable but might be better for loading.
12791284 private void exportDataGridViewToJSON ( string filename )
12801285 {
@@ -1291,7 +1296,7 @@ private void exportDataGridViewToJSON(string filename)
12911296 continue ;
12921297 }
12931298
1294- string columnName = cell . OwningColumn . Name ;
1299+ string columnName = cell . OwningColumn . Name . Substring ( "Column" . Length ) ;
12951300 object cellValue = cell . Value ?? DBNull . Value ; // Use DBNull for null values
12961301
12971302 rowData . Add ( columnName , cellValue ) ;
@@ -1300,8 +1305,12 @@ private void exportDataGridViewToJSON(string filename)
13001305 }
13011306 }
13021307
1308+ // Help to keep the strings as they are (instead of showing 8192 for "Medium" it will show the string)
1309+ JsonSerializerSettings settings = new JsonSerializerSettings ( ) ;
1310+ settings . Converters . Add ( new Newtonsoft . Json . Converters . StringEnumConverter ( ) ) ;
1311+
13031312 // Serialize the data to JSON and write it to the file
1304- string jsonData = JsonConvert . SerializeObject ( rows , Formatting . Indented ) ;
1313+ string jsonData = JsonConvert . SerializeObject ( rows , Formatting . Indented , settings ) ;
13051314 File . WriteAllText ( filename , jsonData ) ;
13061315 }
13071316 private void importDataGridViewToCSV ( string filename )
@@ -1331,7 +1340,7 @@ private void importDataGridViewToJSON(string filename)
13311340 // Add columns to DataGridView
13321341 foreach ( DataColumn column in dataTable . Columns )
13331342 {
1334- dataGridView1 . Columns . Add ( column . ColumnName , column . ColumnName ) ;
1343+ dataGridView1 . Columns . Add ( "Column" + column . ColumnName , column . ColumnName ) ;
13351344 }
13361345
13371346 // Add rows to DataGridView
0 commit comments