diff --git a/PipeViewer/App.config b/PipeViewer/App.config index 4bfa005..bae5d6d 100644 --- a/PipeViewer/App.config +++ b/PipeViewer/App.config @@ -1,6 +1,6 @@ - + diff --git a/PipeViewer/Form1.cs b/PipeViewer/Form1.cs index 4629d50..eabd003 100644 --- a/PipeViewer/Form1.cs +++ b/PipeViewer/Form1.cs @@ -1213,8 +1213,9 @@ private void saveToolStripMenuItem_Click(object sender, EventArgs e) saveDialog.Title = "Save results"; saveDialog.InitialDirectory = @"c:\"; saveDialog.Filter = "CSV files (*.csv)|*.csv|JSON files (*.json)|*.json|All files (*.*)|*.*"; - saveDialog.FilterIndex = 1; + saveDialog.FilterIndex = 2; saveDialog.RestoreDirectory = true; + saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (saveDialog.ShowDialog() == DialogResult.OK) { string filePath = saveDialog.FileName; @@ -1237,8 +1238,9 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e) importDialog.Title = "Import CSV\\JSON file"; importDialog.InitialDirectory = @"c:\"; importDialog.Filter = "CSV files (*.csv)|*.csv|JSON files (*.json)|*.json|All files (*.*)|*.*"; - importDialog.FilterIndex = 1; + importDialog.FilterIndex = 2; importDialog.RestoreDirectory = true; + importDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (importDialog.ShowDialog() == DialogResult.OK) { @@ -1254,6 +1256,9 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e) importDataGridViewToJSON(filePath); } } + + // because we import the data without the color. + this.m_showPermissionColor = false; } // Taken from https://stackoverflow.com/a/26259909/2153777 @@ -1274,7 +1279,7 @@ private void exportDataGridViewToCSV(string filename) File.WriteAllText(filename, dataObject.GetText(TextDataFormat.CommaSeparatedValue).Replace("\n", "")); } - // TODO: maybe had option to make it as one line? liki mini JSON? + // TODO: maybe had option to make it as one line? like mini JSON? // less readable but might be better for loading. private void exportDataGridViewToJSON(string filename) { @@ -1291,7 +1296,7 @@ private void exportDataGridViewToJSON(string filename) continue; } - string columnName = cell.OwningColumn.Name; + string columnName = cell.OwningColumn.Name.Substring("Column".Length); object cellValue = cell.Value ?? DBNull.Value; // Use DBNull for null values rowData.Add(columnName, cellValue); @@ -1300,8 +1305,12 @@ private void exportDataGridViewToJSON(string filename) } } + // Help to keep the strings as they are (instead of showing 8192 for "Medium" it will show the string) + JsonSerializerSettings settings = new JsonSerializerSettings(); + settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); + // Serialize the data to JSON and write it to the file - string jsonData = JsonConvert.SerializeObject(rows, Formatting.Indented); + string jsonData = JsonConvert.SerializeObject(rows, Formatting.Indented, settings); File.WriteAllText(filename, jsonData); } private void importDataGridViewToCSV(string filename) @@ -1331,7 +1340,7 @@ private void importDataGridViewToJSON(string filename) // Add columns to DataGridView foreach (DataColumn column in dataTable.Columns) { - dataGridView1.Columns.Add(column.ColumnName, column.ColumnName); + dataGridView1.Columns.Add("Column"+column.ColumnName, column.ColumnName); } // Add rows to DataGridView diff --git a/PipeViewer/PipeViewer.csproj b/PipeViewer/PipeViewer.csproj index b84120a..225d214 100644 --- a/PipeViewer/PipeViewer.csproj +++ b/PipeViewer/PipeViewer.csproj @@ -8,7 +8,7 @@ WinExe PipeViewer PipeViewer - v4.8 + v4.6.1 512 true true diff --git a/PipeViewer/Properties/Resources.Designer.cs b/PipeViewer/Properties/Resources.Designer.cs index c34619b..8939826 100644 --- a/PipeViewer/Properties/Resources.Designer.cs +++ b/PipeViewer/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace PipeViewer.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/PipeViewer/Properties/Settings.Designer.cs b/PipeViewer/Properties/Settings.Designer.cs index e3c0fd0..569fdee 100644 --- a/PipeViewer/Properties/Settings.Designer.cs +++ b/PipeViewer/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace PipeViewer.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));