Skip to content

Commit 811c23a

Browse files
committed
Finished profile implementation
finished profile implementation added resolution feature added refresh feature
1 parent f1cd1fa commit 811c23a

38 files changed

+1089
-251
lines changed

Source/Debug_Any/AutoHDR.exe

-21 KB
Binary file not shown.
512 Bytes
Binary file not shown.

Source/HDRController/HDRController/HDRController.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <winerror.h>
1111
#include <wingdi.h>
1212
#include <stdexcept>
13-
13+
#include <string>
1414

1515
#include <stdint.h>
1616
#include <cstdlib>
@@ -199,48 +199,6 @@ static void SetHDR(UINT32 uid, bool enabled)
199199
}
200200

201201

202-
static void _SetResolution(UINT32 uid, UINT32 width, UINT32 height)
203-
{
204-
uint32_t pathCount, modeCount;
205-
UINT32 numPathArrayElements = 0, numModeInfoArrayElements = 0;
206-
UINT32 filter = QDC_ALL_PATHS;
207-
if (ERROR_SUCCESS == GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount))
208-
{
209-
210-
const size_t sizePathsArray = pathCount * sizeof(DISPLAYCONFIG_PATH_INFO);
211-
const size_t sizeModesArray = modeCount * sizeof(DISPLAYCONFIG_MODE_INFO);
212-
213-
214-
DISPLAYCONFIG_PATH_INFO* pathsArray = new DISPLAYCONFIG_PATH_INFO[pathCount];
215-
DISPLAYCONFIG_MODE_INFO* modesArray = new DISPLAYCONFIG_MODE_INFO[modeCount];
216-
217-
218-
ZeroMemory(pathsArray, sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount);
219-
ZeroMemory(modesArray, sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount);
220-
QueryDisplayConfig(filter, &pathCount, pathsArray, &modeCount, modesArray, NULL);
221-
222-
223-
for (short i = 0; i < pathCount; i++)
224-
{
225-
try
226-
{
227-
int ix = pathsArray[i].sourceInfo.modeInfoIdx; //assuming path[0] is primary
228-
229-
if (modesArray[ix].id != uid)
230-
231-
{
232-
modesArray[ix].sourceMode.width = width;
233-
modesArray[ix].sourceMode.height = height;
234-
SetDisplayConfig(pathCount, pathsArray, modeCount, modesArray, SDC_APPLY | SDC_USE_SUPPLIED_DISPLAY_CONFIG | SDC_ALLOW_CHANGES | SDC_SAVE_TO_DATABASE);
235-
}
236-
}
237-
catch (const std::exception&)
238-
{
239-
240-
}
241-
}
242-
}
243-
}
244202

245203
static SIZE _GetResolution(UINT32 uid)
246204
{
@@ -464,11 +422,6 @@ extern "C"
464422
return HDRIsOn(uid);
465423
}
466424

467-
__declspec(dllexport) void SetResolution(UINT32 uid, UINT32 width, UINT32 height)
468-
{
469-
_SetResolution(uid, width, height);
470-
}
471-
472425
__declspec(dllexport) SIZE GetResolution(UINT32 uid)
473426
{
474427
return _GetResolution(uid);

Source/HDRProfile/App.xaml

Lines changed: 130 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110

111111
<SolidColorBrush x:Key="ActiveBrush" Color="{StaticResource ActiveColor}"/>
112112
<SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}"/>
113+
<SolidColorBrush x:Key="HighlightedBrush" Color="{StaticResource SelectedBackgroundColor}"/>
114+
<SolidColorBrush x:Key="MouseOverBrush" Color="{StaticResource ControlMouseOverColor}"/>
115+
116+
113117
<SolidColorBrush x:Key="InactiveAccentBrush">#ad7b7b</SolidColorBrush>
114118
<SolidColorBrush x:Key="DisabledAccentBrush">#949ea6</SolidColorBrush>
115119
<SolidColorBrush x:Key="HighlightedInactiveAccentBrush" Color="#95bfdb"/>
@@ -137,6 +141,50 @@
137141
</Style.Triggers>
138142
</Style>
139143

