Skip to content

Commit 8563499

Browse files
committed
1.1.0
- Using WMI for process start and stop event (requires priviled rights) - Use MVVM pattern for dialog handling - cleanup
1 parent b0c661f commit 8563499

21 files changed

+374
-265
lines changed

Source/Debug_x64/HDRProfile.exe

7 KB
Binary file not shown.

Source/Debug_x64/HDRProfile_Settings.xml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<HDRProfileSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3-
<AutoStart>true</AutoStart>
3+
<AutoStart>false</AutoStart>
44
<StartMinimizedToTray>false</StartMinimizedToTray>
5-
<CloseToTray>true</CloseToTray>
6-
<HDRMode>Focused</HDRMode>
5+
<CloseToTray>false</CloseToTray>
6+
<HDRMode>Running</HDRMode>
77
<ApplicationItems>
8-
<ApplicationItem>
9-
<DisplayName>ModernWarfare</DisplayName>
10-
<ApplicationName>ModernWarfare</ApplicationName>
11-
<ApplicationFilePath>D:\Games\Call of Duty Modern Warfare\ModernWarfare.exe</ApplicationFilePath>
12-
<RestartProcess>false</RestartProcess>
13-
</ApplicationItem>
14-
<ApplicationItem>
15-
<DisplayName>Cyberpunk2077</DisplayName>
16-
<ApplicationName>Cyberpunk2077</ApplicationName>
17-
<ApplicationFilePath>C:\Games\GOG\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe</ApplicationFilePath>
18-
<RestartProcess>true</RestartProcess>
19-
</ApplicationItem>
20-
<ApplicationItem>
21-
<DisplayName>starwarsjedifallenorder</DisplayName>
22-
<ApplicationName>starwarsjedifallenorder</ApplicationName>
23-
<ApplicationFilePath>C:\Games\Origin\Jedi Fallen Order\SwGame\Binaries\Win64\starwarsjedifallenorder.exe</ApplicationFilePath>
24-
<RestartProcess>false</RestartProcess>
25-
</ApplicationItem>
26-
<ApplicationItem>
27-
<DisplayName>ACOdyssey</DisplayName>
28-
<ApplicationName>ACOdyssey</ApplicationName>
29-
<ApplicationFilePath>C:\Games\UPlay\Assassin's Creed Odyssey\ACOdyssey.exe</ApplicationFilePath>
30-
<RestartProcess>false</RestartProcess>
31-
</ApplicationItem>
32-
<ApplicationItem>
33-
<DisplayName>WatchDogsLegion</DisplayName>
34-
<ApplicationName>WatchDogsLegion</ApplicationName>
35-
<ApplicationFilePath>C:\Games\UPlay\Watch Dogs Legion\bin\WatchDogsLegion.exe</ApplicationFilePath>
36-
<RestartProcess>false</RestartProcess>
37-
</ApplicationItem>
38-
<ApplicationItem>
39-
<DisplayName>Anno1800</DisplayName>
40-
<ApplicationName>Anno1800</ApplicationName>
41-
<ApplicationFilePath>C:\Games\UPlay\Anno 1800\Bin\Win64\Anno1800.exe</ApplicationFilePath>
42-
<RestartProcess>false</RestartProcess>
43-
</ApplicationItem>
448
<ApplicationItem>
459
<DisplayName>notepad</DisplayName>
4610
<ApplicationName>notepad</ApplicationName>
0 Bytes
Binary file not shown.

Source/HDRProfile/App.xaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
xmlns:system="clr-namespace:System;assembly=mscorlib"
77
xmlns:corewpf="clr-namespace:CodectoryCore.UI.Wpf;assembly=CodectoryCore.UI.Wpf"
88
Exit="Application_Exit"
9-
StartupUri="HDRSwitcherHandlerView.xaml">
9+
StartupUri="HDRProfileHandlerView.xaml">
1010

1111
<Application.Resources>
1212

