diff --git a/client/DebugLog.cs b/client/DebugLog.cs
index 6cb157f..10b286e 100644
--- a/client/DebugLog.cs
+++ b/client/DebugLog.cs
@@ -12,7 +12,8 @@ namespace specify_client;
public static class DebugLog
{
-
+ private static Settings Settings => Settings.Instance;
+
public static string LogText;
public static readonly int[] ErrorCount = new int[7];
private static bool Started = false;
@@ -344,9 +345,9 @@ private static string CreateDebugString(string message, Region region, EventType
private static async Task LogSettings()
{
var properties = typeof(Settings).GetProperties();
- foreach (PropertyInfo property in properties)
+ foreach (PropertyInfo property in properties.Where(x => x.Name != "EnableDebug"))
{
- await LogEventAsync($"{property.Name}: {property.GetValue(null)}");
+ await LogEventAsync($"{property.Name}: {property.GetValue(Settings.Instance)}");
}
}
diff --git a/client/Frontend/App.xaml b/client/Frontend/App.xaml
index 2184258..2399c3a 100644
--- a/client/Frontend/App.xaml
+++ b/client/Frontend/App.xaml
@@ -108,14 +108,19 @@
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
diff --git a/client/Frontend/App.xaml.cs b/client/Frontend/App.xaml.cs
index cbedd5b..2fa3010 100644
--- a/client/Frontend/App.xaml.cs
+++ b/client/Frontend/App.xaml.cs
@@ -11,6 +11,7 @@ namespace specify_client;
///
public partial class App : Application
{
+ private static Settings Settings => Settings.Instance;
[DllImport("Kernel32.dll")]
public static extern bool AllocConsole();
@@ -60,10 +61,6 @@ private async void Application_Startup(object sender, StartupEventArgs e)
Settings.RedactSerialNumber = true;
break;
- case "-redact-odc":
- Settings.RedactOneDriveCommercial = true;
- break;
-
case "-redact-networking":
Settings.RedactNetworking = true;
break;
diff --git a/client/Frontend/BoolToVisibilityConverter.cs b/client/Frontend/BoolToVisibilityConverter.cs
new file mode 100644
index 0000000..1e2e439
--- /dev/null
+++ b/client/Frontend/BoolToVisibilityConverter.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace specify_client.Frontend
+{
+ [ValueConversion(typeof(bool), typeof(Visibility))]
+ public class BoolToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Hidden;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/client/Frontend/CheckboxUserControl.xaml b/client/Frontend/CheckboxUserControl.xaml
new file mode 100644
index 0000000..2c639da
--- /dev/null
+++ b/client/Frontend/CheckboxUserControl.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/client/Frontend/CheckboxUserControl.xaml.cs b/client/Frontend/CheckboxUserControl.xaml.cs
new file mode 100644
index 0000000..e973f8c
--- /dev/null
+++ b/client/Frontend/CheckboxUserControl.xaml.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace specify_client.Frontend
+{
+ ///
+ /// Interaction logic for CheckboxUserControl.xaml
+ ///
+ public partial class CheckboxUserControl : UserControl
+ {
+ public static readonly DependencyProperty IsCheckedProperty =
+ DependencyProperty.Register(
+ name: "IsChecked",
+ propertyType: typeof(bool),
+ ownerType: typeof(CheckboxUserControl),
+ typeMetadata: new FrameworkPropertyMetadata(
+ defaultValue: false,
+ flags: FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
+
+ public static readonly DependencyProperty ContentProperty =
+ DependencyProperty.Register(
+ name: "Content",
+ propertyType: typeof(object),
+ ownerType: typeof(CheckboxUserControl));
+
+ public bool IsChecked
+ {
+ get => (bool)GetValue(IsCheckedProperty);
+ set => SetValue(IsCheckedProperty, value);
+ }
+ public object Content
+ {
+ get => GetValue(ContentProperty);
+ set => SetValue(ContentProperty, value);
+ }
+
+ public CheckboxUserControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/client/Frontend/SettingsUserControl.xaml b/client/Frontend/SettingsUserControl.xaml
new file mode 100644
index 0000000..5ccc743
--- /dev/null
+++ b/client/Frontend/SettingsUserControl.xaml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/Frontend/SettingsUserControl.xaml.cs b/client/Frontend/SettingsUserControl.xaml.cs
new file mode 100644
index 0000000..71c83d3
--- /dev/null
+++ b/client/Frontend/SettingsUserControl.xaml.cs
@@ -0,0 +1,16 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace specify_client.Frontend
+{
+ ///
+ /// Interaction logic for Settings.xaml
+ ///
+ public partial class SettingsUserControl : UserControl
+ {
+ public SettingsUserControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/client/Frontend/StartButtons.xaml b/client/Frontend/StartButtons.xaml
index 1b1d218..5834c52 100644
--- a/client/Frontend/StartButtons.xaml
+++ b/client/Frontend/StartButtons.xaml
@@ -4,28 +4,31 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:specify_client"
+ xmlns:frontend="clr-namespace:specify_client.Frontend"
mc:Ignorable="d"
Title="Specify"
Width="800" Height="400"
MinWidth="800" MinHeight="400"
d:Height="400" d:Width="800">
+
+
+
-
-
+
-
+
+
-
-
+
-
+
@@ -109,114 +112,10 @@
Background="#3b4252" Margin="5,5,5,5" />
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ Visibility="{Binding DontUpload, Source={x:Static local:Settings.Instance}, Converter={StaticResource boolToVisConverter}}" Margin="0,4,0,8">
Careful! Disabling upload will prevent helpers from seeing the report.
diff --git a/client/Frontend/StartButtons.xaml.cs b/client/Frontend/StartButtons.xaml.cs
index e5489fb..8c9cec9 100644
--- a/client/Frontend/StartButtons.xaml.cs
+++ b/client/Frontend/StartButtons.xaml.cs
@@ -27,72 +27,6 @@ private void SettingsOff(object sender, RoutedEventArgs e)
MainText.Visibility = Visibility.Visible;
}
- private void UploadOff(object sender, RoutedEventArgs e)
- {
- Settings.DontUpload = true;
- WarningTextBlock.Visibility = Visibility.Visible;
- }
-
- private void UploadOn(object sender, RoutedEventArgs e)
- {
- Settings.DontUpload = false;
- WarningTextBlock.Visibility = Visibility.Hidden;
- }
-
- private void UsernameOn(object sender, RoutedEventArgs e)
- {
- Settings.RedactUsername = true;
- Settings.RedactOneDriveCommercial = true;
- }
-
- private void UsernameOff(object sender, RoutedEventArgs e)
- {
- Settings.RedactUsername = false;
- Settings.RedactOneDriveCommercial = false;
- }
-
- private void SerialNumberOn(object sender, RoutedEventArgs e)
- {
- Settings.RedactSerialNumber = true;
- }
-
- private void SerialNumberOff(object sender, RoutedEventArgs e)
- {
- Settings.RedactSerialNumber = false;
- }
-
- private void RedactNetworkingOn(object sender, RoutedEventArgs e)
- {
- Settings.RedactNetworking = true;
- }
-
- private void RedactNetworkingOff(object sender, RoutedEventArgs e)
- {
- Settings.RedactNetworking = false;
- }
-
- private void DebugLogToggleOn(object sender, RoutedEventArgs e)
- {
- Settings.EnableDebug = true;
- }
-
- private void DebugLogToggleOff(object sender, RoutedEventArgs e)
- {
- Settings.EnableDebug = false;
- }
-
- private void UnlockUploadOn(object sender, RoutedEventArgs e)
- {
- DontUploadCheckbox.IsEnabled = true;
- DontUploadCheckbox.Foreground = new SolidColorBrush(Colors.White);
- WarningTextBlock.Visibility = Visibility.Visible;
- }
- private void UnlockUploadOff(object sender, RoutedEventArgs e)
- {
- DontUploadCheckbox.IsEnabled = false;
- DontUploadCheckbox.Foreground = new SolidColorBrush(Colors.Gray);
- WarningTextBlock.Visibility = Visibility.Hidden;
- }
private async void StartAction(object sender, RoutedEventArgs e)
{
try
diff --git a/client/Monolith.cs b/client/Monolith.cs
index a76f1d9..0705000 100644
--- a/client/Monolith.cs
+++ b/client/Monolith.cs
@@ -25,6 +25,7 @@ namespace specify_client;
[Serializable]
public class Monolith
{
+ private static Settings Settings => Settings.Instance;
// it will say these are never used, but they are serialized
public string Version;
@@ -84,21 +85,12 @@ await DebugLog.LogFatalError(
var serialized = m.Serialize();
await DebugLog.LogEventAsync("Monolith serialized");
- if (Settings.RedactOneDriveCommercial)
+ if (Settings.RedactUsername && Cache.UserVariables.Contains("OneDriveCommercial"))
{
- try
- {
- var stringToRedact = (string)Cache.UserVariables["OneDriveCommercial"]; // The path containing the Commercial OneDrive
- stringToRedact = stringToRedact.Replace(@"\", @"\\"); // Changing a single \ to two \\ as that is how it shows up in the generated json
- serialized = serialized.Replace(stringToRedact, "[REDACTED]");
- }
- catch (Exception e)
- {
- await DebugLog.LogEventAsync("Commercial OneDrive redaction failed. Serialization restarts." + e, DebugLog.Region.Misc, DebugLog.EventType.ERROR);
- Settings.RedactOneDriveCommercial = false;
- await Specificialize();
- return;
- }
+ var stringToRedact = (string)Cache.UserVariables["OneDriveCommercial"]; // The path containing the Commercial OneDrive
+ stringToRedact = stringToRedact.Replace(@"\", @"\\"); // Changing a single \ to two \\ as that is how it shows up in the generated json
+ serialized = serialized.Replace(stringToRedact, "[REDACTED]");
+
await DebugLog.LogEventAsync("Commercial OneDrive label redacted from report");
}
@@ -230,7 +222,7 @@ public static void ProgramDone(ProgramDoneState state)
Console.WriteLine("Specify is done.");
Console.WriteLine("Specify has uploaded the result to spec-ify.com, the link should be in your clipboard.");
}
- break;
+ break;
case ProgramDoneState.NoUpload:
if (!Settings.Headless)
diff --git a/client/Settings.cs b/client/Settings.cs
index 8f98f19..cfdc8fc 100644
--- a/client/Settings.cs
+++ b/client/Settings.cs
@@ -1,13 +1,17 @@
namespace specify_client;
-public static class Settings
+public class Settings
{
- public static bool RedactUsername { get; set; } = false;
- public static bool RedactSerialNumber { get; set; } = false;
- public static bool RedactOneDriveCommercial { get; set; } = false;
- public static bool RedactNetworking { get; set; } = false;
- public static bool DontUpload { get; set; } = false;
- public static bool Headless { get; set; } = false;
- public static bool LocalCulture { get; set; } = false;
- public static bool EnableDebug = false; // Deliberately not a property.
+ public static Settings Instance { get; set; } = new Settings();
+
+ ///
+ /// Redacts Windows username and OneDrive commercial account name
+ ///
+ public bool RedactUsername { get; set; } = false;
+ public bool RedactSerialNumber { get; set; } = false;
+ public bool RedactNetworking { get; set; } = false;
+ public bool DontUpload { get; set; } = false;
+ public bool Headless { get; set; } = false;
+ public bool LocalCulture { get; set; } = false;
+ public bool EnableDebug { get; set; } = false;
}
\ No newline at end of file
diff --git a/client/data/Methods/Network.cs b/client/data/Methods/Network.cs
index 396afea..82d1334 100644
--- a/client/data/Methods/Network.cs
+++ b/client/data/Methods/Network.cs
@@ -14,6 +14,8 @@ namespace specify_client.data;
public static partial class Cache
{
+ private static Settings Settings => Settings.Instance;
+
public static async Task MakeNetworkData()
{
try
diff --git a/client/data/Methods/System.cs b/client/data/Methods/System.cs
index 49ec51b..d18a7ec 100644
--- a/client/data/Methods/System.cs
+++ b/client/data/Methods/System.cs
@@ -837,18 +837,10 @@ private static async Task CheckCommercialOneDrive()
{
if (!ODFound)
{
- if (Settings.RedactOneDriveCommercial)
- {
- Settings.RedactOneDriveCommercial = false;
- await LogEventAsync("OneDriveCommercial variable not found. Corresponding internal setting disabled.", Region.System);
- }
- else
- {
await LogEventAsync("OneDriveCommercial variable not found.", Region.System);
}
}
}
- }
private static void GetScheduledTasks()
{
diff --git a/client/specify_client.csproj b/client/specify_client.csproj
index d5e3bb9..273345e 100644
--- a/client/specify_client.csproj
+++ b/client/specify_client.csproj
@@ -141,6 +141,13 @@
+
+
+ CheckboxUserControl.xaml
+
+
+ SettingsUserControl.xaml
+
@@ -167,6 +174,10 @@
UploadFail.xaml
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -195,6 +206,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -270,4 +285,4 @@
-
+
\ No newline at end of file