Fix theme not resetting properly
Change button foreground color
This commit is contained in:
parent
9c82d34ba4
commit
81e9ab7fb2
@ -80,6 +80,9 @@
|
|||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Button">
|
<Style Selector="Button">
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Style Selector="^">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource SystemChromeAltLowColor}" />
|
||||||
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ScrollBar">
|
<Style Selector="ScrollBar">
|
||||||
<!-- It's called AutoHide, but this is really the mouseover shrink/expand. -->
|
<!-- It's called AutoHide, but this is really the mouseover shrink/expand. -->
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
{
|
{
|
||||||
protected DataGridCollectionView ThemeColors { get; }
|
protected DataGridCollectionView ThemeColors { get; }
|
||||||
private ChardonnayTheme ExistingTheme { get; } = ChardonnayTheme.GetLiveTheme();
|
private ChardonnayTheme ExistingTheme { get; } = ChardonnayTheme.GetLiveTheme();
|
||||||
private ChardonnayTheme WorkingTheme { get; }
|
private ChardonnayTheme WorkingTheme { get; set; }
|
||||||
|
|
||||||
public ThemePickerDialog()
|
public ThemePickerDialog()
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
|
|
||||||
using (var theme = new ChardonnayThemePersister(selectedFile))
|
using (var theme = new ChardonnayThemePersister(selectedFile))
|
||||||
{
|
{
|
||||||
theme.Target.ApplyTheme(ActualThemeVariant);
|
ResetTheme(theme.Target);
|
||||||
}
|
}
|
||||||
|
|
||||||
await MessageBox.Show(this, "Theme imported and applied", "Theme Imported");
|
await MessageBox.Show(this, "Theme imported and applied", "Theme Imported");
|
||||||
@ -147,13 +147,14 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
|
|
||||||
private void ResetTheme(ChardonnayTheme theme)
|
private void ResetTheme(ChardonnayTheme theme)
|
||||||
{
|
{
|
||||||
theme.ApplyTheme(ActualThemeVariant);
|
WorkingTheme = (ChardonnayTheme)theme.Clone();
|
||||||
|
WorkingTheme.ApplyTheme(ActualThemeVariant);
|
||||||
|
|
||||||
foreach (var i in ThemeColors.OfType<ThemeItemColor>())
|
foreach (var i in ThemeColors.OfType<ThemeItemColor>())
|
||||||
{
|
{
|
||||||
i.SuppressSet = true;
|
i.ColorSetter = null;
|
||||||
i.ThemeColor = theme.GetColor(ActualThemeVariant, i.ThemeItemName);
|
i.ThemeColor = WorkingTheme.GetColor(ActualThemeVariant, i.ThemeItemName);
|
||||||
i.SuppressSet = false;
|
i.ColorSetter = ColorSetter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,18 +165,19 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
{
|
{
|
||||||
ThemeItemName = kvp.Key,
|
ThemeItemName = kvp.Key,
|
||||||
ThemeColor = kvp.Value,
|
ThemeColor = kvp.Value,
|
||||||
ColorSetter = c =>
|
ColorSetter = ColorSetter
|
||||||
{
|
|
||||||
WorkingTheme.SetColor(ActualThemeVariant, kvp.Key, c);
|
|
||||||
WorkingTheme.ApplyTheme(ActualThemeVariant);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private void ColorSetter(Color color, string colorName)
|
||||||
|
{
|
||||||
|
WorkingTheme.SetColor(ActualThemeVariant, colorName, color);
|
||||||
|
WorkingTheme.ApplyTheme(ActualThemeVariant);
|
||||||
|
}
|
||||||
|
|
||||||
private class ThemeItemColor : ViewModels.ViewModelBase
|
private class ThemeItemColor : ViewModels.ViewModelBase
|
||||||
{
|
{
|
||||||
public bool SuppressSet { get; set; }
|
|
||||||
public required string ThemeItemName { get; init; }
|
public required string ThemeItemName { get; init; }
|
||||||
public required Action<Color> ColorSetter { get; init; }
|
public required Action<Color, string>? ColorSetter { get; set; }
|
||||||
|
|
||||||
private Color _themeColor;
|
private Color _themeColor;
|
||||||
public Color ThemeColor
|
public Color ThemeColor
|
||||||
@ -183,10 +185,10 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
get => _themeColor;
|
get => _themeColor;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var setColors = !SuppressSet && !_themeColor.Equals(value);
|
var setColors = !_themeColor.Equals(value);
|
||||||
this.RaiseAndSetIfChanged(ref _themeColor, value);
|
this.RaiseAndSetIfChanged(ref _themeColor, value);
|
||||||
if (setColors)
|
if (setColors)
|
||||||
ColorSetter?.Invoke(_themeColor);
|
ColorSetter?.Invoke(_themeColor, ThemeItemName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user