1313
<system:String x:Key="DonateLink">https://paypal.me/pools/c/8vksshrMln</system:String>
1414
<system:String x:Key="InfoLink">https://sourceforge.net/projects/hdr-profile</system:String>
15-
<system:String x:Key="Version">1.0.2</system:String>
15+
<system:String x:Key="Version">1.1.0</system:String>
1616
<SolidColorBrush x:Key="ButtonBackground" Color="#FF0086F5"/>
1717
<SolidColorBrush x:Key="AccentColor" Color="#FFFF581A"/>
1818
<SolidColorBrush x:Key="AccentColor2" Color="#4C87B3"/>
1919
<CornerRadius x:Key="CornerRadius">3</CornerRadius>
2020
<local:EnumLocaleConverter x:Key="EnumLocaleConverter"/>
21+
<corewpf:DialogService x:Key="DialogService" />
2122
<corewpf:BitmapToBitmapImageConverter x:Key="BitmapToBitmapImageConverter"/>
2223
<corewpf:InvertBooleanConverter x:Key="InvertBooleanConverter"/>
24+
<corewpf:MainWindowBase x:Key="MainWindowBase"/>
2325
<corewpf:IsNotNullConverter x:Key="IsNotNullConverter"/>
2426
<corewpf:IsNotZeroConverter x:Key="IsNotZeroConverter"/>
2527
<corewpf:StringFormatConcatenator x:Key="StringFormatConcatenator"/>
@@ -32,6 +34,10 @@
3234
<corewpf:IsNotZeroConverter />
3335
<corewpf:VisibilityBooleanConverter />
3436
</corewpf:ConverterChain>
37+
38+
<DataTemplate DataType="{x:Type local:ApplicationAdder}">
39+
<local:ApplicationAdderView></local:ApplicationAdderView>
40+
</DataTemplate>
3541
</Application.Resources>
3642

3743
</Application>

Source/HDRProfile/ApplicationAdder.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
using System.Text;
88
using System.Threading.Tasks;
99
using Microsoft.Win32;
10+
using System.Windows;
1011

1112
namespace HDRProfile
1213
{
13-
public class ApplicationAdder : BaseViewModel
14+
public class ApplicationAdder : DialogViewModelBase
1415
{
1516
private bool _canCreate = false;
1617
private string _displayName = string.Empty;
@@ -20,18 +21,20 @@ public class ApplicationAdder : BaseViewModel
2021
public ApplicationItem ApplicationItem { get => applicationItem; private set { applicationItem = value; OnPropertyChanged(); } }
2122

2223
public RelayCommand GetFileCommand { get; private set; }
23-
public RelayCommand CreateApplicationItemCommand { get; private set; }
24+
public RelayCommand<object> OKClickCommand { get; private set; }
2425

26+
public event EventHandler OKClicked;
2527

2628
public ApplicationAdder()
2729
{
30+
Title = Locale_Texts.AddApplication;
2831
CreateRelayCommands();
2932
}
3033

3134
private void CreateRelayCommands()
3235
{
3336
GetFileCommand = new RelayCommand(GetFile);
34-
CreateApplicationItemCommand = new RelayCommand(CreateApplicationItem);
37+
OKClickCommand = new RelayCommand<object>(CreateApplicationItem);
3538
}
3639

3740

@@ -64,10 +67,12 @@ public void GetFile()
6467
DisplayName = new FileInfo(FilePath).Name.Replace(".exe", "");
6568
}
6669

67-
public void CreateApplicationItem()
70+
public void CreateApplicationItem(object parameter)
6871
{
6972

7073
ApplicationItem = new ApplicationItem(DisplayName, FilePath);
74+
OKClicked?.Invoke(this, EventArgs.Empty);
75+
CloseDialog(parameter as Window);
7176
}
7277
}
7378
}
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
<Window x:Class="HDRProfile.ApplicationAdderView"
1+
<UserControl x:Class="HDRProfile.ApplicationAdderView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:HDRProfile"
77
mc:Ignorable="d"
8-
Title="{x:Static local:Locale_Texts.HDRProfile}" Height="151.407" Width="414" MinHeight="165" MinWidth="414">
9-
10-
<Window.DataContext>
11-
<local:ApplicationAdder/>
12-
</Window.DataContext>
8+
d:DataContext="{d:DesignInstance Type=local:ApplicationAdder, IsDesignTimeCreatable=False}"
9+
Height="130.159" Width="414" MinWidth="414">
1310

1411
<Grid Margin="0,0,2,-1" VerticalAlignment="Top">
1512
<Grid.RowDefinitions>
@@ -20,10 +17,10 @@
2017
<Label Content="{x:Static local:Locale_Texts.FilePath}" HorizontalAlignment="Left" Margin="10,41,0,0" VerticalAlignment="Top" Width="111"/>
2118
<TextBox Height="23" Margin="126,13,10,0" TextWrapping="Wrap" Text="{Binding DisplayName}" VerticalAlignment="Top"/>
2219
<TextBlock Text="{Binding FilePath}" Margin="126,41,10,0" VerticalAlignment="Top" Height="26" />
23-
<Button Content="{x:Static local:Locale_Texts.OK}" IsEnabled="{Binding CanCreate}" Command="{Binding CreateApplicationItemCommand}" Margin="0,103,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="82" Click="Button_Click" Grid.RowSpan="2" Height="Auto"/>
20+
<Button Content="{x:Static local:Locale_Texts.OK}" IsEnabled="{Binding CanCreate}" Command="{Binding OKClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}" Margin="0,103,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="82" Grid.RowSpan="2" Height="Auto"/>
2421
<Button Content="{Binding Source={x:Static local:Locale_Texts.ChooseApplication}, StringFormat={}{0}...}" Command="{Binding GetFileCommand}" Margin="10,0,0,0" VerticalAlignment="Top" Grid.Row="1" HorizontalAlignment="Left" Width="Auto" Height="Auto">
2522

