Skip to content

Commit

Permalink
Add themes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Nov 6, 2024
1 parent 6022b11 commit 71084d8
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 9 deletions.
22 changes: 21 additions & 1 deletion Yura/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Sentry;
using System;
using System.IO;
using System.Windows;
using Yura.Properties;

namespace Yura
{
Expand All @@ -9,6 +11,8 @@ namespace Yura
/// </summary>
public partial class App : Application
{
private const string SentryDsn = "https://2bca1d6075984d7fb74e569f4f6ff3a1@o4503985120215040.ingest.sentry.io/4503985128341504";

private MainWindow _window;

public App()
Expand All @@ -17,7 +21,7 @@ public App()
// setup sentry
SentrySdk.Init(options =>
{
options.Dsn = "https://2bca1d6075984d7fb74e569f4f6ff3a1@o4503985120215040.ingest.sentry.io/4503985128341504";
options.Dsn = SentryDsn;
options.IsGlobalModeEnabled = true;

options.BeforeSend = sentryEvent =>

Check warning on line 27 in Yura/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'SentryOptions.BeforeSend' is obsolete: 'This property will be removed in a future version. Use SetBeforeSend instead.'

Check warning on line 27 in Yura/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'SentryOptions.BeforeSend' is obsolete: 'This property will be removed in a future version. Use SetBeforeSend instead.'

Check warning on line 27 in Yura/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'SentryOptions.BeforeSend' is obsolete: 'This property will be removed in a future version. Use SetBeforeSend instead.'

Check warning on line 27 in Yura/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'SentryOptions.BeforeSend' is obsolete: 'This property will be removed in a future version. Use SetBeforeSend instead.'
Expand All @@ -35,8 +39,24 @@ public App()
#endif
}

private void SetTheme(Theme theme)
{
var name = theme == Theme.Light ? "Light.xaml" : "Dark.xaml";

var dictionary = new ResourceDictionary()
{
Source = new Uri("/Themes/" + name, UriKind.Relative)
};

Resources.MergedDictionaries.Add(dictionary);
}

private void Application_Startup(object sender, StartupEventArgs e)
{
// set the theme
SetTheme((Theme)Settings.Default.Theme);

// show the main window
_window = new MainWindow();
_window.Show();

Expand Down
14 changes: 13 additions & 1 deletion Yura/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Yura/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<Setting Name="ClickAction" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="Theme" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
22 changes: 16 additions & 6 deletions Yura/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>

<!-- spec mask view -->
<Label Grid.Column="0" Grid.Row="0" Margin="5">Specialisation mask view</Label>
<!-- theme -->
<Label Grid.Column="0" Grid.Row="0" Margin="5">Theme</Label>
<ComboBox Grid.Column="1" Grid.Row="0" Margin="5"
Name="Theme"
SelectionChanged="Theme_SelectionChanged">
<ComboBoxItem>Light</ComboBoxItem>
<ComboBoxItem>Dark</ComboBoxItem>
</ComboBox>

<!-- spec mask view -->
<Label Grid.Column="0" Grid.Row="1" Margin="5">Specialisation mask view</Label>
<ComboBox Grid.Column="1" Grid.Row="1" Margin="5"
Name="SpecMaskView"
SelectionChanged="SpecMaskView_SelectionChanged">
<ComboBoxItem>Display languages</ComboBoxItem>
Expand All @@ -33,17 +43,17 @@
</ComboBox>

<!-- click action -->
<Label Grid.Column="0" Grid.Row="1" Margin="5">Double-click action</Label>
<ComboBox Grid.Column="1" Grid.Row="1" Margin=" 5" Name="ClickAction"
<Label Grid.Column="0" Grid.Row="2" Margin="5">Double-click action</Label>
<ComboBox Grid.Column="1" Grid.Row="2" Margin=" 5" Name="ClickAction"
SelectionChanged="ClickAction_SelectionChanged">
<ComboBoxItem>Open file</ComboBoxItem>
<ComboBoxItem>Only open in Yura</ComboBoxItem>
<ComboBoxItem>Export file</ComboBoxItem>
</ComboBox>

<!-- file associations -->
<Label Grid.Column="0" Grid.Row="2" Margin="5">File associations</Label>
<Button Grid.Column="1" Grid.Row="2" Margin="5" Name="FileAssociations"
<Label Grid.Column="0" Grid.Row="3" Margin="5">File associations</Label>
<Button Grid.Column="1" Grid.Row="3" Margin="5" Name="FileAssociations"
Click="FileAssociations_Click">Update</Button>
</Grid>
</Window>
7 changes: 6 additions & 1 deletion Yura/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public SettingsWindow()
{
InitializeComponent();

Theme.SelectedIndex = Properties.Settings.Default.Theme;
SpecMaskView.SelectedIndex = Properties.Settings.Default.SpecMaskView;
ClickAction.SelectedIndex = Properties.Settings.Default.ClickAction;
}
Expand All @@ -28,6 +29,11 @@ private void Window_Closed(object sender, EventArgs e)
Properties.Settings.Default.Save();
}

private void Theme_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Properties.Settings.Default.Theme = Theme.SelectedIndex;
}

private void SpecMaskView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Properties.Settings.Default.SpecMaskView = SpecMaskView.SelectedIndex;
Expand All @@ -47,7 +53,6 @@ private void FileAssociations_Click(object sender, RoutedEventArgs e)
// associate .000, .dat and .tiger with Yura
reg.CreateSubKey(".000").SetValue(string.Empty, ProgId);
reg.CreateSubKey(".dat").SetValue(string.Empty, ProgId);
reg.CreateSubKey(".tiger").SetValue(string.Empty, ProgId);

// define yura, see https://learn.microsoft.com/en-us/windows/win32/shell/fa-progids
var program = reg.CreateSubKey(ProgId);
Expand Down
8 changes: 8 additions & 0 deletions Yura/Theme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Yura
{
internal enum Theme
{
Light,
Dark
}
}
17 changes: 17 additions & 0 deletions Yura/Themes/Dark.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<SolidColorBrush x:Key="BackgroundColor" Color="Black" />
<SolidColorBrush x:Key="ForegroundColor" Color="White" />

<Style TargetType="ListView">
<Setter Property="Background" Value="{StaticResource BackgroundColor}" />
<Setter Property="Foreground" Value="{StaticResource ForegroundColor}" />
</Style>

<Style TargetType="TreeView">
<Setter Property="Background" Value="{StaticResource BackgroundColor}" />
<Setter Property="Foreground" Value="{StaticResource ForegroundColor}" />
</Style>

</ResourceDictionary>
4 changes: 4 additions & 0 deletions Yura/Themes/Light.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

</ResourceDictionary>

0 comments on commit 71084d8

Please sign in to comment.