Skip to content

Commit

Permalink
Add ConfigureTintColor for VSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Dec 6, 2024
1 parent 5c4a909 commit 0eae6d7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,6 @@ public async void RunStarted(object automationObject, Dictionary<string, string>

WizardConfig.LibraryDic?.Clear();
WizardConfig.CSProjectElements?.Clear();

//if (UseSettingsPage && UseThemeSettingPage)
//{
// replacementsDictionary.Add("$BackdropTintColorViewModel$", Environment.NewLine + "themeService.ConfigBackdropTintColor();");
// replacementsDictionary.Add("$BackdropTintColor$", Environment.NewLine + "ThemeService.ConfigBackdropTintColor();");
//}
//else
//{
// replacementsDictionary.Add("$BackdropTintColorViewModel$", "");
// replacementsDictionary.Add("$BackdropTintColor$", "");
//}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ private static IServiceProvider ConfigureServices()

if (GetThemeService != null)
{
GetThemeService.AutoInitialize(MainWindow);
GetThemeService.AutoInitialize(MainWindow)
.ConfigureTintColor();
}$Windows11ContextMenuMVVMInitializer$

rootFrame.Navigate(typeof(MainPage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,48 @@
HeaderIcon="{dev:BitmapIcon Source=Assets/Fluent/Color.png}"
IsClickEnabled="True"
LaunchUri="ms-settings:colors" />
<dev:SettingsExpander Description="Add tint to your window to make your experience more personalized."
Header="Tint Color"
HeaderIcon="{dev:BitmapIcon Source=Assets/Fluent/Tint.png}">
<Button Padding="0">
<StackPanel Orientation="Horizontal">
<Border Width="24"
Height="24"
Margin="4"
Background="Gray"
CornerRadius="4">
<Grid>
<PathIcon Data="M0 6 L0 0 L6 0 L6 6 L12 6 L12 0 L18 0 L18 6 L12 6 L12 12 L18 12 L18 6 L24 6 L24 12 L18 12 L18 18 L24 18 L24 24 L6 24 L6 18 L0 18 L0 12 L6 12 L6 18 L12 18 L12 24 L18 24 L18 18 L12 18 L12 12 L6 12 L6 6 Z"
Foreground="LightGray" />
<Rectangle x:Name="TintBox" />
</Grid>
</Border>
<FontIcon Margin="8,4,10,4"
FontSize="12"
Glyph="&#xE70D;" />
</StackPanel>
<Button.Flyout>
<Flyout>
<ColorPicker ColorChanged="OnColorChanged"
IsAlphaEnabled="True"
IsMoreButtonVisible="True" />
</Flyout>
</Button.Flyout>
</Button>
<dev:SettingsExpander.ItemsHeader>
<dev:SettingsCard>
<dev:SettingsCard.Description>
<dev:ColorPalette Margin="5,5,0,0"
HorizontalAlignment="Left"
ItemClick="OnColorPaletteItemClick"
ItemWidth="32"
Palette="Rectangle"
ShowHeader="False"
Color="NormalLarge" />
</dev:SettingsCard.Description>
</dev:SettingsCard>
</dev:SettingsExpander.ItemsHeader>
</dev:SettingsExpander>
</StackPanel>
</ScrollView>
</Page>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
namespace $safeprojectname$.Views;
using Microsoft.UI.Xaml.Media;

namespace $safeprojectname$.Views;

public sealed partial class ThemeSettingPage : Page
{
public ThemeSettingPage()
{
this.InitializeComponent();
}

private void OnColorChanged(ColorPicker sender, ColorChangedEventArgs args)
{
TintBox.Fill = new SolidColorBrush(args.NewColor);
App.Current.GetThemeService.SetBackdropTintColor(args.NewColor);
}

private void OnColorPaletteItemClick(object sender, ItemClickEventArgs e)
{
var color = e.ClickedItem as ColorPaletteItem;
if (color != null)
{
if (color.Hex.Contains("#000000"))
{
App.Current.GetThemeService.ResetBackdropProperties();
}
else
{
App.Current.GetThemeService.SetBackdropTintColor(color.Color);
}
TintBox.Fill = new SolidColorBrush(color.Color);
}
}
}


0 comments on commit 0eae6d7

Please sign in to comment.