2623
</Button>
2724

2825
</Grid>
29-
</Window>
26+
</UserControl>

Source/HDRProfile/ApplicationAdderView.xaml.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ namespace HDRProfile
1717
/// <summary>
1818
/// Interaktionslogik für ApplicationAdderView.xaml
1919
/// </summary>
20-
public partial class ApplicationAdderView : Window
20+
public partial class ApplicationAdderView : UserControl
2121
{
2222
public ApplicationAdderView()
2323
{
2424
InitializeComponent();
2525
}
26-
27-
private void Button_Click(object sender, RoutedEventArgs e)
28-
{
29-
this.Close();
30-
}
3126
}
3227
}
Binary file not shown.

Source/HDRProfile/HDRProfile.csproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<PropertyGroup>
5757
<ApplicationIcon>LogoBig.ico</ApplicationIcon>
5858
</PropertyGroup>
59+
<PropertyGroup>
60+
<ApplicationManifest>app.manifest</ApplicationManifest>
61+
</PropertyGroup>
5962
<ItemGroup>
6063
<Reference Include="CodectoryCore.UI.Wpf, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
6164
<SpecificVersion>False</SpecificVersion>
@@ -75,7 +78,15 @@
7578
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
7679
<HintPath>..\packages\System.Drawing.Common.5.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
7780
</Reference>
81+
<Reference Include="System.IdentityModel" />
7882
<Reference Include="System.Management" />
83+
<Reference Include="System.Runtime.Serialization" />
84+
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
85+
<HintPath>..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath>
86+
<Private>True</Private>
87+
<Private>True</Private>
88+
</Reference>
89+
<Reference Include="System.ServiceModel" />
7990
<Reference Include="System.Windows.Interactivity">
8091
<HintPath>..\Externals\System.Windows.Interactivity.dll</HintPath>
8192
</Reference>
@@ -97,11 +108,12 @@
97108
<Generator>MSBuild:Compile</Generator>
98109
<SubType>Designer</SubType>
99110
</ApplicationDefinition>
111+
<Compile Include="Tools.cs" />
100112
<Page Include="HDRProfileSettingsView.xaml">
101113
<SubType>Designer</SubType>
102114
<Generator>MSBuild:Compile</Generator>
103115
</Page>
104-
<Page Include="HDRSwitcherHandlerView.xaml">
116+
<Page Include="HDRProfileHandlerView.xaml">
105117
<Generator>MSBuild:Compile</Generator>
106118
<SubType>Designer</SubType>
107119
</Page>
@@ -117,8 +129,8 @@
117129
<Compile Include="HDRProfileSettingsView.xaml.cs">
118130
<DependentUpon>HDRProfileSettingsView.xaml</DependentUpon>
119131
</Compile>
120-
<Compile Include="HDRSwitcherHandlerView.xaml.cs">
121-
<DependentUpon>HDRSwitcherHandlerView.xaml</DependentUpon>
132+
<Compile Include="HDRProfileHandlerView.xaml.cs">
133+
<DependentUpon>HDRProfileHandlerView.xaml</DependentUpon>
122134
<SubType>Code</SubType>
123135
</Compile>
124136
<Page Include="ApplicationAdderView.xaml">
@@ -148,7 +160,6 @@
148160
</Compile>
149161
<Compile Include="ApplicationItem.cs" />
150162
<Compile Include="ProcessWatcher.cs" />
151-
<Compile Include="ProcessWatchMode.cs" />
152163
<Compile Include="Properties\AssemblyInfo.cs">
153164
<SubType>Code</SubType>
154165
</Compile>
@@ -181,6 +192,7 @@
181192
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
182193
</EmbeddedResource>
183194
<EmbeddedResource Include="Costura64\nvapi64.lib" />
195+
<None Include="app.manifest" />
184196
<None Include="packages.config" />
185197
<None Include="Properties\Settings.settings">
186198
<Generator>SettingsSingleFileGenerator</Generator>

0 commit comments

Comments
 (0)