Skip to content

Commit c524c1b

Browse files
committed
1.4.0
UI overhaul Toggle HDR manually HDR status Stability improvements Code cleanup
1 parent 7af7512 commit c524c1b

22 files changed

+497
-147
lines changed
42.5 KB
Loading

Photoshop/Logo.ico

124 KB
Binary file not shown.

Photoshop/Logo.png

79.8 KB
Loading

Photoshop/Logo.psd

-102 KB
Binary file not shown.

Photoshop/Logo_256.png

15 KB
Loading

Source/HDRProfile/App.xaml

Lines changed: 121 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:HDRProfile"
55
xmlns:tb="http://www.hardcodet.net/taskbar"
6+
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
67
xmlns:system="clr-namespace:System;assembly=mscorlib"
78
xmlns:corewpf="clr-namespace:CodectoryCore.UI.Wpf;assembly=CodectoryCore.UI.Wpf"
89
Exit="Application_Exit"
@@ -12,11 +13,127 @@
1213

1314
<system:String x:Key="DonateLink">https://paypal.me/pools/c/8vksshrMln</system:String>
1415
<system:String x:Key="InfoLink">https://sourceforge.net/projects/hdr-profile</system:String>
15-
<system:String x:Key="Version">1.3.4</system:String>
16-
<SolidColorBrush x:Key="ButtonBackground" Color="#FF0086F5"/>
17-
<SolidColorBrush x:Key="AccentColor" Color="#FFFF581A"/>
18-
<SolidColorBrush x:Key="AccentColor2" Color="#4C87B3"/>
16+
<Color x:Key="AccentColor">#5d9ac7</Color>
17+
<Color x:Key="HighlightedColor">#6fb3e3</Color>
18+
<Color x:Key="ButtonClickedColor">#396585</Color>
19+
<SolidColorBrush x:Key="ButtonForegroundBrush">White</SolidColorBrush>
20+
21+
22+
<SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}"/>
23+
<SolidColorBrush x:Key="InactiveAccentBrush">#7292a8</SolidColorBrush>
24+
<SolidColorBrush x:Key="DisabledAccentBrush">#949ea6</SolidColorBrush>
25+
<SolidColorBrush x:Key="HighlightedInactiveAccentBrush" Color="#95bfdb"/>
26+
<StaticResource x:Key="ButtonBackgroundBrush" ResourceKey="AccentBrush"/>
1927
<CornerRadius x:Key="CornerRadius">3</CornerRadius>
28+
29+
<Style TargetType="TextBlock" >
30+
<Setter Property="Foreground" Value="Black"/>
31+
</Style>
32+
33+
34+
35+
36+
<Style x:Key="DefaultButton" TargetType="Button" >
37+
<Setter Property="Background" Value="{StaticResource AccentBrush}"/>
38+
<Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
39+
<Setter Property="Height" Value="25"/>
40+
<Setter Property="Template">
41+
<Setter.Value>
42+
<ControlTemplate TargetType="Button">
43+
<Border Height="Auto" Width="Auto" BorderBrush="{TemplateBinding Background}" Background="{TemplateBinding Background}" BorderThickness="1" CornerRadius="{StaticResource CornerRadius}">
44+
<TextBlock Background="Transparent" Padding="5,4,5,5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
45+
</Border>
46+
</ControlTemplate>
47+
</Setter.Value>
48+
</Setter>
49+
<Setter Property="Padding" Value="5,5"/>
50+
<Style.Triggers>
51+
<Trigger Property="IsEnabled" Value="false">
52+
<Setter Property="Background" Value="{StaticResource DisabledAccentBrush}"/>
53+
<Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
54+
</Trigger>
55+
<Trigger Property="IsMouseOver" Value="true">
56+
<Trigger.EnterActions>
57+
<BeginStoryboard>
58+
<Storyboard>
59+
<ColorAnimation To="{StaticResource HighlightedColor}"
60+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
61+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
62+
</Storyboard>
63+
</BeginStoryboard>
64+
</Trigger.EnterActions>
65+
66+
<Trigger.ExitActions>
67+
<BeginStoryboard>
68+
<Storyboard>
69+
<ColorAnimation
70+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
71+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
72+
</Storyboard>
73+
</BeginStoryboard>
74+
</Trigger.ExitActions>
75+
76+
</Trigger>
77+
78+
<Trigger Property="IsPressed" Value="true">
79+
<Trigger.EnterActions>
80+
<BeginStoryboard>
81+
<Storyboard>
82+
<ColorAnimation To="{StaticResource ButtonClickedColor}"
83+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
84+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
85+
</Storyboard>
86+
</BeginStoryboard>
87+
</Trigger.EnterActions>
88+
89+
<Trigger.ExitActions>
90+
<BeginStoryboard>
91+
<Storyboard>
92+
<ColorAnimation
93+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
94+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
95+
</Storyboard>
96+
</BeginStoryboard>
97+
</Trigger.ExitActions>
98+
99+
</Trigger>
100+
101+
102+
</Style.Triggers>
103+
</Style>
104+
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}"/>
105+
106+
<Style x:Key="DefaultTabItem" TargetType="TabItem">
107+
<Setter Property="Background" Value="{StaticResource AccentBrush}"/>
108+
<Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
109+
<Setter Property="Template">
110+
<Setter.Value>
111+
<ControlTemplate TargetType="TabItem">
112+
<Border Height="Auto" Width="Auto" BorderBrush="{StaticResource AccentBrush}" Background="{TemplateBinding Background}" BorderThickness="1 1 1 0" CornerRadius="3 3 0 0">
113+
<TextBlock Padding="5,5,5,5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Header}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
114+
</Border>
115+
</ControlTemplate>
116+
</Setter.Value>
117+
</Setter>
118+
<Style.Triggers>
119+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" >
120+
<Setter Property="Background" Value="{StaticResource AccentBrush}"/>
121+
<Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
122+
<Setter Property="BorderThickness" Value="0.8 1 1 1"/>
123+
124+
</DataTrigger>
125+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False" >
126+
<Setter Property="Background" Value="White"/>
127+
<Setter Property="Foreground" Value="Black"/>
128+
<Setter Property="BorderThickness" Value="0"/>
129+
130+
</DataTrigger>
131+
</Style.Triggers>
132+
133+
</Style>
134+
<Style TargetType="TabItem" BasedOn="{StaticResource DefaultTabItem}"/>
135+
136+
20137
<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
21138
<corewpf:DialogService x:Key="DialogService" />
22139
<corewpf:BitmapToBitmapImageConverter x:Key="BitmapToBitmapImageConverter"/>