144+
<Style x:Key="DefaultTextBox" TargetType="TextBox" >
145+
<Setter Property="BorderThickness" Value="0"/>
146+
<Setter Property="Template">
147+
<Setter.Value>
148+
<ControlTemplate TargetType="TextBoxBase">
149+
<Border Height="Auto" Width="Auto" BorderBrush="{StaticResource AccentBrush}" Background="{TemplateBinding Background}" BorderThickness="1" CornerRadius="{StaticResource CornerRadius}">
150+
<ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
151+
</Border>
152+
</ControlTemplate>
153+
</Setter.Value>
154+
</Setter>
155+
<Setter Property="Padding" Value="5,5"/>
156+
<Style.Triggers>
157+
<Trigger Property="IsEnabled" Value="false">
158+
<Setter Property="Background" Value="{StaticResource DisabledAccentBrush}"/>
159+
<Setter Property="Foreground" Value="{StaticResource ButtonForegroundBrush}"/>
160+
</Trigger>
161+
<Trigger Property="IsMouseOver" Value="true">
162+
<Trigger.EnterActions>
163+
<BeginStoryboard>
164+
<Storyboard>
165+
<ColorAnimation To="{StaticResource ControlMouseOverColor}"
166+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
167+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
168+
</Storyboard>
169+
</BeginStoryboard>
170+
</Trigger.EnterActions>
171+
172+
<Trigger.ExitActions>
173+
<BeginStoryboard>
174+
<Storyboard>
175+
<ColorAnimation
176+
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
177+
FillBehavior="HoldEnd" Duration="0:0:0.10" AutoReverse="False" RepeatBehavior="1x"/>
178+
</Storyboard>
179+
</BeginStoryboard>
180+
</Trigger.ExitActions>
181+
182+
</Trigger>
183+
184+
</Style.Triggers>
185+
</Style>
186+
<Style TargetType="TextBox" BasedOn="{StaticResource DefaultTextBox}"/>
187+
140188

141189
<Style x:Key="DefaultButton" TargetType="Button" >
142190
<Setter Property="Background" Value="{StaticResource AccentBrush}"/>
@@ -366,7 +414,7 @@
366414
</VisualStateManager.VisualStateGroups>
367415
<Border x:Name="Border"
368416
Grid.ColumnSpan="2"
369-
CornerRadius="2"
417+
CornerRadius="{StaticResource CornerRadius}"
370418
BorderThickness="1">
371419
<Border.BorderBrush>
372420
<SolidColorBrush Color="{StaticResource AccentColor}"/>
@@ -400,7 +448,7 @@
400448
TargetType="{x:Type TextBox}">
401449
<Border x:Name="PART_ContentHost"
402450
Focusable="False"
403-
Background="{TemplateBinding Background}" />
451+
Background="{TemplateBinding Background}" />
404452
</ControlTemplate>
405453

406454
<Style x:Key="DefaultComboBox"
@@ -419,6 +467,8 @@
419467
Value="120" />
420468
<Setter Property="MinHeight"
421469
Value="20" />
470+
471+
422472
<Setter Property="Template">
423473
<Setter.Value>
424474
<ControlTemplate TargetType="{x:Type ComboBox}">
@@ -481,7 +531,6 @@
481531
Margin="3,3,23,3"
482532
Focusable="True"
483533
Background="Transparent"
484-
Visibility="Hidden"
485534
IsReadOnly="{TemplateBinding IsReadOnly}" />
486535
<Popup x:Name="Popup"
487536
Placement="Bottom"
@@ -496,7 +545,7 @@
496545
<Border x:Name="DropDownBorder"
497546
BorderThickness="1">
498547
<Border.BorderBrush>
499-
<SolidColorBrush Color="{DynamicResource BorderMediumColor}" />
548+
<SolidColorBrush Color="{StaticResource AccentColor}" />
500549
</Border.BorderBrush>
501550
<Border.Background>
502551
<SolidColorBrush Color="{DynamicResource ControlLightColor}" />
@@ -511,8 +560,7 @@
511560
</Popup>
512561
</Grid>
513562
<ControlTemplate.Triggers>
514-
<Trigger Property="HasItems"
515-
Value="false">
563+
<Trigger Property="HasItems" Value="false">
516564
<Setter TargetName="DropDownBorder"
517565
Property="MinHeight"
518566
Value="95" />
@@ -527,7 +575,7 @@
527575
Value="true">
528576
<Setter TargetName="DropDownBorder"
529577
Property="CornerRadius"
530-
Value="4" />
578+
Value="{StaticResource CornerRadius}" />
531579
<Setter TargetName="DropDownBorder"
532580
Property="Margin"
533581
Value="0,2,0,0" />
@@ -629,6 +677,81 @@
629677
<Style TargetType="TabItem" BasedOn="{StaticResource DefaultTabHeader}"/>
630678

631679

