Skip to content

Commit b89a324

Browse files
committed
1.5.2
Bugfixes
1 parent 9a103d9 commit b89a324

File tree

10 files changed

+45
-55
lines changed

10 files changed

+45
-55
lines changed

Source/Debug_x64/HDRProfile.exe

519 KB
Binary file not shown.
-4.5 KB
Binary file not shown.
1 KB
Binary file not shown.

Source/HDRProfile/HDRProfile.csproj

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</PropertyGroup>
6262
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
6363
<DebugSymbols>true</DebugSymbols>
64-
<OutputPath>bin\x64\Debug\</OutputPath>
64+
<OutputPath>..\Debug_x64\</OutputPath>
6565
<DefineConstants>DEBUG;TRACE</DefineConstants>
6666
<DebugType>full</DebugType>
6767
<PlatformTarget>x64</PlatformTarget>
@@ -156,6 +156,16 @@
156156
<SubType>Designer</SubType>
157157
</ApplicationDefinition>
158158
<Compile Include="ApplicationState.cs" />
159+
<Compile Include="Locale_Texts.de.Designer.cs">
160+
<AutoGen>True</AutoGen>
161+
<DesignTime>True</DesignTime>
162+
<DependentUpon>Locale_Texts.de.resx</DependentUpon>
163+
</Compile>
164+
<Compile Include="Locale_Texts.Designer.cs">
165+
<AutoGen>True</AutoGen>
166+
<DesignTime>True</DesignTime>
167+
<DependentUpon>Locale_Texts.resx</DependentUpon>
168+
</Compile>
159169
<Compile Include="Tools.cs" />
160170
<Compile Include="TrayMenuHelper.cs" />
161171
<Page Include="HDRProfileSettingsView.xaml">
@@ -188,16 +198,6 @@
188198
</Page>
189199
</ItemGroup>
190200
<ItemGroup>
191-
<Compile Include="Locale_Texts.de.Designer.cs">
192-
<DependentUpon>Locale_Texts.de.resx</DependentUpon>
193-
<AutoGen>True</AutoGen>
194-
<DesignTime>True</DesignTime>
195-
</Compile>
196-
<Compile Include="Locale_Texts.Designer.cs">
197-
<AutoGen>True</AutoGen>
198-
<DesignTime>True</DesignTime>
199-
<DependentUpon>Locale_Texts.resx</DependentUpon>
200-
</Compile>
201201
<Compile Include="Locale_Enums.Designer.cs">
202202
<AutoGen>True</AutoGen>
203203
<DesignTime>True</DesignTime>
@@ -222,19 +222,17 @@
222222
<DependentUpon>Settings.settings</DependentUpon>
223223
<DesignTimeSharedInput>True</DesignTimeSharedInput>
224224
</Compile>
225+
<EmbeddedResource Include="Locale_Enums.resx">
226+
<Generator>PublicResXFileCodeGenerator</Generator>
227+
<LastGenOutput>Locale_Enums.Designer.cs</LastGenOutput>
228+
</EmbeddedResource>
225229
<EmbeddedResource Include="Locale_Texts.de.resx">
226230
<Generator>PublicResXFileCodeGenerator</Generator>
227231
<LastGenOutput>Locale_Texts.de.Designer.cs</LastGenOutput>
228-
<SubType>Designer</SubType>
229232
</EmbeddedResource>
230233
<EmbeddedResource Include="Locale_Texts.resx">
231234
<Generator>PublicResXFileCodeGenerator</Generator>
232235
<LastGenOutput>Locale_Texts.Designer.cs</LastGenOutput>
233-
<SubType>Designer</SubType>
234-
</EmbeddedResource>
235-
<EmbeddedResource Include="Locale_Enums.resx">
236-
<Generator>PublicResXFileCodeGenerator</Generator>
237-
<LastGenOutput>Locale_Enums.Designer.cs</LastGenOutput>
238236
</EmbeddedResource>
239237
<EmbeddedResource Include="Properties\Resources.resx">
240238
<Generator>ResXFileCodeGenerator</Generator>

