mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
Add better theme support
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<Window x:Class="DesktopMagic.Dialogs.ThemeDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:local="clr-namespace:DesktopMagic.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
ResizeMode="NoResize"
|
||||
Title="ThemeDialog"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
SizeToContent="WidthAndHeight">
|
||||
<Grid>
|
||||
<StackPanel Margin="15">
|
||||
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Loaded="TextBlock_Loaded"/>
|
||||
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
|
||||
|
||||
<TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Grid.Row="1" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
|
||||
<materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
<Style TargetType="TextBlock" />
|
||||
</materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
</TextBox>
|
||||
|
||||
<TextBlock Text="Margin: " Grid.Column="0" Grid.Row="3" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="marginTextBox" Grid.Column="1" Grid.Row="3" TextChanged="MarginTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
|
||||
<materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
<Style TargetType="TextBlock" />
|
||||
</materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
||||
<DockPanel Margin="0,0,0,5">
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click" />
|
||||
</DockPanel>
|
||||
<DockPanel Margin="0,0,0,5">
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="secondaryColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Secondary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeSecondaryColorButton_Click" />
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="backgroundColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Background Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeBackgroundColorButton_Click" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
|
||||
<Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand" />
|
||||
<Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,143 @@
|
||||
using DesktopMagic.Helpers;
|
||||
using DesktopMagic.Plugins;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DesktopMagic.Dialogs;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for ColorDialog.xaml
|
||||
/// </summary>
|
||||
public partial class ThemeDialog : Window
|
||||
{
|
||||
private readonly Theme theme;
|
||||
|
||||
public ThemeDialog(string content, Theme theme, string title = App.AppName)
|
||||
{
|
||||
this.theme = theme;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Resources.MergedDictionaries.Add(App.LanguageDictionary);
|
||||
|
||||
cornerRadiusTextBox.Text = theme.CornerRadius.ToString();
|
||||
marginTextBox.Text = theme.Margin.ToString();
|
||||
primaryColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(theme.PrimaryColor));
|
||||
secondaryColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(theme.SecondaryColor));
|
||||
backgroundColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(theme.BackgroundColor));
|
||||
|
||||
label.Content = content;
|
||||
Title = title;
|
||||
}
|
||||
|
||||
private void OkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
}
|
||||
|
||||
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (FontFamily ff in Fonts.SystemFontFamilies)
|
||||
{
|
||||
ComboBoxItem comboBoxItem = new()
|
||||
{
|
||||
FontFamily = ff,
|
||||
Content = ff.ToString()
|
||||
};
|
||||
_ = fontComboBox.Items.Add(comboBoxItem);
|
||||
|
||||
if (ff.ToString() == theme.Font)
|
||||
{
|
||||
fontComboBox.SelectedIndex = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (fontComboBox.SelectedIndex == -1)
|
||||
{
|
||||
fontComboBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
theme.Font = fontComboBox.SelectedValue.ToString()!.Replace("System.Windows.Controls.ComboBoxItem: ", "");
|
||||
}
|
||||
|
||||
private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Primary Color", theme.PrimaryColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
theme.PrimaryColor = colorDialog.ResultColor;
|
||||
primaryColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeSecondaryColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Secondary Color", theme.SecondaryColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
theme.SecondaryColor = colorDialog.ResultColor;
|
||||
secondaryColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeBackgroundColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Background Color", theme.BackgroundColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
theme.BackgroundColor = colorDialog.ResultColor;
|
||||
backgroundColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void CornerRadiusTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
|
||||
{
|
||||
bool success = int.TryParse(cornerRadiusTextBox.Text, out int cornerRadius);
|
||||
if (success)
|
||||
{
|
||||
cornerRadiusTextBox.Foreground = Brushes.Black;
|
||||
theme.CornerRadius = cornerRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
cornerRadiusTextBox.Foreground = Brushes.Red;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarginTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
|
||||
{
|
||||
bool success = int.TryParse(marginTextBox.Text, out int margin);
|
||||
if (success)
|
||||
{
|
||||
marginTextBox.Foreground = Brushes.Black;
|
||||
theme.Margin = margin;
|
||||
}
|
||||
else
|
||||
{
|
||||
marginTextBox.Foreground = Brushes.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<busyIndicator:BusyMask x:Name="BusyIndicator" IsBusy="{Binding IsLoading}" IndicatorType="Cogs" BusyContent="Please wait..." BusyContentMargin="0,20,0,0" IsBusyAtStartup="False">
|
||||
<Grid>
|
||||
<TextBlock TextWrapping="Wrap" Text="0" VerticalAlignment="Top" FontFamily="Comic Sans MS" Loaded="TextBlock_Loaded" Foreground="Transparent" />
|
||||
<TextBlock TextWrapping="Wrap" Text="0" VerticalAlignment="Top" FontFamily="Comic Sans MS" Foreground="Transparent" />
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
@@ -38,7 +38,7 @@
|
||||
<DockPanel Margin="0,0,2.5,0">
|
||||
<Grid DockPanel.Dock="Top">
|
||||
<Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" />
|
||||
<CheckBox x:Name="editCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" />
|
||||
<CheckBox x:Name="editCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource editLayout}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" />
|
||||
</Grid>
|
||||
<ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||
<ItemsControl ItemsSource="{Binding Settings.CurrentLayout.Plugins}">
|
||||
@@ -75,53 +75,26 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
|
||||
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
|
||||
|
||||
<TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Grid.Row="1" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
|
||||
<materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
<Style TargetType="TextBlock" />
|
||||
</materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
</TextBox>
|
||||
|
||||
<TextBlock Text="Margin: " Grid.Column="0" Grid.Row="3" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="marginTextBox" Grid.Column="1" Grid.Row="3" TextChanged="MarginTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
|
||||
<materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
<Style TargetType="TextBlock" />
|
||||
</materialDesign:TextFieldAssist.CharacterCounterStyle>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
|
||||
<DockPanel Margin="0,0,0,5">
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click" />
|
||||
</DockPanel>
|
||||
<DockPanel Margin="0,0,0,5">
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="secondaryColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Secondary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeSecondaryColorButton_Click" />
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
|
||||
<Rectangle x:Name="backgroundColorRechtangle" Fill="White" />
|
||||
</Border>
|
||||
<Button Content="Change Background Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeBackgroundColorButton_Click" />
|
||||
</DockPanel>
|
||||
<ListBox x:Name="themesListBox" Grid.Row="0" Grid.ColumnSpan="1" Margin="{StaticResource DefaultMargin}" ItemsSource="{Binding Settings.Themes}" DisplayMemberPath="Name" SelectedValue="{Binding Settings.CurrentLayout.CurrentThemeName}" SelectedValuePath="Name" />
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="{StaticResource DefaultMargin}">
|
||||
<Button x:Name="addThemeButton" Margin="0,0,0,5" HorizontalAlignment="Stretch" FontWeight="Regular">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Add" Margin="0 0 10 0" />
|
||||
<TextBlock Text="{DynamicResource newTheme}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="deleteThemeButton" Margin="0,0,0,5" HorizontalAlignment="Stretch" FontWeight="Regular">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="DeleteOutline" Margin="0 0 10 0" />
|
||||
<TextBlock Text="{DynamicResource deleteTheme}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="changeThemeButton" Margin="0,0,0,5" HorizontalAlignment="Stretch" Click="ChangeThemeButton_Click" FontWeight="Regular">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="PaletteOutline" Margin="0 0 10 0" />
|
||||
<TextBlock Text="{DynamicResource changeTheme}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@@ -11,10 +11,8 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DesktopMagic
|
||||
{
|
||||
@@ -301,9 +299,16 @@ namespace DesktopMagic
|
||||
|
||||
#region Options
|
||||
|
||||
private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
private void ChangeThemeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings.CurrentLayout.Theme.Font = fontComboBox.SelectedValue.ToString()!.Replace("System.Windows.Controls.ComboBoxItem: ", "");
|
||||
Theme theme = themesListBox.SelectedItem as Theme ?? Settings.CurrentLayout.Theme;
|
||||
|
||||
ThemeDialog themeDialog = new(theme.Name, theme, App.AppName)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
themeDialog.ShowDialog();
|
||||
}
|
||||
|
||||
private void OptionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -381,100 +386,6 @@ namespace DesktopMagic
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (FontFamily ff in Fonts.SystemFontFamilies)
|
||||
{
|
||||
ComboBoxItem comboBoxItem = new()
|
||||
{
|
||||
FontFamily = ff,
|
||||
Content = ff.ToString()
|
||||
};
|
||||
_ = fontComboBox.Items.Add(comboBoxItem);
|
||||
|
||||
if (ff.ToString() == Settings.CurrentLayout.Theme.Font)
|
||||
{
|
||||
fontComboBox.SelectedIndex = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (fontComboBox.SelectedIndex == -1)
|
||||
{
|
||||
fontComboBox.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangePrimaryColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Primary Color", Settings.CurrentLayout.Theme.PrimaryColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
Settings.CurrentLayout.Theme.PrimaryColor = colorDialog.ResultColor;
|
||||
primaryColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeSecondaryColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Secondary Color", Settings.CurrentLayout.Theme.SecondaryColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
Settings.CurrentLayout.Theme.SecondaryColor = colorDialog.ResultColor;
|
||||
secondaryColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeBackgroundColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorDialog colorDialog = new ColorDialog("Set Background Color", Settings.CurrentLayout.Theme.BackgroundColor)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (colorDialog.ShowDialog() == true)
|
||||
{
|
||||
Settings.CurrentLayout.Theme.BackgroundColor = colorDialog.ResultColor;
|
||||
backgroundColorRechtangle.Fill = colorDialog.ResultBrush;
|
||||
}
|
||||
}
|
||||
|
||||
private void CornerRadiusTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
|
||||
{
|
||||
bool success = int.TryParse(cornerRadiusTextBox.Text, out int cornerRadius);
|
||||
if (success)
|
||||
{
|
||||
cornerRadiusTextBox.Foreground = Brushes.Black;
|
||||
Settings.CurrentLayout.Theme.CornerRadius = cornerRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
cornerRadiusTextBox.Foreground = Brushes.Red;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarginTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
|
||||
{
|
||||
bool success = int.TryParse(marginTextBox.Text, out int margin);
|
||||
if (success)
|
||||
{
|
||||
marginTextBox.Foreground = Brushes.Black;
|
||||
Settings.CurrentLayout.Theme.Margin = margin;
|
||||
}
|
||||
else
|
||||
{
|
||||
marginTextBox.Foreground = Brushes.Red;
|
||||
}
|
||||
}
|
||||
|
||||
#region Layout
|
||||
|
||||
private readonly JsonSerializerOptions jsonSettingsOptions = new()
|
||||
@@ -538,9 +449,11 @@ namespace DesktopMagic
|
||||
{
|
||||
Settings = new DesktopMagicSettings()
|
||||
{
|
||||
Layouts =
|
||||
[
|
||||
Layouts = [
|
||||
new Layout((string)FindResource("default"))
|
||||
],
|
||||
Themes = [
|
||||
new Theme((string)FindResource("default"))
|
||||
]
|
||||
};
|
||||
|
||||
@@ -551,9 +464,11 @@ namespace DesktopMagic
|
||||
|
||||
Settings = JsonSerializer.Deserialize<DesktopMagicSettings>(json, jsonSettingsOptions) ?? new DesktopMagicSettings()
|
||||
{
|
||||
Layouts =
|
||||
[
|
||||
Layouts = [
|
||||
new Layout((string)FindResource("default"))
|
||||
],
|
||||
Themes = [
|
||||
new Theme((string)FindResource("default"))
|
||||
]
|
||||
};
|
||||
}
|
||||
@@ -561,17 +476,8 @@ namespace DesktopMagic
|
||||
private void LoadLayout(bool minimize = true)
|
||||
{
|
||||
mainWindowDataContext.IsLoading = true;
|
||||
cornerRadiusTextBox.Text = Settings.CurrentLayout.Theme.CornerRadius.ToString();
|
||||
marginTextBox.Text = Settings.CurrentLayout.Theme.Margin.ToString();
|
||||
blockWindowsClosing = false;
|
||||
|
||||
primaryColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(Settings.CurrentLayout.Theme.PrimaryColor));
|
||||
secondaryColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(Settings.CurrentLayout.Theme.SecondaryColor));
|
||||
backgroundColorRechtangle.Fill = new SolidColorBrush(MultiColorConverter.ConvertToMediaColor(Settings.CurrentLayout.Theme.BackgroundColor));
|
||||
|
||||
CornerRadiusTextBox_TextChanged(null, null);
|
||||
MarginTextBox_TextChanged(null, null);
|
||||
|
||||
foreach (Window window in Windows)
|
||||
{
|
||||
window.Close();
|
||||
|
||||
@@ -9,7 +9,7 @@ internal class PluginData(PluginWindow window, PluginSettings pluginSettings) :
|
||||
{
|
||||
private readonly PluginWindow window = window;
|
||||
|
||||
public ITheme Theme { get; } = pluginSettings.Theme;
|
||||
public ITheme Theme => pluginSettings.Theme;
|
||||
|
||||
public Size WindowSize => new Size((int)window.ActualWidth, (int)window.ActualHeight);
|
||||
|
||||
|
||||
@@ -11,17 +11,27 @@ using Color = System.Drawing.Color;
|
||||
|
||||
namespace DesktopMagic.Plugins;
|
||||
|
||||
public class Theme : ITheme, INotifyPropertyChanged
|
||||
public class Theme(string name) : ITheme, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private Color primaryColor = Color.White;
|
||||
private Color secondaryColor = Color.White;
|
||||
private Color secondaryColor = Color.LightGray;
|
||||
private Color backgroundColor = Color.Transparent;
|
||||
private string font = "Segoe UI";
|
||||
private int cornerRadius;
|
||||
private int margin;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => name;
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public Color PrimaryColor
|
||||
{
|
||||
get => primaryColor;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<system:String x:Key="default">Standard</system:String>
|
||||
<system:String x:Key="wantToCloseProgram">Wollen sie das Programm wirklich schließen?</system:String>
|
||||
<system:String x:Key="noOptions">Keine Optionen!</system:String>
|
||||
<system:String x:Key="edit">Bearbeiten</system:String>
|
||||
<system:String x:Key="editLayout">Layout Bearbeiten</system:String>
|
||||
<system:String x:Key="time">Uhrzeit</system:String>
|
||||
<system:String x:Key="date">Datum</system:String>
|
||||
<system:String x:Key="cpuUsage">CPU Auslastung</system:String>
|
||||
@@ -34,6 +34,9 @@
|
||||
<system:String x:Key="amplifier">Signalverstärkung:</system:String>
|
||||
<system:String x:Key="newLayout">Neues Layout</system:String>
|
||||
<system:String x:Key="deleteLayout">Layout Löschen</system:String>
|
||||
<system:String x:Key="newTheme">Neues Theme</system:String>
|
||||
<system:String x:Key="deleteTheme">Theme Löschen</system:String>
|
||||
<system:String x:Key="changeTheme">Theme Ändern</system:String>
|
||||
<system:String x:Key="ok">Ok</system:String>
|
||||
<system:String x:Key="cancel">Abbrechen</system:String>
|
||||
<system:String x:Key="enterLayoutName">Layoutnamen eingeben:</system:String>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<system:String x:Key="default">Default</system:String>
|
||||
<system:String x:Key="wantToCloseProgram">Do you really want to close the program?</system:String>
|
||||
<system:String x:Key="noOptions">No Options!</system:String>
|
||||
<system:String x:Key="edit">Edit</system:String>
|
||||
<system:String x:Key="editLayout">Edit Layout</system:String>
|
||||
<system:String x:Key="time">Time</system:String>
|
||||
<system:String x:Key="date">Date</system:String>
|
||||
<system:String x:Key="cpuUsage">CPU Usage</system:String>
|
||||
@@ -34,6 +34,9 @@
|
||||
<system:String x:Key="amplifier">Signal Amplification:</system:String>
|
||||
<system:String x:Key="newLayout">New Layout</system:String>
|
||||
<system:String x:Key="deleteLayout">Delete Layout</system:String>
|
||||
<system:String x:Key="newTheme">New Theme</system:String>
|
||||
<system:String x:Key="deleteTheme">Delete Theme</system:String>
|
||||
<system:String x:Key="changeTheme">Change Theme</system:String>
|
||||
<system:String x:Key="ok">Ok</system:String>
|
||||
<system:String x:Key="cancel">Cancel</system:String>
|
||||
<system:String x:Key="enterLayoutName">Enter layout name</system:String>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using DesktopMagic.Plugins;
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -11,8 +13,19 @@ internal class DesktopMagicSettings : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private ObservableCollection<Layout> layouts = [];
|
||||
private ObservableCollection<Theme> themes = [];
|
||||
private string? currentLayoutName;
|
||||
|
||||
public ObservableCollection<Theme> Themes
|
||||
{
|
||||
get => themes;
|
||||
set
|
||||
{
|
||||
themes = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Layout> Layouts
|
||||
{
|
||||
get => layouts;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using DesktopMagic.Plugins;
|
||||
using DesktopMagic.DataContexts;
|
||||
using DesktopMagic.Plugins;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DesktopMagic.Settings;
|
||||
|
||||
@@ -12,16 +14,30 @@ internal class Layout(string name) : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private string name = name;
|
||||
private Theme theme = new Theme();
|
||||
private string? currentThemeName = null;
|
||||
private Dictionary<uint, PluginSettings> plugins = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public Theme Theme
|
||||
{
|
||||
get => theme;
|
||||
get
|
||||
{
|
||||
DesktopMagicSettings settings = MainWindowDataContext.GetSettings();
|
||||
return settings.Themes.FirstOrDefault(theme => theme.Name == currentThemeName) ?? settings.Themes.FirstOrDefault() ?? new Theme("ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
public string? CurrentThemeName
|
||||
{
|
||||
get => currentThemeName;
|
||||
set
|
||||
{
|
||||
theme = value;
|
||||
OnPropertyChanged();
|
||||
if (currentThemeName != value)
|
||||
{
|
||||
currentThemeName = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(Theme));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +63,8 @@ internal class Layout(string name) : INotifyPropertyChanged
|
||||
|
||||
public void UpdatePlugins()
|
||||
{
|
||||
Plugins = Plugins.ToDictionary();
|
||||
plugins = plugins.ToDictionary();
|
||||
OnPropertyChanged(nameof(Plugins));
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
|
||||
@@ -3,6 +3,7 @@ using DesktopMagic.Plugins;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows;
|
||||
@@ -13,19 +14,40 @@ public class PluginSettings : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private readonly Theme? theme;
|
||||
private string? currentThemeName;
|
||||
private List<SettingElement> settings = [];
|
||||
private bool enabled = false;
|
||||
private Point position = new Point(100, 100);
|
||||
private Point size = new Point(300, 300);
|
||||
|
||||
[JsonIgnore]
|
||||
public Theme Theme => theme is null ? MainWindowDataContext.GetSettings().CurrentLayout.Theme : theme;
|
||||
|
||||
// Only for internal use to show the name of the plugin in the main window
|
||||
[JsonIgnore]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public Theme Theme
|
||||
{
|
||||
get
|
||||
{
|
||||
DesktopMagicSettings settings = MainWindowDataContext.GetSettings();
|
||||
return settings.Themes.FirstOrDefault(t => t.Name == currentThemeName) ?? settings.CurrentLayout.Theme;
|
||||
}
|
||||
}
|
||||
|
||||
public string? CurrentThemeName
|
||||
{
|
||||
get => currentThemeName;
|
||||
set
|
||||
{
|
||||
if (currentThemeName != value)
|
||||
{
|
||||
currentThemeName = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(Theme));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<SettingElement> Settings
|
||||
{
|
||||
get => settings;
|
||||
|
||||
Reference in New Issue
Block a user