Skip to content

Commit 364b914

Browse files
committed
1.9.5
[Bug fixes] - Display selection in display actions reverts to "All display" (Won't save profiles. (Ver 1.94) #92) - Tray icon is still visible after closing AutoHDR
1 parent 2eece06 commit 364b914

File tree

6 files changed

+47
-59
lines changed

6 files changed

+47
-59
lines changed

Source/AutoHDR.Displays/Display.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace AutoHDR.Displays
1414
[JsonObject(MemberSerialization.OptIn)]
1515
public class Display : BaseViewModel
1616
{
17-
public static readonly Display AllDisplays = new Display(Locale.AllDisplays, UInt32.MaxValue);
17+
public static readonly Display AllDisplays = new Display(Locale.AllDisplays, UInt32.MaxValue, UInt32.MaxValue);
1818
private bool _managed = true;
1919

2020
[JsonProperty]
@@ -37,7 +37,11 @@ public class Display : BaseViewModel
3737
private UInt32 _uid;
3838

3939
[JsonProperty]
40-
public UInt32 UID { get => _uid; set { _uid = value; OnPropertyChanged(); } }
40+
public UInt32 UID
41+
{
42+
get => _uid;
43+
set { _uid = value; OnPropertyChanged(); }
44+
}
4145

4246
private uint _id;
4347

@@ -81,20 +85,13 @@ public Display(DisplayInformation monitorInformation, uint uid)
8185
GraphicsCard = monitorInformation.DisplayDevice.DeviceString;
8286
}
8387

84-
public Display(string name, uint uid)
88+
public Display(string name, uint uid, uint id)
8589
{
8690
Name = name;
8791
UID = uid;
92+
ID = id;
8893
}
8994

90-
public Display(uint iD, uint uID, bool isPrimary, string name, string graphicsCard)
91-
{
92-
IsPrimary = isPrimary;
93-
Name = name;
94-
GraphicsCard = graphicsCard;
95-
UID = uID;
96-
ID = iD;
97-
}
9895

9996
public void UpdateHDRState()
10097
{

Source/AutoHDR.Displays/DisplayManagerNvidia.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,6 @@ public override List<Display> GetActiveMonitors()
3838
return displays;
3939
}
4040

41-
public List<Display> GetActiveMonitors2()
42-
{
43-
List<Display> displays = new List<Display>();
44-
DisplayHandle[] handles = DisplayApi.EnumNvidiaDisplayHandle();
45-
IPathInfo[] config = DisplayApi.GetDisplayConfig();
46-
for (int i = 0; i < handles.Length; i++)
47-
{
48-
string displayName = DisplayApi.GetAssociatedNvidiaDisplayName(handles[i]);
49-
uint displayID = DisplayApi.GetDisplayIdByDisplayName(displayName);
50-
IPathInfo pathInfo = config.First(p => p.TargetsInfo.ToList().First().DisplayId == displayID);
51-
52-
DisplayDevice displayDevice = new DisplayDevice(displayID);
53-
if (displayDevice.IsActive)
54-
{
55-
uint id = pathInfo.SourceId;
56-
uint uid = 0;
57-
if (Displays.Any(m => m.Tag != null && displayDevice.DisplayId.Equals(((DisplayDevice)m.Tag).DisplayId)))
58-
uid = Displays.First(m => displayDevice.DisplayId.Equals(((DisplayDevice)m.Tag).DisplayId)).UID;
59-
else
60-
uid = GetUID(id);
61-
bool isPrimary = pathInfo.SourceModeInfo.IsGDIPrimary;
62-
string name = displayName;
63-
string graphicsCard = displayDevice.Output.PhysicalGPU.FullName;
64-
Display display = new Display(id, uid, isPrimary, name, graphicsCard);
65-
display.Tag = displayDevice;
66-
display.Resolution = new Size(displayDevice.CurrentTiming.HorizontalActive, displayDevice.CurrentTiming.VerticalActive);
67-
display.RefreshRate = GetRefreshRate(display);
68-
display.ColorDepth = GetColorDepth(display);
69-
displays.Add(display);
70-
71-
}
72-
}
73-
return displays;
74-
}
7541

7642
public override void SetColorDepth(Display display, ColorDepth colorDepth)
7743
{

Source/AutoHDR/AutoHDRDaemon.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,11 @@ private void Shutdown()
439439
ApplicationWatcher.NewLog -= ApplicationWatcher_NewLog;
440440
ApplicationWatcher.ApplicationChanged -= ApplicationWatcher_ApplicationChanged;
441441
Stop();
442-
// TrayMenuHelper.SwitchTrayIcon(false);
442+
try
443+
{
444+
TrayMenuHelper.SwitchTrayIcon(false);
445+
}
446+
catch {}
443447
Application.Current.Shutdown();
444448
}
445449

@@ -651,8 +655,6 @@ private void ApplicationProfiles_CollectionChanged(object sender, NotifyCollecti
651655
}
652656
break;
653657
}
654-
655-
656658
Globals.Instance.SaveSettings();
657659

658660
}

Source/AutoHDR/ProfileActionShortcut.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public class ProfileActionShortcut : BaseViewModel
1616
private IProfileAction _action;
1717

1818
[JsonProperty]
19-
public IProfileAction Action { get => _action; set { _action = value; OnPropertyChanged(); } }
19+
public IProfileAction Action
20+
{
21+
get => _action;
22+
set { _action = value; OnPropertyChanged(); }
23+
}
2024

2125
private string _shortcutName;
2226

Source/AutoHDR/Profiles/Actions/DisplayAction.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,43 @@ public List<Display> AllDisplays
2929
return displays;
3030
}
3131
}
32-
private Display _display = null;
32+
33+
private uint _displayUID = uint.MaxValue;
3334

3435
[JsonProperty]
36+
public uint DisplayUID
37+
{
38+
get => _displayUID;
39+
set
40+
{
41+
_displayUID = value;
42+
OnPropertyChanged();
43+
OnPropertyChanged(nameof(Display));
44+
try
45+
{
46+
Resolution = Display.Resolution;
47+
RefreshRate = Display.RefreshRate;
48+
}
49+
catch (Exception)
50+
{ }
51+
52+
}
53+
}
54+
55+
private Display _display = null;
56+
3557
public Display Display
3658
{
37-
get => _display;
59+
get => AllDisplays.FirstOrDefault(d => d.UID.Equals(DisplayUID));
3860
set
3961
{
40-
_display = value;
41-
OnPropertyChanged();
62+
DisplayUID = value.UID;
4263

43-
Resolution = value.Resolution;
44-
RefreshRate = value.RefreshRate;
4564
}
4665
}
47-
public override string ActionTypeName => ProjectResources.ProjectLocales.DisplayAction;
4866

49-
67+
public override string ActionTypeName => ProjectResources.ProjectLocales.DisplayAction;
68+
5069

5170
private bool _changeHDR = false;
5271
[JsonProperty]

Source/AutoHDR/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.9.4.0")]
56-
[assembly: AssemblyFileVersion("1.9.4.0")]
55+
[assembly: AssemblyVersion("1.9.5.0")]
56+
[assembly: AssemblyFileVersion("1.9.5.0")]

0 commit comments

Comments
 (0)