Source/HDRProfile/HDRProfileHandler.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class HDRProfileHandler : BaseViewModel
3333
private static Logs Logs = new Logs($"{System.AppDomain.CurrentDomain.BaseDirectory}HDRProfile.log", "HDRPProfile", Assembly.GetExecutingAssembly().GetName().Version.ToString(), true);
3434
private HDRProfileSettings settings;
3535

36-
Dictionary<ApplicationItem, bool> _lastApplicationStates = new Dictionary<ApplicationItem, bool>();
36+
Dictionary<ApplicationItem, ApplicationState> _lastApplicationStates = new Dictionary<ApplicationItem, ApplicationState>();
3737

3838
private string SettingsPath => $"{System.AppDomain.CurrentDomain.BaseDirectory}HDRProfile_Settings.xml";
3939

@@ -77,7 +77,7 @@ public string Version
7777

7878
public HDRProfileHandler()
7979
{
80-
ChangeLanguage( new System.Globalization.CultureInfo("en-US"));
80+
//ChangeLanguage( new System.Globalization.CultureInfo("en-US"));
8181
Initialize();
8282
}
8383

@@ -108,6 +108,7 @@ private void Initialize()
108108
ShowView = !Settings.StartMinimizedToTray;
109109
Initialized = true;
110110
Logs.Add("Initialized", false);
111+
Start();
111112

112113
}
113114
}
@@ -176,7 +177,7 @@ private void LoadSettings()
176177
Logs.LoggingEnabled = Settings.Logging;
177178
foreach (var application in Settings.ApplicationItems)
178179
{
179-
ProcessWatcher.AddProcess(application);
180+
ProcessWatcher.AddProcess(application, false);
180181
application.PropertyChanged += ApplicationItem_PropertyChanged;
181182
}
182183
Logs.Add("Settings loaded", false);
@@ -189,7 +190,6 @@ private void CreateRelayCommands()
189190
DeactivateHDRCommand = new RelayCommand(HDRController.DeactivateHDR);
190191
AddApplicationCommand = new RelayCommand(AddAplication);
191192
RemoveApplicationCommand = new RelayCommand<ApplicationItem>(RemoveApplication);
192-
LoadingCommand = new RelayCommand(Starting);
193193
ClosingCommand = new RelayCommand(Closing);
194194
ShutdownCommand = new RelayCommand(Shutdown);
195195
StartApplicationCommand = new RelayCommand<ApplicationItem>(StartApplication);
@@ -248,11 +248,6 @@ private void StartApplication(ApplicationItem application)
248248
}
249249
}
250250

251-
252-
private void Starting()
253-
{
254-
Start();
255-
}
256251
private void Closing()
257252
{
258253
if (Settings.CloseToTray)
@@ -423,7 +418,7 @@ private void UpdateHDRBasedOnCurrentApplication()
423418
Logs.Add($"Activating HDR...", false);
424419

425420
HDRController.ActivateHDR();
426-
CheckIfRestartIsNecessary((IDictionary<ApplicationItem, bool>)ProcessWatcher.Applications);
421+
CheckIfRestartIsNecessary((IDictionary<ApplicationItem, ApplicationState>)ProcessWatcher.Applications);
427422

428423
}
429424
else if (HDRController.HDRIsActive && Settings.HDRMode != HDRActivationMode.None)
@@ -444,17 +439,17 @@ private void UpdateHDRBasedOnCurrentApplication()
444439
}
445440
}
446441

