Skip to content

Commit 5a970a8

Browse files
committed
Reference profile & cleanup
Added reference profile action and cleanup up xaml code
1 parent db34978 commit 5a970a8

37 files changed

+709
-265
lines changed

Source/AutoHDR.Audio/AudioController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void UpdateDevices()
5454
{
5555
lock (_lockDevices)
5656
{
57-
List<CoreAudioDevice> devices = Controller.GetDevices(AudioSwitcher.AudioApi.DeviceState.All).ToList();
57+
List<CoreAudioDevice> devices = Controller.GetDevices(AudioSwitcher.AudioApi.DeviceState.Active | AudioSwitcher.AudioApi.DeviceState.Unplugged).ToList();
5858

5959
List<AudioDevice> outputAudioDevices = new List<AudioDevice>();
6060
List<AudioDevice> inputAudioDevices = new List<AudioDevice>();

Source/AutoHDR.ProjectResources/ProjectLocales.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/AutoHDR.ProjectResources/ProjectLocales.de.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,21 @@
297297
<data name="ManagedHDR" xml:space="preserve">
298298
<value>Automatischer HDR-Modus</value>
299299
</data>
300+
<data name="MessageMissingAudioDevice" xml:space="preserve">
301+
<value>Audiogerät fehlt.</value>
302+
</data>
303+
<data name="MessageMissingFile" xml:space="preserve">
304+
<value>Datei fehlt.</value>
305+
</data>
306+
<data name="MessageMissingProcessName" xml:space="preserve">
307+
<value>Prozessname fehlt</value>
308+
</data>
309+
<data name="MessageReferenceLoop" xml:space="preserve">
310+
<value>Der Verweis auf das Profil erzeugt eine Schleife.</value>
311+
</data>
312+
<data name="MessageReferenceProfileNotFound" xml:space="preserve">
313+
<value>Das verwiesene Profil mit der Guid {0} wurde nicht gefunden.</value>
314+
</data>
300315
<data name="MinimizeToTray" xml:space="preserve">
301316
<value>Zu Symbolleiste minimieren, beim Schließen</value>
302317
</data>
@@ -339,6 +354,9 @@
339354
<data name="Profiles" xml:space="preserve">
340355
<value>Profile</value>
341356
</data>
357+
<data name="ReferenceProfileAction" xml:space="preserve">
358+
<value>Profilverweis</value>
359+
</data>
342360
<data name="RefreshRate" xml:space="preserve">
343361
<value>Bildwiederholrate [Hz]</value>
344362
</data>

Source/AutoHDR.ProjectResources/ProjectLocales.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,21 @@ Public License instead of this License. But first, please read
10131013
<data name="ManagedHDR" xml:space="preserve">
10141014
<value>Automated HDR mode</value>
10151015
</data>
1016+
<data name="MessageMissingAudioDevice" xml:space="preserve">
1017+
<value>Mssing audio device.</value>
1018+
</data>
1019+
<data name="MessageMissingFile" xml:space="preserve">
1020+
<value>Missing file.</value>
1021+
</data>
1022+
<data name="MessageMissingProcessName" xml:space="preserve">
1023+
<value>Missing process name.</value>
1024+
</data>
1025+
<data name="MessageReferenceLoop" xml:space="preserve">
1026+
<value>Refrenced profile is creating a loop.</value>
1027+
</data>
1028+
<data name="MessageReferenceProfileNotFound" xml:space="preserve">
1029+
<value>Referenced profile with Guid {0} hasn't been found.</value>
1030+
</data>
10161031
<data name="MinimizeToTray" xml:space="preserve">
10171032
<value>Close to tray</value>
10181033
</data>
@@ -1055,6 +1070,9 @@ Public License instead of this License. But first, please read
10551070
<data name="Profiles" xml:space="preserve">
10561071
<value>Profiles</value>
10571072
</data>
1073+
<data name="ReferenceProfileAction" xml:space="preserve">
1074+
<value>Reference profile</value>
1075+
</data>
10581076
<data name="RefreshRate" xml:space="preserve">
10591077
<value>Refresh rate [Hz]</value>
10601078
</data>

Source/AutoHDR/App.xaml

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<system:String x:Key="DonateLink">https://paypal.me/HeikoH89</system:String>
2525
<system:String x:Key="GitHubRepoLink">https://github.com/Codectory/AutoHDR</system:String>
2626

27-
2827
<Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
2928
<Setter Property="Template">
3029
<Setter.Value>
@@ -50,23 +49,61 @@
5049

5150

5251

53-
<Style x:Key="DefaultLabel" TargetType="Label">
54-
<Setter Property="FontSize" Value="{StaticResource DefaultFontSize}"/>
55-
</Style>
56-
<Style TargetType="Label" BasedOn="{StaticResource DefaultLabel}"/>
52+
<Style x:Key="DefaultTextBlock" TargetType="TextBlock">
53+
<Setter Property="FontSize" Value="{StaticResource DefaultFontSize}" />
54+
<Setter Property="Foreground" Value="Black"/>
55+
<Setter Property="Margin" Value="5"/>
5756

57+
</Style>
5858

5959

60-
<Style x:Key="DefaultTextBlock" TargetType="TextBlock">
61-
<Setter Property="FontSize" Value="15"/>
62-
<Setter Property="Foreground" Value="Black"/>
6360

64-
</Style>
65-
66-
<Style TargetType="TextBlock" BasedOn="{StaticResource DefaultTextBlock}"/>
61+
<Style x:Key="TitleTextBlock" TargetType="TextBlock" BasedOn="{StaticResource DefaultTextBlock}">
62+
<Setter Property="FontSize" Value="25"/>
63+
<Setter Property="Foreground" Value="Black"/>
64+
<Setter Property="FontWeight" Value="Bold"/>
65+
</Style>
66+
67+
<Style x:Key="SubTitleTextBlock" TargetType="TextBlock" BasedOn="{StaticResource DefaultTextBlock}">
68+
<Setter Property="FontSize" Value="20"/>
69+
<Setter Property="Foreground" Value="Black"/>
70+
<Setter Property="FontWeight" Value="DemiBold"/>
71+
</Style>
6772

6873

69-
<Style x:Key="DefaultUserControl" TargetType="UserControl">
74+
<Style x:Key="ToggleStatus" TargetType="{x:Type CheckBox}">
75+
76+
<Setter Property="SnapsToDevicePixels"
77+
Value="true" />
78+
<Setter Property="IsEnabled"
79+
Value="false" />
80+
81+
<Setter Property="Height"
82+
Value="20" />
83+
<Setter Property="Width"
84+
Value="20" />
85+
<Setter Property="OverridesDefaultStyle"
86+
Value="true" />
87+
<Setter Property="FocusVisualStyle"
88+
Value="{DynamicResource CheckBoxFocusVisual}" />
89+
<Setter Property="Template">
90+
<Setter.Value>
91+
<ControlTemplate TargetType="{x:Type CheckBox}">
92+
<Ellipse Fill="{TemplateBinding Background}" HorizontalAlignment="Stretch" Stroke="Black" VerticalAlignment="Stretch" />
93+
</ControlTemplate>
94+
</Setter.Value>
95+
</Setter>
96+
<Style.Triggers>
97+
<Trigger Property="IsChecked" Value="true">
98+
<Setter Property="Background" Value="{StaticResource ActiveBrush}"></Setter>
99+
</Trigger>
100+
<Trigger Property="IsChecked" Value="false">
101+
<Setter Property="Background" Value="Transparent"></Setter>
102+
</Trigger>
103+
</Style.Triggers>
104+
105+
</Style>
106+
<Style x:Key="DefaultUserControl" TargetType="UserControl">
70107
<Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}"/>
71108
<Setter Property="Foreground" Value="Black"/>
72109

@@ -75,7 +112,7 @@
75112

76113

77114

78-
<Style x:Key="HDRCircle" TargetType="Ellipse">
115+
<!--<Style x:Key="HDRCircle" TargetType="Ellipse">
79116
<Setter Property="HorizontalAlignment" Value="Center" />
80117
<Setter Property="VerticalAlignment" Value="Center" />
81118
<Style.Triggers>
@@ -86,7 +123,7 @@
86123
<Setter Property="Fill" Value="Transparent"/>
87124
</Trigger>
88125
</Style.Triggers>
89-
</Style>
126+
</Style>-->
90127

91128
<Style x:Key="DefaultTextBox" TargetType="TextBox" >
92129
<Setter Property="BorderThickness" Value="0"/>
@@ -149,7 +186,7 @@
149186
<Setter.Value>
150187
<ControlTemplate TargetType="Button">
151188
<Border Height="Auto" Width="Auto" BorderBrush="{TemplateBinding Background}" Background="{TemplateBinding Background}" BorderThickness="0" CornerRadius="{StaticResource CornerRadius}">
152-
<TextBlock FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="5,2" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
189+
<TextBlock Style="{StaticResource DefaultTextBlock}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="8,5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
153190
</Border>
154191
</ControlTemplate>
155192
</Setter.Value>
@@ -312,7 +349,7 @@
312349
<Grid>
313350
<Border x:Name="HeaderBorder" Background="Transparent" Height="Auto" Width="Auto" BorderBrush="{TemplateBinding Background}" CornerRadius="3 3 0 0">
314351
</Border>
315-
<TextBlock x:Name="HeaderContent" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Header}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
352+
<TextBlock Style="{StaticResource DefaultTextBlock}" x:Name="HeaderContent" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Background="Transparent" Margin="5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Header}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
316353

