Skip to content

Commit

Permalink
1.9.5
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
Codectory committed Jan 12, 2022
1 parent 2eece06 commit 364b914
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 59 deletions.
19 changes: 8 additions & 11 deletions Source/AutoHDR.Displays/Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace AutoHDR.Displays
[JsonObject(MemberSerialization.OptIn)]
public class Display : BaseViewModel
{
public static readonly Display AllDisplays = new Display(Locale.AllDisplays, UInt32.MaxValue);
public static readonly Display AllDisplays = new Display(Locale.AllDisplays, UInt32.MaxValue, UInt32.MaxValue);
private bool _managed = true;

[JsonProperty]
Expand All @@ -37,7 +37,11 @@ public class Display : BaseViewModel
private UInt32 _uid;

[JsonProperty]
public UInt32 UID { get => _uid; set { _uid = value; OnPropertyChanged(); } }
public UInt32 UID
{
get => _uid;
set { _uid = value; OnPropertyChanged(); }
}

private uint _id;

Expand Down Expand Up @@ -81,20 +85,13 @@ public Display(DisplayInformation monitorInformation, uint uid)
GraphicsCard = monitorInformation.DisplayDevice.DeviceString;
}

public Display(string name, uint uid)
public Display(string name, uint uid, uint id)
{
Name = name;
UID = uid;
ID = id;
}

public Display(uint iD, uint uID, bool isPrimary, string name, string graphicsCard)
{
IsPrimary = isPrimary;
Name = name;
GraphicsCard = graphicsCard;
UID = uID;
ID = iD;
}

public void UpdateHDRState()
{
Expand Down
34 changes: 0 additions & 34 deletions Source/AutoHDR.Displays/DisplayManagerNvidia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,6 @@ public override List<Display> GetActiveMonitors()
return displays;
}

public List<Display> GetActiveMonitors2()
{
List<Display> displays = new List<Display>();
DisplayHandle[] handles = DisplayApi.EnumNvidiaDisplayHandle();
IPathInfo[] config = DisplayApi.GetDisplayConfig();
for (int i = 0; i < handles.Length; i++)
{
string displayName = DisplayApi.GetAssociatedNvidiaDisplayName(handles[i]);
uint displayID = DisplayApi.GetDisplayIdByDisplayName(displayName);
IPathInfo pathInfo = config.First(p => p.TargetsInfo.ToList().First().DisplayId == displayID);

DisplayDevice displayDevice = new DisplayDevice(displayID);
if (displayDevice.IsActive)
{
uint id = pathInfo.SourceId;
uint uid = 0;
if (Displays.Any(m => m.Tag != null && displayDevice.DisplayId.Equals(((DisplayDevice)m.Tag).DisplayId)))
uid = Displays.First(m => displayDevice.DisplayId.Equals(((DisplayDevice)m.Tag).DisplayId)).UID;
else
uid = GetUID(id);
bool isPrimary = pathInfo.SourceModeInfo.IsGDIPrimary;
string name = displayName;
string graphicsCard = displayDevice.Output.PhysicalGPU.FullName;
Display display = new Display(id, uid, isPrimary, name, graphicsCard);
display.Tag = displayDevice;
display.Resolution = new Size(displayDevice.CurrentTiming.HorizontalActive, displayDevice.CurrentTiming.VerticalActive);
display.RefreshRate = GetRefreshRate(display);
display.ColorDepth = GetColorDepth(display);
displays.Add(display);

}
}
return displays;
}

public override void SetColorDepth(Display display, ColorDepth colorDepth)
{
Expand Down
8 changes: 5 additions & 3 deletions Source/AutoHDR/AutoHDRDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,11 @@ private void Shutdown()
ApplicationWatcher.NewLog -= ApplicationWatcher_NewLog;
ApplicationWatcher.ApplicationChanged -= ApplicationWatcher_ApplicationChanged;
Stop();
// TrayMenuHelper.SwitchTrayIcon(false);
try
{
TrayMenuHelper.SwitchTrayIcon(false);
}
catch {}
Application.Current.Shutdown();
}

Expand Down Expand Up @@ -651,8 +655,6 @@ private void ApplicationProfiles_CollectionChanged(object sender, NotifyCollecti
}
break;
}


Globals.Instance.SaveSettings();

}
Expand Down
6 changes: 5 additions & 1 deletion Source/AutoHDR/ProfileActionShortcut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public class ProfileActionShortcut : BaseViewModel
private IProfileAction _action;

[JsonProperty]
public IProfileAction Action { get => _action; set { _action = value; OnPropertyChanged(); } }
public IProfileAction Action
{
get => _action;
set { _action = value; OnPropertyChanged(); }
}

private string _shortcutName;

Expand Down
35 changes: 27 additions & 8 deletions Source/AutoHDR/Profiles/Actions/DisplayAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,43 @@ public List<Display> AllDisplays
return displays;
}
}
private Display _display = null;

private uint _displayUID = uint.MaxValue;

[JsonProperty]
public uint DisplayUID
{
get => _displayUID;
set
{
_displayUID = value;
OnPropertyChanged();
OnPropertyChanged(nameof(Display));
try
{
Resolution = Display.Resolution;
RefreshRate = Display.RefreshRate;
}
catch (Exception)
{ }

}
}

private Display _display = null;

public Display Display
{
get => _display;
get => AllDisplays.FirstOrDefault(d => d.UID.Equals(DisplayUID));
set
{
_display = value;
OnPropertyChanged();
DisplayUID = value.UID;

Resolution = value.Resolution;
RefreshRate = value.RefreshRate;
}
}
public override string ActionTypeName => ProjectResources.ProjectLocales.DisplayAction;


public override string ActionTypeName => ProjectResources.ProjectLocales.DisplayAction;


private bool _changeHDR = false;
[JsonProperty]
Expand Down
4 changes: 2 additions & 2 deletions Source/AutoHDR/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyFileVersion("1.9.4.0")]
[assembly: AssemblyVersion("1.9.5.0")]
[assembly: AssemblyFileVersion("1.9.5.0")]

0 comments on commit 364b914

Please sign in to comment.