Skip to content

Commit

Permalink
Merge pull request #426 from TheJoeFin/new-settings-pages
Browse files Browse the repository at this point in the history
New Settings UX Improvements
  • Loading branch information
TheJoeFin committed Feb 17, 2024
2 parents b82f02a + 3bcc4e2 commit 200d310
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 729 deletions.
83 changes: 81 additions & 2 deletions Text-Grab/Pages/GeneralSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@
Click="AboutBTN_Click" />
</Grid>

<Border
Margin="0,20"
Padding="20,12,20,20"
Background="{ui:ThemeResource SolidBackgroundFillColorBaseBrush}"
CornerRadius="8">
<StackPanel Orientation="Vertical">
<TextBlock Style="{StaticResource TextHeader}" Text="Hello there!" />
<TextBlock Style="{StaticResource TextBodyNormal}">
Thank you for using Text Grab!
Building this application is very much a labor of love. I am always happy to hear from users to better understand how you use the app and what you would like to see in the future.<LineBreak />
Feel free to open an issue on GitHub if you have a bug or feature request. Email me directly for questions or just to say hi.<LineBreak />
Happy Text Grabbing!</TextBlock>
<TextBlock
Margin="0,12"
HorizontalAlignment="Left"
Style="{StaticResource TextBodyNormal}"
Text="- Joe" />
<ui:HyperlinkButton NavigateUri="https://github.com/TheJoeFin/Text-Grab/issues">
🌐 https://github.com/TheJoeFin/Text-Grab/issues
</ui:HyperlinkButton>
<ui:HyperlinkButton NavigateUri="mailto:[email protected]">
📧 [email protected]
</ui:HyperlinkButton>
</StackPanel>
</Border>

<!-- Theme -->
<TextBlock
Margin="0,16,0,4"
Expand Down Expand Up @@ -88,7 +114,10 @@
FontSize="16"
Style="{StaticResource TextHeader}"
Text="Show Notification" />
<ui:ToggleSwitch Name="ShowToastCheckBox">
<ui:ToggleSwitch
Name="ShowToastCheckBox"
Checked="ShowToastCheckBox_Checked"
Unchecked="ShowToastCheckBox_Unchecked">
<TextBlock Style="{StaticResource TextBodyNormal}">
Show Notification when text is copied.
</TextBlock>
Expand Down Expand Up @@ -140,7 +169,6 @@
</TextBlock>
</RadioButton>


<!-- Run in the background -->
<TextBlock
Margin="0,16,0,4"
Expand All @@ -156,6 +184,17 @@
</TextBlock>
</ui:ToggleSwitch>

<!-- Startup on login -->
<ui:ToggleSwitch
Name="StartupOnLoginCheckBox"
Margin="0,12,0,0"
Checked="StartupOnLoginCheckBox_Checked"
Unchecked="StartupOnLoginCheckBox_Unchecked">
<TextBlock x:Name="StartupTextBlock" Style="{StaticResource TextBodyNormal}">
Auto start Text Grab when you login
</TextBlock>
</ui:ToggleSwitch>

<TextBlock
Margin="0,16,0,4"
FontSize="16"
Expand Down Expand Up @@ -212,6 +251,46 @@
</TextBlock>
</ui:ToggleSwitch>

<StackPanel>
<ui:ToggleSwitch
Name="TryInsertCheckbox"
Margin="0,12,0,0"
Checked="TryInsertCheckbox_Checked"
Unchecked="TryInsertCheckbox_Unchecked">
<TextBlock Style="{StaticResource TextBodyNormal}">
Try to Insert text in text fields after Fullscreen Grab after:
</TextBlock>
</ui:ToggleSwitch>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal">
<TextBox
x:Name="SecondsTextBox"
Width="40"
Height="26"
Margin="48,0,0,0"
HorizontalAlignment="Left"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Background="White"
FontWeight="Medium"
Foreground="Black"
Style="{StaticResource TextBoxStyle1}"
Text="0.5"
TextChanged="ValidateTextIsNumber" />
<TextBlock
Margin="4,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource TextBodyNormal}"
Text="Seconds" />
<TextBlock
x:Name="DelayTimeErrorSeconds"
Margin="12,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource TextBodyNormal}"
Text="⚠ Pick a number between 0 and 10"
Visibility="Collapsed" />
</StackPanel>
</StackPanel>

<TextBlock
Margin="0,16,0,4"
FontSize="16"
Expand Down
100 changes: 98 additions & 2 deletions Text-Grab/Pages/GeneralSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Text_Grab.Properties;
using Text_Grab.Utilities;
using Windows.ApplicationModel;
using Wpf.Ui.Controls;