447-
private void CheckIfRestartIsNecessary(IDictionary<ApplicationItem, bool> applicationStates)
442+
private void CheckIfRestartIsNecessary(IDictionary<ApplicationItem, ApplicationState> applicationStates)
448443
{
449-
Dictionary<ApplicationItem, bool> newLastStates = new Dictionary<ApplicationItem, bool>();
444+
Dictionary<ApplicationItem, ApplicationState> newLastStates = new Dictionary<ApplicationItem, ApplicationState>();
450445
foreach (var applicationState in applicationStates)
451446
{
452447
if (!applicationState.Key.RestartProcess)
453448
continue;
454449
newLastStates.Add(applicationState.Key, applicationState.Value);
455-
if (!_lastApplicationStates.ContainsKey(applicationState.Key) && applicationState.Value)
450+
if (!_lastApplicationStates.ContainsKey(applicationState.Key) && applicationState.Value != ApplicationState.None)
456451
RestartProcess(applicationState.Key);
457-
else if (_lastApplicationStates.ContainsKey(applicationState.Key) && applicationState.Value && !_lastApplicationStates[applicationState.Key])
452+
else if (_lastApplicationStates.ContainsKey(applicationState.Key) && applicationState.Value != ApplicationState.None && _lastApplicationStates[applicationState.Key] == ApplicationState.None)
458453
RestartProcess(applicationState.Key);
459454
}
460455
_lastApplicationStates.Clear();

Source/HDRProfile/HDRProfileHandlerView.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
Height="362"
1313
Width="550" Loaded="MainWindow_Loaded">
1414
<i:Interaction.Triggers>
15-
<i:EventTrigger EventName="Loaded">
16-
<i:InvokeCommandAction Command="{Binding LoadingCommand}"/>
17-
</i:EventTrigger>
1815
<i:EventTrigger EventName="Closing">
1916
<i:InvokeCommandAction Command="{Binding ClosingCommand}"/>
2017
</i:EventTrigger>
@@ -104,7 +101,11 @@
104101
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Text="{x:Static local:Locale_Texts.CurrentApplication}" Width="Auto" FontWeight="Bold" Height="Auto" FontSize="15" VerticalAlignment="Center" />
105102

106103
<Border Grid.Row="2" Grid.Column="3" BorderThickness="1" BorderBrush="LightGray" Style="{StaticResource RounedBorder}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" Padding="0">
107-
<Image Source="{Binding CurrentApplication.Icon, Converter={StaticResource BitmapToBitmapImageConverter}}" Stretch="Fill" HorizontalAlignment="Left" Width="40" Height="40" VerticalAlignment="Top"/>
104+
<Rectangle RadiusX="3" RadiusY="3" Width="40" Height="40" Margin="2 ">
105+
<Rectangle.Fill>
106+
<ImageBrush ImageSource="{Binding CurrentApplication.Icon, Converter={StaticResource BitmapToBitmapImageConverter}}" Stretch="Fill" />
107+
</Rectangle.Fill>
108+
</Rectangle>
108109
</Border>
109110
<TextBlock Grid.Row="2" Grid.Column="4" Text="{Binding CurrentApplication.DisplayName , FallbackValue={x:Static local:Locale_Texts.NoApplication}}" TextAlignment="left" Width="Auto" VerticalAlignment="Center" FontSize="15" />
110111

Source/HDRProfile/Locale_Texts.de.resx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@
177177
<data name="Logging" xml:space="preserve">
178178
<value>Logging</value>
179179
</data>
180-
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
181-
<data name="Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
182-
<value>Logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
183-
</data>
184180
<data name="MinimizeToTray" xml:space="preserve">
185181
<value>Zu Symbolleiste minimieren, beim Schließen</value>
186182
</data>

Source/HDRProfile/ProcessWatcher.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ProcessWatcher
1717

1818
Thread _watchProcessThread = null;
1919

20-
readonly object _processesLock = new object();
20+
readonly object _applicationsLock = new object();
2121
readonly object _accessLock = new object();
2222

2323
public ApplicationItem CurrentRunningApplicationItem { get; private set; }
@@ -57,7 +57,7 @@ private void CallNewLog(string logMessage)
5757

5858
private void StartWatch_EventArrived(object sender, EventArrivedEventArgs e)
5959
{
60-
lock (_processesLock)
60+
lock (_applicationsLock)
6161
{
6262
string applicationName = e.NewEvent.Properties["ProcessName"].Value.ToString().Replace(".exe", "").ToUpperInvariant();
6363
if (_applications.Any(a => a.Key.ApplicationName.ToUpperInvariant().Equals(applicationName)))
@@ -73,7 +73,7 @@ private void StartWatch_EventArrived(object sender, EventArrivedEventArgs e)
7373
private void StopWatch_EventArrived(object sender, EventArrivedEventArgs e)
7474
{
7575

76-
lock (_processesLock)
76+
lock (_applicationsLock)
7777
{
7878
string applicationName = e.NewEvent.Properties["ProcessName"].Value.ToString().Replace(".exe", "").ToUpperInvariant();
7979
if (_applications.Any(a => a.Key.ApplicationName.ToUpperInvariant().Equals(applicationName)))
@@ -85,22 +85,23 @@ private void StopWatch_EventArrived(object sender, EventArrivedEventArgs e)
8585
}
8686
}
8787

88-
public void AddProcess(ApplicationItem application)
88+
public void AddProcess(ApplicationItem application, bool updateRunningProcesses = true)
8989
{
90-
lock (_processesLock)
90+
lock (_applicationsLock)
9191
{
9292
if (!_applications.ContainsKey(application))
9393
{
9494
_applications.Add(application, ApplicationState.None);
9595
CallNewLog($"Application added to process watcher: {application}");
9696
}
97-
UpdateRunningProcessesOnce();
97+
if (updateRunningProcesses)
98+
UpdateRunningProcessesOnce();
9899
}
99100
}
100101

101102
public void RemoveProcess(ApplicationItem application)
102103
{
103-
lock (_processesLock)
104+
lock (_applicationsLock)
104105
{
105106
if (_applications.ContainsKey(application))
106107
{
@@ -125,7 +126,7 @@ public void Start()
125126
_watchProcessThread = new Thread(WatchProcessLoop);
126127
_watchProcessThread.IsBackground = true;
127128
_watchProcessThread.Start();
128-
CallNewLog($"rocess watcher started");
129+
CallNewLog($"Process watcher started");
129130
}
130131
}
131132

@@ -151,7 +152,7 @@ public void Stop()
151152

152153
private void UpdateRunningProcessesOnce()
153154
{
154-
lock (_processesLock)
155+
lock (_applicationsLock)
155156
{
156157
CallNewLog($"Looking for running applications on start...");
157158

@@ -168,8 +169,6 @@ private void UpdateRunningProcessesOnce()
168169
_applications[application] = ApplicationState.Running;
169170
CurrentRunningApplicationItem = application;
170171
CallNewLog($"Application is running: {application}");
171-
172-
return;
173172
}
174173
}
175174
}
@@ -184,7 +183,7 @@ private void WatchProcessLoop()
184183
{
185184
while (!_stopRequested)
186185
{
187-
lock (_processesLock)
186+
lock (_applicationsLock)
188187
{
189188
bool oldIsOneRunning = OneProcessIsRunning;
190189
bool newIsOneRunning = GetIsOneProcessRunning();
@@ -230,7 +229,7 @@ private bool GetIsOneProcessRunning()
230229
private bool GetIsOneProcessFocused()
231230
{
232231
string currentProcessName = GetForegroundProcessName().ToUpperInvariant();
233-
lock (_processesLock)
232+
lock (_applicationsLock)
234233
{
235234
if (_applications.Any(a => a.Key.ApplicationName.ToUpperInvariant().Equals(currentProcessName)))
236235
{
@@ -242,7 +241,8 @@ private bool GetIsOneProcessFocused()
242241
}
243242
else
244243
{
245-
foreach (var application in _applications.Select(a => a.Key))
244+
var applications = _applications.Select(a => a.Key).ToList();
245+
foreach (var application in applications)
246246
if (_applications[application] != ApplicationState.None)
247247
_applications[application] = ApplicationState.Running;
248248
CurrentFocusedApplicationItem = null;

Source/HDRProfile/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.5.1.0")]
56-
[assembly: AssemblyFileVersion("1.5.1.0")]
55+
[assembly: AssemblyVersion("1.5.2.0")]
56+
[assembly: AssemblyFileVersion("1.5.2.0")]
-124 KB
Binary file not shown.

0 commit comments

Comments
 (0)