Skip to content

Commit

Permalink
.net upgrade and darkmode
Browse files Browse the repository at this point in the history
Upgrades to .net 4.8.1 due to 4.7.2 no longer being supported
Updated theming to use Fluent design (from Wpf-Ui by wpfui.lepo.co) with dark mode and live theme switching
  • Loading branch information
ell1010 committed Feb 2, 2025
1 parent 71f0565 commit 3cdc82e
Show file tree
Hide file tree
Showing 18 changed files with 833 additions and 502 deletions.
3 changes: 2 additions & 1 deletion src/installer/installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef CONFIG
# define CONFIG GetEnv('CONFIG')
#endif
#define FRAMEWORK "net472"
#define FRAMEWORK "net481"

#define SRCDIR "../wincompose"
#define BINDIR "../wincompose/bin/" + CONFIG + "/" + FRAMEWORK
Expand Down Expand Up @@ -58,6 +58,7 @@ Source: "{#BINDIR}\{#EXE}.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\language.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\Emoji.Wpf.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\Hardcodet.NotifyIcon.Wpf.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\Wpf.Ui.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\NLog.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\System.ValueTuple.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BINDIR}\stfu.dll"; DestDir: "{app}"; Flags: ignoreversion
Expand Down
12 changes: 6 additions & 6 deletions src/installer/installer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ procedure visit_homepage(sender: tobject);
end;

{
{ Download .NET Framework 3.5 SP1
{ Download .NET Framework 4.8.1
}
procedure download_dotnet(sender: tobject);
var
ret: integer;
begin
shellexec('open', 'https://dotnet.microsoft.com/download/dotnet-framework/net40',
shellexec('open', 'https://dotnet.microsoft.com/en-us/download/dotnet-framework/net481',
'', '', sw_show, ewnowait, ret);
end;

Expand Down Expand Up @@ -176,12 +176,12 @@ procedure InitializeWizard;
_('Software required by WinCompose'));

warning := tnewstatictext.create(dotnet_page);
warning.caption := _('WinCompose needs the .NET Framework, version 4.0 or later, which does not\n'
warning.caption := _('WinCompose needs the .NET Framework, version 4.8.1 or later, which does not\n'
+ 'seem to be currently installed. The following action may help solve the problem:');
warning.parent := dotnet_page.surface;

action := tnewstatictext.create(dotnet_page);
action.caption := _('Download and install .NET Framework 4.0 Runtime');
action.caption := _('Download and install .NET Framework 4.8.1 Runtime');
action.parent := dotnet_page.surface;
action.cursor := crhand;
action.onclick := @download_dotnet;
Expand Down Expand Up @@ -220,7 +220,7 @@ procedure refresh_dotnet_page(sender: tobject; var key: word; shift: tshiftstate
begin
if wizardform.curpageid = dotnet_page.id then
begin
if (get_dotnet_state() < 0) then begin
if not IsDotNetInstalled(net462, 0) then begin
wizardform.nextbutton.enabled := false;
action.visible := true;
hint.visible := true;
Expand Down Expand Up @@ -264,7 +264,7 @@ function ShouldSkipPage(page_id: integer): boolean;
{ If this is the .NET page, only show it on run 1 and if the
{ prerequisites are not yet installed. }
if page_id = dotnet_page.id then begin
result := (state <> s_run_1) or (get_dotnet_state() = 0);
result := (state <> s_run_1) or (IsDotNetInstalled(net462, 0));
exit;
end;

Expand Down
12 changes: 11 additions & 1 deletion src/wincompose/Application.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wc="clr-namespace:WinCompose"
DispatcherUnhandledException="OnUnhandledException"
mc:Ignorable="d">
mc:Ignorable="d"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
<Application.MainWindow>
<wc:RemoteControl x:Name="RC">
<wc:NotificationIcon/>
</wc:RemoteControl>
</Application.MainWindow>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary/>
<ui:ControlsDictionary/>
<ResourceDictionary Source="StyleOverrides.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
1 change: 1 addition & 0 deletions src/wincompose/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Application()
try
{
InitializeComponent();
Settings.SetTheme();
}
catch (Exception ex)
{
Expand Down
245 changes: 245 additions & 0 deletions src/wincompose/StyleOverrides.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style TargetType="{x:Type TabControl}">
<Setter Property="Foreground" Value="{DynamicResource TabViewForeground}" />
<Setter Property="Background" Value="{DynamicResource TabViewBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TabViewBorderBrush}" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TabPanel
x:Name="HeaderPanel"
Grid.Row="0"
Margin="0"
Panel.ZIndex="1"
Background="Transparent"
IsItemsHost="True"
KeyboardNavigation.TabIndex="1" />
<Border
x:Name="Border"
Grid.Row="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0,1,0,0"
CornerRadius="0,4,4,4"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2"
KeyboardNavigation.TabNavigation="Local">
<ContentPresenter
x:Name="PART_SelectedContentHost"
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ContentSource="SelectedContent"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type TabItem}">
<Setter Property="Background" Value="{DynamicResource TabViewItemHeaderBackground}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" />
<Setter Property="Focusable" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid x:Name="Root">
<Border
x:Name="Border"
MinHeight="{TemplateBinding MinHeight}"
MinWidth="{TemplateBinding MaxWidth}"
Margin="0"
Padding="6"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1,1,1,0"
CornerRadius="8,8,0,0">
<ContentPresenter
x:Name="ContentSite"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True" />
</Border>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected" />

</VisualStateGroup>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Opacity)"
From="0.0"
To="0.5"
Duration="0:0:.16" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource TabViewItemHeaderBackgroundSelected}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource TabViewSelectedItemBorderBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TabViewItemForegroundSelected}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="DefaultListBoxStyle" TargetType="{x:Type ListBox}">
<Setter Property="Background" Value="{DynamicResource ListBoxBackground}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Standard" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsVirtualizing="{TemplateBinding VirtualizingPanel.IsVirtualizing}" VirtualizationMode="{TemplateBinding VirtualizingPanel.VirtualizationMode}" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer
x:Name="PART_ContentHost"
Padding="{TemplateBinding Padding}"
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsGrouping" Value="True">
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style BasedOn="{StaticResource DefaultListBoxStyle}" TargetType="{x:Type ListBox}" />

<SolidColorBrush x:Key="GroupBox.Border" Color="LightGray" />

<BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>

<Style x:Key="{x:Type GroupBox}" TargetType="{x:Type GroupBox}">
<Setter Property="BorderBrush" Value="{StaticResource GroupBox.Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupBox}">
<Grid SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="6"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="6"/>
</Grid.RowDefinitions>
<!-- Separate Border for the background because if the background is set in the Border with the Header the opacity mask will be applied to the background as well. -->
<Border Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="0"
Grid.ColumnSpan="4"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="Transparent"
Background="{TemplateBinding Background}"/>

<Border Grid.Row="1"
Grid.RowSpan="3"
Grid.ColumnSpan="4"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<Border.OpacityMask>
<MultiBinding Converter="{StaticResource BorderGapMaskConverter}"
ConverterParameter="7">
<Binding ElementName="Header"
Path="ActualWidth"/>
<Binding RelativeSource="{RelativeSource Self}"
Path="ActualWidth"/>
<Binding RelativeSource="{RelativeSource Self}"
Path="ActualHeight"/>
</MultiBinding>
</Border.OpacityMask>
</Border>

<!-- ContentPresenter for the header -->
<Border x:Name="Header"
Padding="3,0,3,0"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1">
<ContentPresenter ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<!-- Primary content for GroupBox -->
<ContentPresenter Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
Loading

0 comments on commit 3cdc82e

Please sign in to comment.