namespace Text_Grab.Pages;
Expand All @@ -14,7 +16,15 @@ namespace Text_Grab.Pages;
/// </summary>
public partial class GeneralSettings : Page
{
private Settings DefaultSettings = Settings.Default;
#region Fields

private readonly Settings DefaultSettings = Settings.Default;
private readonly Brush BadBrush = new SolidColorBrush(Colors.Red);
private readonly Brush GoodBrush = new SolidColorBrush(Colors.Transparent);
private double InsertDelaySeconds = 1.5;

#endregion Fields


public GeneralSettings()
{
Expand All @@ -41,7 +51,7 @@ private void AboutBTN_Click(object sender, RoutedEventArgs e)
WindowUtilities.OpenOrActivateWindow<FirstRunWindow>();
}

private void Page_Loaded(object sender, RoutedEventArgs e)
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
AppTheme appTheme = Enum.Parse<AppTheme>(DefaultSettings.AppTheme, true);
switch (appTheme)
Expand Down Expand Up @@ -80,13 +90,67 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
break;
}

if (ImplementAppOptions.IsPackaged())
{
StartupTask startupTask = await StartupTask.GetAsync("StartTextGrab");

switch (startupTask.State)
{
case StartupTaskState.Disabled:
// Task is disabled but can be enabled.
StartupOnLoginCheckBox.IsChecked = false;
break;
case StartupTaskState.DisabledByUser:
// Task is disabled and user must enable it manually.
StartupOnLoginCheckBox.IsChecked = false;
StartupOnLoginCheckBox.IsEnabled = false;

StartupTextBlock.Text += "\nDisabled in Task Manager";
break;
case StartupTaskState.Enabled:
StartupOnLoginCheckBox.IsChecked = true;
break;
}
}
else
{
StartupOnLoginCheckBox.IsChecked = Settings.Default.StartupOnLogin;
}

ShowToastCheckBox.IsChecked = DefaultSettings.ShowToast;
RunInBackgroundChkBx.IsChecked = DefaultSettings.RunInTheBackground;
ReadBarcodesBarcode.IsChecked = DefaultSettings.TryToReadBarcodes;
HistorySwitch.IsChecked = DefaultSettings.UseHistory;
ErrorCorrectBox.IsChecked = DefaultSettings.CorrectErrors;
CorrectToLatin.IsChecked = DefaultSettings.CorrectToLatin;
NeverUseClipboardChkBx.IsChecked = DefaultSettings.NeverAutoUseClipboard;
TryInsertCheckbox.IsChecked = DefaultSettings.TryInsert;
InsertDelaySeconds = DefaultSettings.InsertDelay;
SecondsTextBox.Text = InsertDelaySeconds.ToString("##.#", System.Globalization.CultureInfo.InvariantCulture);
}

private void ValidateTextIsNumber(object sender, TextChangedEventArgs e)
{
if (!IsLoaded)
return;

if (sender is System.Windows.Controls.TextBox numberInputBox)
{
bool wasAbleToConvert = double.TryParse(numberInputBox.Text, out double parsedText);
if (wasAbleToConvert && parsedText > 0 && parsedText < 10)
{
InsertDelaySeconds = parsedText;
DefaultSettings.InsertDelay = InsertDelaySeconds;
DelayTimeErrorSeconds.Visibility = Visibility.Collapsed;
numberInputBox.BorderBrush = GoodBrush;
}
else
{
InsertDelaySeconds = 3;
DelayTimeErrorSeconds.Visibility = Visibility.Visible;
numberInputBox.BorderBrush = BadBrush;
}
}
}

private void FullScreenRDBTN_Checked(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -185,4 +249,36 @@ private void NeverUseClipboardChkBx_Unchecked(object sender, RoutedEventArgs e)
{
DefaultSettings.NeverAutoUseClipboard = false;
}

private async void StartupOnLoginCheckBox_Checked(object sender, RoutedEventArgs e)
{
DefaultSettings.StartupOnLogin = true;
await ImplementAppOptions.ImplementStartupOption(true);
}

private async void StartupOnLoginCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
DefaultSettings.StartupOnLogin = false;
await ImplementAppOptions.ImplementStartupOption(false);
}

private void TryInsertCheckbox_Checked(object sender, RoutedEventArgs e)
{
DefaultSettings.TryInsert = true;
}

private void TryInsertCheckbox_Unchecked(object sender, RoutedEventArgs e)
{
DefaultSettings.TryInsert = false;
}

private void ShowToastCheckBox_Checked(object sender, RoutedEventArgs e)
{
DefaultSettings.ShowToast = true;
}

private void ShowToastCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
DefaultSettings.ShowToast = false;
}
}
2 changes: 1 addition & 1 deletion Text-Grab/Pages/TesseractSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Text_Grab.Pages;
/// </summary>
public partial class TesseractSettings : Page
{
private Settings DefaultSettings = Settings.Default;
private readonly Settings DefaultSettings = Settings.Default;

public TesseractSettings()
{
Expand Down
Loading

0 comments on commit 200d310

Please sign in to comment.