317354
</Grid>
318355
<ControlTemplate.Triggers>
@@ -643,7 +680,7 @@
643680
<views:AutoHDRLogsView></views:AutoHDRLogsView>
644681
</DataTemplate>
645682
<DataTemplate x:Key="ProfileItemTemplate" DataType="Profile">
646-
<TextBlock Text="{Binding Name }"/>
683+
<TextBlock Style="{StaticResource DefaultTextBlock}" Text="{Binding Name }"/>
647684
</DataTemplate>
648685
</ResourceDictionary>
649686

Source/AutoHDR/Applications/ApplicationChangedEventArgs.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ namespace AutoHDR
88
{
99
public enum ApplicationChangedType
1010
{
11+
None,
1112
Started,
1213
Closed,
1314
GotFocus,
1415
LostFocus
16+
1517
}
1618
public class ApplicationChangedEventArgs : EventArgs
1719
{

Source/AutoHDR/AutoHDR.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,17 @@
174174
<Compile Include="Globals.cs" />
175175
<Compile Include="LoopManager.cs" />
176176
<Compile Include="Profiles\Actions\CloseProgramAction.cs" />
177+
<Compile Include="Profiles\Actions\ReferenceProfileAction.cs" />
177178
<Compile Include="Theming\ThemeResourceDirectory.cs" />
178179
<Compile Include="Theming\Theme.cs" />
179180
<Compile Include="UserAppSettings.cs" />
180181
<Compile Include="UWP\WWAHostHandler.cs" />
181182
<Compile Include="Views\CloseProgramActionView.xaml.cs">
182183
<DependentUpon>CloseProgramActionView.xaml</DependentUpon>
183184
</Compile>
185+
<Compile Include="Views\ReferenceProfileActionView.xaml.cs">
186+
<DependentUpon>ReferenceProfileActionView.xaml</DependentUpon>
187+
</Compile>
184188
<Compile Include="WinAPIFunctions.cs" />
185189
<Compile Include="Windows\UI.cs" />
186190
<Page Include="App.xaml">
@@ -283,6 +287,10 @@
283287
<Generator>MSBuild:Compile</Generator>
284288
<SubType>Designer</SubType>
285289
</Page>
290+
<Page Include="Views\ReferenceProfileActionView.xaml">
291+
<Generator>MSBuild:Compile</Generator>
292+
<SubType>Designer</SubType>
293+
</Page>
286294
<Page Include="Views\RunProgramActionView.xaml">
287295
<Generator>MSBuild:Compile</Generator>
288296
<SubType>Designer</SubType>

Source/AutoHDR/AutoHDRDaemon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private void UpdateCurrentProfile(ApplicationItem application, ApplicationChange
205205
{
206206
App.Current.Dispatcher.Invoke(() => LastActions.Add(action));
207207
action.NewLog += ActionLog;
208-
action.RunAction();
208+
action.RunAction(changedType);
209209
action.NewLog -= ActionLog;
210210
System.Threading.Thread.Sleep(100);
211211
}
@@ -248,7 +248,7 @@ private void InitializeTrayMenuHelper()
248248
{
249249
Globals.Logs.Add("Initializing TrayMenu...", false);
250250
TrayMenuHelper = new TrayMenuHelper();
251-
TrayMenuHelper.Initialize(DisplayManagerHandler.Instance);
251+
TrayMenuHelper.Initialize();
252252
TrayMenuHelper.OpenViewRequested += TrayMenuHelper_OpenViewRequested;
253253
TrayMenuHelper.CloseApplicationRequested += TrayMenuHelper_CloseApplicationRequested;
254254
//TrayMenuHelper.SwitchTrayIcon(Settings.StartMinimizedToTray);

Source/AutoHDR/Controls/CustomComboBox.xaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
<Border Style="{StaticResource DefaultBorder}"
1212
x:Name="Border"
1313
Grid.ColumnSpan="2"
14-
Background="{StaticResource ControlLightBrush}"
15-
BorderBrush="{StaticResource AccentBrush}"
16-
BorderThickness="1" />
14+
Background="{StaticResource ControlLightBrush}" />
1715
<Border
1816
Grid.Column="0"
1917
CornerRadius="0"
@@ -100,8 +98,8 @@
10098
MinWidth="{TemplateBinding ActualWidth}"
10199
MaxHeight="{TemplateBinding MaxDropDownHeight}">
102100
<Border
103-
x:Name="DropDownBorder" Style="{StaticResource DefaultBorder}" CornerRadius="5"
104-
Background="{StaticResource ControlLightBrush}" BorderThickness="1,1,1,1"/>
101+
x:Name="DropDownBorder" Style="{StaticResource DefaultBorder}"
102+
Background="{StaticResource ControlLightBrush}"/>
105103
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
106104
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
107105
</ScrollViewer>

Source/AutoHDR/Profiles/Actions/AudioDeviceAction.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ namespace AutoHDR.Profiles.Actions
99
[JsonObject(MemberSerialization.OptIn)]
1010
public class AudioDeviceAction : ProfileActionBase
1111
{
12-
public override string ActionTypeName => ProjectLocales.AudioAction;
1312

13+
public override bool CanSave => (SetOutput && OutputDevice==null) || (SetInput && InputDevice == null);
14+
public override string CannotSaveMessage => ProjectLocales.MessageMissingAudioDevice;
15+
16+
public override string ActionTypeName => ProjectLocales.AudioAction;
1417

1518

1619
private Guid _outputDeviceID = Guid.Empty;
@@ -50,7 +53,7 @@ public AudioDeviceAction() : base()
5053
{
5154
}
5255

53-
public override ActionEndResult RunAction(params object[] parameter)
56+
public override ActionEndResult RunAction(ApplicationChangedType applicationChangedType)
5457
{
5558
try
5659
{

0 commit comments

Comments
 (0)