From 6298316c947ada78c9082ec2b4478cd187f9c6ce Mon Sep 17 00:00:00 2001
From: F K <54195004+fredjk-gh@users.noreply.github.com>
Date: Sun, 26 Feb 2023 09:50:59 -0500
Subject: [PATCH] Implement Tab separated export format (#103)
Tab separated output facilitates much more efficient opening of exported content in a spreadsheet for further data analysis, furthermore, it vastly reduces file size at the cost of human-readability. However, for the spreadsheet junkies among us, this is a welcome option.
To complement this, there is now an "Export Options" expander in the Core settings panel. Here one can select their preferred export style (default remains Fixed width) and now one can pre-select the export folder.
With this change, clicking export *will not* prompt for an export folder if one is already set. It will simply immediately export data.
Enjoy!
---
ObservatoryCore/Properties/Core.Designer.cs | 14 +-
ObservatoryCore/Properties/Core.settings | 3 +
.../UI/ViewModels/CoreViewModel.cs | 200 +++++++++++-------
ObservatoryCore/UI/Views/BasicUIView.axaml.cs | 107 +++++++++-
4 files changed, 243 insertions(+), 81 deletions(-)
diff --git a/ObservatoryCore/Properties/Core.Designer.cs b/ObservatoryCore/Properties/Core.Designer.cs
index 96eba62..bca9546 100644
--- a/ObservatoryCore/Properties/Core.Designer.cs
+++ b/ObservatoryCore/Properties/Core.Designer.cs
@@ -12,7 +12,7 @@ namespace Observatory.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")]
internal sealed partial class Core : global::System.Configuration.ApplicationSettingsBase {
private static Core defaultInstance = ((Core)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Core())));
@@ -274,5 +274,17 @@ namespace Observatory.Properties {
this["StartReadAll"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Fixed width")]
+ public string ExportStyle {
+ get {
+ return ((string)(this["ExportStyle"]));
+ }
+ set {
+ this["ExportStyle"] = value;
+ }
+ }
}
}
diff --git a/ObservatoryCore/Properties/Core.settings b/ObservatoryCore/Properties/Core.settings
index 37938c1..77b31db 100644
--- a/ObservatoryCore/Properties/Core.settings
+++ b/ObservatoryCore/Properties/Core.settings
@@ -65,5 +65,8 @@
False
+
+ Fixed width
+
\ No newline at end of file
diff --git a/ObservatoryCore/UI/ViewModels/CoreViewModel.cs b/ObservatoryCore/UI/ViewModels/CoreViewModel.cs
index 219814d..9dd4a87 100644
--- a/ObservatoryCore/UI/ViewModels/CoreViewModel.cs
+++ b/ObservatoryCore/UI/ViewModels/CoreViewModel.cs
@@ -112,95 +112,67 @@ namespace Observatory.UI.ViewModels
try
{
var exportFolder = Properties.Core.Default.ExportFolder;
-
if (string.IsNullOrEmpty(exportFolder))
{
exportFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+
+ OpenFolderDialog openFolderDialog = new()
+ {
+ Directory = exportFolder
+ };
+
+ var application = (IClassicDesktopStyleApplicationLifetime)Avalonia.Application.Current.ApplicationLifetime;
+
+ var selectedFolder = await openFolderDialog.ShowAsync(application.MainWindow);
+
+ if (!string.IsNullOrEmpty(selectedFolder))
+ {
+ Properties.Core.Default.ExportFolder = selectedFolder;
+ Properties.Core.Default.Save();
+ exportFolder = selectedFolder;
+ }
}
- OpenFolderDialog openFolderDialog = new()
+ var exportStyle = Properties.Core.Default.ExportStyle;
+ if (string.IsNullOrEmpty(exportStyle))
{
- Directory = exportFolder
- };
-
- var application = (IClassicDesktopStyleApplicationLifetime)Avalonia.Application.Current.ApplicationLifetime;
-
- var selectedFolder = await openFolderDialog.ShowAsync(application.MainWindow);
-
- if (!string.IsNullOrEmpty(selectedFolder))
- {
- Properties.Core.Default.ExportFolder = selectedFolder;
+ exportStyle = "Fixed width";
+ Properties.Core.Default.ExportStyle = exportStyle;
Properties.Core.Default.Save();
- exportFolder = selectedFolder;
+ }
- foreach (var tab in tabs.Where(t => t.Name != "Core"))
+ foreach (var tab in tabs.Where(t => t.Name != "Core"))
+ {
+ var ui = (BasicUIViewModel)tab.UI;
+ List