680+
<Style x:Key="GridHeaderRight" TargetType="{x:Type GridViewColumnHeader}">
681+
<Setter Property="Template">
682+
<Setter.Value>
683+
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
684+
<Border BorderBrush="White" BorderThickness="1,0,1,0">
685+
<TextBlock Text="{TemplateBinding Content}" Padding="10,5,10,5" Width="{TemplateBinding Width}" TextAlignment="Left" Background="{StaticResource AccentBrush}" Style="{x:Null}"/>
686+
</Border>
687+
688+
</ControlTemplate>
689+
</Setter.Value>
690+
</Setter>
691+
<Setter Property="HorizontalAlignment" Value="Stretch"/>
692+
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
693+
694+
<Setter Property="OverridesDefaultStyle" Value="True" />
695+
<Setter Property="Background" Value="{StaticResource AccentBrush}" />
696+
<Setter Property="Foreground" Value="White" />
697+
<Setter Property="FontSize" Value="15" />
698+
<Setter Property="Background" Value="{StaticResource AccentBrush}"/>
699+
700+
</Style>
701+
702+
703+
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource GridHeaderRight}"/>
704+
705+
706+
<Style x:Key="DefaultListViewItem" TargetType="{x:Type ListViewItem}">
707+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
708+
<Setter Property="Template">
709+
<Setter.Value>
710+
<ControlTemplate TargetType="{x:Type ListViewItem}">
711+
<Border x:Name="ListBoxItemRoot"
712+
BorderBrush="{TemplateBinding BorderBrush}"
713+
BorderThickness="1,0"
714+
Background="{TemplateBinding Background}"
715+
CornerRadius="2"
716+
Uid="Border_57">
717+
<GridViewRowPresenter Columns="{TemplateBinding GridView.ColumnCollection}"
718+
Content="{TemplateBinding Content}"
719+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
720+
Margin="{TemplateBinding Padding}"
721+
Uid="GridViewRowPresenter_1"
722+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
723+
<VisualStateManager.VisualStateGroups>
724+
<VisualStateGroup x:Name="CommonStates">
725+
<VisualState x:Name="Normal"></VisualState>
726+
<VisualState x:Name="Disabled"></VisualState>
727+
<VisualState x:Name="MouseOver"></VisualState>
728+
</VisualStateGroup>
729+
<VisualStateGroup x:Name="SelectionStates">
730+
<VisualState x:Name="Selected"></VisualState>
731+
<VisualState x:Name="Unselected"></VisualState>
732+
</VisualStateGroup>
733+
</VisualStateManager.VisualStateGroups>
734+
</Border>
735+
</ControlTemplate>
736+
</Setter.Value>
737+
</Setter>
738+
<Style.Triggers>
739+
<Trigger Property="IsMouseOver" Value="true">
740+
<Setter Property="Background" Value="{StaticResource MouseOverBrush}" />
741+
<Setter Property="Foreground" Value="White" />
742+
743+
</Trigger>
744+
<Trigger Property="IsSelected" Value="true">
745+
<Setter Property="Background" Value="{StaticResource HighlightedBrush}" />
746+
<Setter Property="Foreground" Value="White" />
747+
748+
</Trigger>
749+
</Style.Triggers>
750+
</Style>
751+
752+
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource DefaultListViewItem}"/>
753+
754+
632755

633756

634757
<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>

Source/HDRProfile/ApplicationProfileAssignment.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public class ApplicationProfileAssignment : BaseViewModel
2121
public ApplicationItem Application { get => _application; set { _application = value; OnPropertyChanged(); }
2222
}
2323

24-
public Profile Profile { get => _profile; set { _profile = value; OnPropertyChanged(); } }
24+
public Profile Profile {
25+
get => _profile;
26+
set { _profile = value; OnPropertyChanged(); Globals.Instance.SaveSettings(); }
27+
}
2528

26-
public int Position { get => _position; set { _position = value; OnPropertyChanged(); } }
29+
public int Position { get => _position; set { _position = value; OnPropertyChanged(); Globals.Instance.SaveSettings(); } }
2730

2831

2932
private ApplicationProfileAssignment()
@@ -46,11 +49,15 @@ public void RemoveAssignment()
4649
}
4750
Assignments.Remove(this);
4851
Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
49-
52+
Globals.Instance.SaveSettings();
5053
}
5154

5255
public void ChangePosition(bool up)
5356
{
57+
if (up && Position == 0)
58+
return;
59+
if (!up && Position == Assignments.Count - 1)
60+
return;
5461
int newPosition = up ? Position - 1 : Position + 1;
5562
if (Assignments.Any(x => x.Position == newPosition))
5663
{
@@ -59,7 +66,7 @@ public void ChangePosition(bool up)
5966
Position = newPosition;
6067
Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
6168

62-
69+
Globals.Instance.SaveSettings();
6370
}
6471

6572

@@ -70,7 +77,7 @@ public static ApplicationProfileAssignment NewAssigment(ApplicationItem applicat
7077
assigment.Position = GetNextPosition();
7178
Assignments.Add(assigment);
7279
Assignments.Sort(x => x.Position, System.ComponentModel.ListSortDirection.Ascending);
73-
80+
Globals.Instance.SaveSettings();
7481
return assigment;
7582
}
7683

0 commit comments

Comments
 (0)