Skip to content

Commit

Permalink
Removed MetroWindow, added theming support and modernWPF
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels Laute authored and yuyoyuppe committed Nov 20, 2020
1 parent 9c5f142 commit 22957c4
Show file tree
Hide file tree
Showing 15 changed files with 417 additions and 21 deletions.
8 changes: 3 additions & 5 deletions src/modules/fancyzones/editor/FancyZonesEditor/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FancyZonesEditor"
xmlns:ui="http://schemas.modernwpf.com/2019"
Startup="OnStartup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ui:ThemeResources />
<ui:XamlControlsResources />
</ResourceDictionary.MergedDictionaries>

<SolidColorBrush x:Key="CanvasZoneBackgroundBrush" Color="#BF333333"/>
Expand Down
4 changes: 4 additions & 0 deletions src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public partial class App : Application

public static int PowerToysPID { get; set; }

private ThemeManager _themeManager;

public static bool DebugMode
{
get
Expand Down Expand Up @@ -82,6 +84,8 @@ private void OnStartup(object sender, StartupEventArgs e)
Environment.Exit(0);
});

_themeManager = new ThemeManager(this);

FancyZonesEditorIO.ParseCommandLineArguments();
FancyZonesEditorIO.ParseDeviceInfoData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using System;
using System.Windows;
using FancyZonesEditor.Models;
using MahApps.Metro.Controls;

namespace FancyZonesEditor
{
public class EditorWindow : MetroWindow
public class EditorWindow : Window
{
protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<DependentUpon>GridEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SplitEventArgs.cs" />
<Compile Include="Utils\CustomLibraryThemeProvider.cs" />
<Compile Include="Utils\FancyZonesEditorIO.cs" />
<Compile Include="Utils\EventArgs`1.cs" />
<Compile Include="Utils\EventRaiser.cs" />
Expand All @@ -166,6 +167,7 @@
<Compile Include="Utils\RelayCommand.cs" />
<Compile Include="Utils\RelayCommand`1.cs" />
<Compile Include="Models\Device.cs" />
<Compile Include="Utils\ThemeManager.cs" />
<Compile Include="ViewModels\MonitorViewModel.cs" />
<Compile Include="WindowLayout.xaml.cs">
<DependentUpon>WindowLayout.xaml</DependentUpon>
Expand Down Expand Up @@ -215,6 +217,30 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Dark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\HighContrast1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\HighContrast2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\HighContrastBlack.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\HighContrastWhite.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Light.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WindowLayout.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -264,8 +290,11 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MahApps.Metro">
<Version>2.3.2</Version>
<PackageReference Include="ControlzEx">
<Version>4.4.0</Version>
</PackageReference>
<PackageReference Include="ModernWpfUI">
<Version>0.9.2</Version>
</PackageReference>
<PackageReference Include="System.IO.Abstractions">
<Version>12.2.5</Version>
Expand Down
10 changes: 5 additions & 5 deletions src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Controls:MetroWindow x:Class="FancyZonesEditor.MainWindow"
<Window x:Class="FancyZonesEditor.MainWindow"
x:Name="MainWindow1"
AutomationProperties.Name="{x:Static props:Resources.Fancy_Zones_Main_Editor}"
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:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:local="clr-namespace:FancyZonesEditor"
xmlns:Converters="clr-namespace:FancyZonesEditor.Converters"
xmlns:props="clr-namespace:FancyZonesEditor.Properties" xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels"
mc:Ignorable="d"
xmlns:props="clr-namespace:FancyZonesEditor.Properties"
xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels"
mc:Ignorable="d"
Title=""
Width="810"
SizeToContent="Height"
Expand Down Expand Up @@ -462,4 +462,4 @@
</StackPanel>

</StackPanel>
</Controls:MetroWindow>
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
using System.Windows.Controls;
using System.Windows.Input;
using FancyZonesEditor.Models;
using MahApps.Metro.Controls;

namespace FancyZonesEditor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
public partial class MainWindow : Window
{
// TODO: share the constants b/w C# Editor and FancyZoneLib
public const int MaxZones = 40;
Expand Down
5 changes: 0 additions & 5 deletions src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ public void OpenEditor(LayoutModel model)
{
(window as GridEditorWindow).NameTextBox().Focus();
}

window.LeftWindowCommands = null;
window.RightWindowCommands = null;
}

public void CloseEditor()
Expand Down Expand Up @@ -318,8 +315,6 @@ private void OpenMainWindow()
_mainWindow.ShowActivated = true;
_mainWindow.Topmost = true;
_mainWindow.Show();
_mainWindow.LeftWindowCommands = null;
_mainWindow.RightWindowCommands = null;

// window is set to topmost to make sure it shows on top of PowerToys settings page
// we can reset topmost flag now
Expand Down
24 changes: 24 additions & 0 deletions src/modules/fancyzones/editor/FancyZonesEditor/Themes/Dark.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">Dark.Accent1</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent1 (Dark)</system:String>
<system:String x:Key="Theme.BaseColorScheme">Dark</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">Black</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FF535353"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF6b6b6b" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent2</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent2 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent2</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFffff00"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFffff00" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF00ff00" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent3</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent3 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent3</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FF00ff00"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>

<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF00ff00" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FFc0c0c0" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent4</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent4 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent4</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFffffff"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>

<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFffffff" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF1aebff" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent5</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent5 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent5</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FFededed" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FFe5e5e5" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="Black"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF949494"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#e9e9e9"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FFe5e5e5"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FFf9f9f9"/>

<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF000000" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF37006e" />
</ResourceDictionary>
25 changes: 25 additions & 0 deletions src/modules/fancyzones/editor/FancyZonesEditor/Themes/Light.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">

<!-- Metadata -->
<system:String x:Key="Theme.Name">Light.Accent1</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent1 (Light)</system:String>
<system:String x:Key="Theme.BaseColorScheme">Light</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>

<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FFededed" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FFe5e5e5" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFf7f7f7"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF949494"/>

<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#e9e9e9"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FFe5e5e5"/>

<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FFf9f9f9"/>

<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF000000" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF949494" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using ControlzEx.Theming;

namespace FancyZonesEditor.Utils
{
public class CustomLibraryThemeProvider : LibraryThemeProvider
{
public static readonly CustomLibraryThemeProvider DefaultInstance = new CustomLibraryThemeProvider();

public CustomLibraryThemeProvider()
: base(true)
{
}

/// <inheritdoc />
public override void FillColorSchemeValues(Dictionary<string, string> values, RuntimeThemeColorValues colorValues)
{
}
}
}
Loading

0 comments on commit 22957c4

Please sign in to comment.