Source/HDRProfile/HDRMode.cs renamed to Source/HDRProfile/HDRActivationMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace HDRProfile
88
{
9-
public enum HDRMode
9+
public enum HDRActivationMode
1010
{
1111
None,
1212
Running,

Source/HDRProfile/HDRController.cs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,73 @@
1010

1111
namespace HDRProfile
1212
{
13-
public static class HDRController
13+
public static class HDRController
1414
{
15+
16+
static Thread _updateThread = null;
17+
static readonly object _threadControlLock = new object();
18+
static bool _monitorCancelRequested = false;
19+
20+
readonly static object _dllLock = new object();
21+
1522
[DllImport("HDRController.dll", CallingConvention = CallingConvention.Cdecl)]
1623
private static extern IntPtr SetHDRState(bool enabled);
1724

1825
[DllImport("HDRController.dll", CallingConvention = CallingConvention.Cdecl)]
1926
private static extern bool GetHDRState();
2027

21-
readonly static object _dllLock = new object();
2228

23-
public static bool HDRIsActive()
29+
public static bool HDRIsActive { get; private set; } = false;
30+
public static bool Monitoring { get; private set; } = false;
31+
32+
public static event EventHandler HDRIsActiveChanged;
33+
34+
public static void StartMonitoring()
2435
{
25-
return GetHDRState();
36+
lock (_threadControlLock)
37+
{
38+
if (Monitoring)
39+
return;
40+
_updateThread = new Thread(HDRMonitorLoop);
41+
_updateThread.IsBackground = true;
42+
Monitoring = true;
43+
_monitorCancelRequested = false;
44+
_updateThread.Start();
45+
}
46+
}
47+
48+
public static void StopMonitoring()
49+
{
50+
lock (_threadControlLock)
51+
{
52+
if (!Monitoring)
53+
return;
54+
_monitorCancelRequested = true;
55+
_updateThread.Join();
56+
_updateThread = null;
57+
Monitoring = false;
58+
}
59+
}
60+
61+
private static void HDRMonitorLoop()
62+
{
63+
while (!_monitorCancelRequested)
64+
{
65+
bool currentValue = GetHDRState();
66+
bool changed = HDRIsActive != currentValue;
67+
HDRIsActive = currentValue;
68+
if (changed)
69+
{
70+
try {HDRIsActiveChanged?.Invoke(null, EventArgs.Empty);} catch {}
71+
}
72+
System.Threading.Thread.Sleep(50);
73+
}
2674
}
2775

2876
public static void ActivateHDR()
2977
{
3078
lock (_dllLock)
3179
SetHDRState(true);
32-
3380
}
3481

3582
public static void DeactivateHDR()

Source/HDRProfile/HDRProfile.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<WarningLevel>4</WarningLevel>
5555
</PropertyGroup>
5656
<PropertyGroup>
57-
<ApplicationIcon>LogoBig.ico</ApplicationIcon>
57+
<ApplicationIcon>Logo.ico</ApplicationIcon>
5858
</PropertyGroup>
5959
<PropertyGroup>
6060
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -156,6 +156,7 @@
156156
<SubType>Designer</SubType>
157157
</ApplicationDefinition>
158158
<Compile Include="Tools.cs" />
159+
<Compile Include="TrayMenuHelper.cs" />
159160
<Page Include="HDRProfileSettingsView.xaml">
160161
<SubType>Designer</SubType>
161162
<Generator>MSBuild:Compile</Generator>
@@ -169,7 +170,7 @@
169170
<SubType>Code</SubType>
170171
</Compile>
171172
<Compile Include="EnumLocaleConverter.cs" />
172-
<Compile Include="HDRMode.cs" />
173+
<Compile Include="HDRActivationMode.cs" />
173174
<Compile Include="HDRProfileHandler.cs" />
174175
<Compile Include="HDRController.cs" />
175176
<Compile Include="HDRProfileSettings.cs" />
@@ -263,9 +264,6 @@
263264
<ItemGroup>
264265
<Resource Include="Logo.ico" />
265266
</ItemGroup>
266-
<ItemGroup>
267-
<Resource Include="LogoBig.ico" />
268-
</ItemGroup>
269267
<ItemGroup>
270268
<Resource Include="FodyWeavers.xml" />
271269
</ItemGroup>
@@ -280,6 +278,7 @@
280278
<EmbeddedResource Include="Costura32\HDRController.dll" />
281279
<Content Include="Externals\CodectoryCore.Logging.dll" />
282280
</ItemGroup>
281+
<ItemGroup />
283282
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
284283
<Import Project="..\packages\Fody.6.0.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.0\build\Fody.targets')" />
285284
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

0 commit comments

Comments
 (0)