diff --git a/Source/HDRController/HDRController/HDRController.cpp b/Source/HDRController/HDRController/HDRController.cpp index 410fa41..c2ca9b3 100644 --- a/Source/HDRController/HDRController/HDRController.cpp +++ b/Source/HDRController/HDRController/HDRController.cpp @@ -202,47 +202,77 @@ static void SetHDR(UINT32 uid, bool enabled) static SIZE _GetResolution(UINT32 uid) { + + + uint8_t set[] = { 0x0A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x14, 0x81, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; + + uint8_t request[] = { 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x7C, 0x6F, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0xDB, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 }; + SIZE resolution = SIZE(); + bool returnValue = false; + uint32_t pathCount, modeCount; - UINT32 numPathArrayElements = 0, numModeInfoArrayElements = 0; - UINT32 filter = QDC_ALL_PATHS; + if (ERROR_SUCCESS == GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount)) { + DISPLAYCONFIG_PATH_INFO* pathsArray = nullptr; + DISPLAYCONFIG_MODE_INFO* modesArray = nullptr; const size_t sizePathsArray = pathCount * sizeof(DISPLAYCONFIG_PATH_INFO); const size_t sizeModesArray = modeCount * sizeof(DISPLAYCONFIG_MODE_INFO); + pathsArray = static_cast(std::malloc(sizePathsArray)); + modesArray = static_cast(std::malloc(sizeModesArray)); - DISPLAYCONFIG_PATH_INFO* pathsArray = new DISPLAYCONFIG_PATH_INFO[pathCount]; - DISPLAYCONFIG_MODE_INFO* modesArray = new DISPLAYCONFIG_MODE_INFO[modeCount]; - + if (pathsArray != nullptr && modesArray != nullptr) + { + std::memset(pathsArray, 0, sizePathsArray); + std::memset(modesArray, 0, sizeModesArray); - ZeroMemory(pathsArray, sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); - ZeroMemory(modesArray, sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); - QueryDisplayConfig(filter, &pathCount, pathsArray, &modeCount, modesArray, NULL); + if (ERROR_SUCCESS == QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, pathsArray, + &modeCount, modesArray, 0)) + { + DISPLAYCONFIG_DEVICE_INFO_HEADER* setPacket = + reinterpret_cast(set); + DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket = + reinterpret_cast(request); + //HDR is off + returnValue = false; + for (int i = 0; i < modeCount; i++) + { + try + { + if (modesArray[i].id == uid) + { + setPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart; + setPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart; + setPacket->id = modesArray[i].id; - for (short i = 0; i < pathCount; i++) - { - try - { - int ix = pathsArray[i].sourceInfo.modeInfoIdx; //assuming path[0] is primary + requestPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart; + requestPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart; + requestPacket->id = modesArray[i].id; + DISPLAYCONFIG_MODE_INFO mode = modesArray[i]; + resolution.cx = mode.sourceMode.width; + resolution.cy = mode.sourceMode.height; + } + } + catch (const std::exception&) + { - if (modesArray[ix].id != uid) + } - { - resolution.cx = modesArray[ix].sourceMode.width; - resolution.cy = modesArray[ix].sourceMode.height; - SetDisplayConfig(pathCount, pathsArray, modeCount, modesArray, SDC_APPLY | SDC_USE_SUPPLIED_DISPLAY_CONFIG | SDC_ALLOW_CHANGES | SDC_SAVE_TO_DATABASE); } } - catch (const std::exception&) - { - - } + std::free(pathsArray); + std::free(modesArray); + return resolution; } } - return resolution; + } static bool HDRIsOn(UINT32 uid) diff --git a/Source/HDRProfile/AutoHDR.csproj b/Source/HDRProfile/AutoHDR.csproj index 90590fe..20cd9c6 100644 --- a/Source/HDRProfile/AutoHDR.csproj +++ b/Source/HDRProfile/AutoHDR.csproj @@ -175,11 +175,14 @@ Externals\Windows.winmd + False + + diff --git a/Source/HDRProfile/Costura64/HDRController.dll b/Source/HDRProfile/Costura64/HDRController.dll index a26c629..5f1c658 100644 Binary files a/Source/HDRProfile/Costura64/HDRController.dll and b/Source/HDRProfile/Costura64/HDRController.dll differ diff --git a/Source/HDRProfile/DispatchingObservableCollection.cs b/Source/HDRProfile/DispatchingObservableCollection.cs new file mode 100644 index 0000000..2dd209c --- /dev/null +++ b/Source/HDRProfile/DispatchingObservableCollection.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Threading; + +namespace AutoHDR +{ + /// + /// This class is an observablecollection which invokes automatically. + /// This means that any change will be done in the right thread. + /// + /// The type of the elements + public class DispatchingObservableCollection : ObservableCollection + { + /// + /// The default constructor of the ObservableCollection + /// + public DispatchingObservableCollection() + { + //Assign the current Dispatcher (owner of the collection) + _currentDispatcher = Dispatcher.CurrentDispatcher; + } + + private readonly Dispatcher _currentDispatcher; + + /// + /// Executes this action in the right thread + /// + ///The action which should be executed + private void DoDispatchedAction(Action action) + { + if (_currentDispatcher.CheckAccess()) + action.Invoke(); + else + _currentDispatcher.Invoke(DispatcherPriority.DataBind, action); + } + + /// + /// Clears all items + /// + protected override void ClearItems() + { + DoDispatchedAction(BaseClearItems); + } + + private void BaseClearItems() + { + base.ClearItems(); + } + + /// + /// Inserts a item at the specified index + /// + ///The index where the item should be inserted + ///The item which should be inserted + protected override void InsertItem(int index, T item) + { + DoDispatchedAction(() => BaseInsertItem(index, item)); + } + + private void BaseInsertItem(int index, T item) + { + base.InsertItem(index, item); + } + + /// + /// Moves an item from one index to another + /// + ///The index of the item which should be moved + ///The index where the item should be moved + protected override void MoveItem(int oldIndex, int newIndex) + { + DoDispatchedAction(() => BaseMoveItem(oldIndex, newIndex)); + } + + private void BaseMoveItem(int oldIndex, int newIndex) + { + base.MoveItem(oldIndex, newIndex); + } + + /// + /// Removes the item at the specified index + /// + ///The index of the item which should be removed + protected override void RemoveItem(int index) + { + DoDispatchedAction(() => BaseRemoveItem(index)); + } + + private void BaseRemoveItem(int index) + { + base.RemoveItem(index); + } + + /// + /// Sets the item at the specified index + /// + ///The index which should be set + ///The new item + protected override void SetItem(int index, T item) + { + DoDispatchedAction(() => BaseSetItem(index, item)); + } + + private void BaseSetItem(int index, T item) + { + base.SetItem(index, item); + } + + /// + /// Fires the CollectionChanged Event + /// + ///The additional arguments of the event + protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + DoDispatchedAction(() => BaseOnCollectionChanged(e)); + } + + private void BaseOnCollectionChanged(NotifyCollectionChangedEventArgs e) + { + base.OnCollectionChanged(e); + } + + /// + /// Fires the PropertyChanged Event + /// + ///The additional arguments of the event + protected override void OnPropertyChanged(PropertyChangedEventArgs e) + { + DoDispatchedAction(() => BaseOnPropertyChanged(e)); + } + + private void BaseOnPropertyChanged(PropertyChangedEventArgs e) + { + base.OnPropertyChanged(e); + } + } +} diff --git a/Source/HDRProfile/Displays/Display.cs b/Source/HDRProfile/Displays/Display.cs index d4fc66e..b5ca371 100644 --- a/Source/HDRProfile/Displays/Display.cs +++ b/Source/HDRProfile/Displays/Display.cs @@ -14,18 +14,30 @@ namespace AutoHDR.Displays [JsonObject(MemberSerialization.OptIn)] public class Display : BaseViewModel { - public static readonly Display AllDisplays = new Display(ProjectResources.Locale_Texts.AllDisplays, UInt32.MaxValue, UInt32.MaxValue, new Size(0, 0),0,0); + public static readonly Display AllDisplays = new Display(ProjectResources.Locale_Texts.AllDisplays, UInt32.MaxValue); private bool _managed = true; [JsonProperty] public bool Managed { get => _managed; set { _managed = value; OnPropertyChanged(); } } + private bool _isPrimary; + + [JsonProperty] + public bool IsPrimary { get => _isPrimary; set { _isPrimary = value; OnPropertyChanged(); } } + private string _name; [JsonProperty] public string Name { get => _name; set { _name = value; OnPropertyChanged(); } } + private string _graphicsCard; + + public string GraphicsCard { get => _graphicsCard; set { _graphicsCard = value; OnPropertyChanged(); } } + + private string _deviceKey; + + public string DeviceKey { get => _deviceKey; set { _deviceKey = value; OnPropertyChanged(); } } private UInt32 _uid; @@ -35,7 +47,7 @@ public class Display : BaseViewModel private uint _id; [JsonProperty] - public uint ID { get => _id; private set { _id = value; OnPropertyChanged(); } } + public uint ID { get => _id; set { _id = value; OnPropertyChanged(); } } private bool _hdrState; @@ -61,14 +73,22 @@ private Display() } - public Display(string name, uint uID, uint id, Size resolution, int refreshRate, int colorDepth) + public Display(DisplayInformation displayInformation, uint uid) + { + Name = displayInformation.DisplayDevice.DeviceName; + UID = uid; + ID = displayInformation.Id; + IsPrimary = displayInformation.IsPrimary; + DeviceKey = displayInformation.DisplayDevice.DeviceKey; + Resolution = new Size(displayInformation.Devmode.dmPelsWidth, displayInformation.Devmode.dmPelsHeight); + RefreshRate = displayInformation.Devmode.dmDisplayFrequency; + GraphicsCard = displayInformation.DisplayDevice.DeviceString; + } + + public Display(string name, uint uid) { - Name = name ?? throw new ArgumentNullException(nameof(name)); - UID = uID; - ID = id; - Resolution = resolution; - RefreshRate = refreshRate; - ColorDepth = colorDepth; + Name = name; + UID = uid; } public void UpdateHDRState() diff --git a/Source/HDRProfile/Displays/DisplayInformation.cs b/Source/HDRProfile/Displays/DisplayInformation.cs new file mode 100644 index 0000000..3411693 --- /dev/null +++ b/Source/HDRProfile/Displays/DisplayInformation.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutoHDR.Displays +{ + public class DisplayInformation + { + public uint Id { get; private set; } + public DISPLAY_DEVICE DisplayDevice { get; private set; } + public DEVMODE Devmode { get; private set; } + public bool IsPrimary => DisplayDevice.StateFlags.HasFlag(DisplayDeviceStateFlags.PrimaryDevice); + + public DisplayInformation(uint id, DISPLAY_DEVICE displayDevice, DEVMODE devmode) : this(id, displayDevice) + { + Devmode = devmode; + } + + public DisplayInformation(uint id, DISPLAY_DEVICE displayDevice) + { + Id = id; + DisplayDevice = displayDevice; + } + } +} diff --git a/Source/HDRProfile/Displays/DisplayInterop.cs b/Source/HDRProfile/Displays/DisplayInterop.cs index ce5a921..43d5ce6 100644 --- a/Source/HDRProfile/Displays/DisplayInterop.cs +++ b/Source/HDRProfile/Displays/DisplayInterop.cs @@ -29,7 +29,7 @@ internal static extern int EnumDisplaySettings( } [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - internal struct DEVMODE + public struct DEVMODE { public const int CCHDEVICENAME = 32; public const int CCHFORMNAME = 32; @@ -102,7 +102,7 @@ internal struct DEVMODE } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct DISPLAY_DEVICE + public struct DISPLAY_DEVICE { [MarshalAs(UnmanagedType.U4)] public int cb; @@ -119,7 +119,7 @@ internal struct DISPLAY_DEVICE } [StructLayout(LayoutKind.Sequential)] - struct POINTL + public struct POINTL { long x; long y; @@ -138,7 +138,7 @@ enum DISP_CHANGE : int } [Flags()] - enum DisplayDeviceStateFlags : int + public enum DisplayDeviceStateFlags : int { AttachedToDesktop = 0x1, MultiDriver = 0x2, @@ -169,7 +169,7 @@ enum DisplaySettingsFlags : int } [Flags()] - enum DM : int + public enum DM : int { Orientation = 0x1, PaperSize = 0x2, diff --git a/Source/HDRProfile/Displays/DisplayManager.cs b/Source/HDRProfile/Displays/DisplayManager.cs index 2d5b69f..84430c2 100644 --- a/Source/HDRProfile/Displays/DisplayManager.cs +++ b/Source/HDRProfile/Displays/DisplayManager.cs @@ -12,12 +12,12 @@ using System.Text; using System.Threading; +using System.Windows.Threading; namespace AutoHDR.Displays { public class DisplayManager : BaseViewModel { - Thread _updateThread = null; readonly object _threadControlLock = new object(); bool _monitorCancelRequested = false; @@ -36,7 +36,7 @@ private DisplayManager() public bool Monitoring { get; private set; } = false; - public UserAppSettings Settings { get; private set; } + public UserAppSettings Settings { get; private set; } public ObservableCollection Monitors => Settings.Monitors; @@ -54,6 +54,7 @@ public void StartMonitoring() if (Monitoring) return; _updateThread = new Thread(UpdateMonitorLoop); + _updateThread.SetApartmentState(ApartmentState.STA); _updateThread.IsBackground = true; Monitoring = true; _monitorCancelRequested = false; @@ -78,24 +79,35 @@ private void UpdateMonitorLoop() { while (!_monitorCancelRequested) { - bool currentValue = false; - MergeMonitors(GetActiveMonitors()); - foreach (Display monitor in Monitors) + try { - monitor.UpdateHDRState(); - if (monitor.Managed) - currentValue = currentValue || monitor.HDRState; - monitor.Resolution = GetResolution(monitor.ID); - monitor.RefreshRate = GetRefreshRate(monitor.ID); - + bool currentValue = false; + Dispatcher.CurrentDispatcher.Invoke(() => + { + MergeMonitors(GetActiveMonitors()); + }); + foreach (Display monitor in Monitors) + { + monitor.UpdateHDRState(); + if (monitor.Managed) + currentValue = currentValue || monitor.HDRState; + monitor.Resolution = GetResolution(monitor.UID); + monitor.RefreshRate = GetRefreshRate(monitor.ID); + + } + bool changed = GlobalHDRIsActive != currentValue; + GlobalHDRIsActive = currentValue; + if (changed) + { + try { HDRIsActiveChanged?.Invoke(null, EventArgs.Empty); } catch { } + } + System.Threading.Thread.Sleep(100); } - bool changed = GlobalHDRIsActive != currentValue; - GlobalHDRIsActive = currentValue; - if (changed) + catch (Exception ex) { - try { HDRIsActiveChanged?.Invoke(null, EventArgs.Empty); } catch { } + Globals.Logs.AddException(ex); + throw; } - System.Threading.Thread.Sleep(100); } } @@ -112,8 +124,8 @@ private void ChangeDisplaySetting(uint deviceID, Func func) d.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) { - dm= func.Invoke(dm); - + dm = func.Invoke(dm); + DISP_CHANGE iRet = NativeMethods.ChangeDisplaySettingsEx( d.DeviceName, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); @@ -198,7 +210,6 @@ public int GetRefreshRate(uint deviceID) DEVMODE dm = new DEVMODE(); d.cb = Marshal.SizeOf(d); - NativeMethods.EnumDisplayDevices(null, deviceID, ref d, 0); if (0 != NativeMethods.EnumDisplaySettings( @@ -210,42 +221,37 @@ public int GetRefreshRate(uint deviceID) else return 0; } - - public static List GetActiveMonitors() + public static List GetActiveMonitors() { List monitors = new List(); - DisplayConfigTopologyId topologyId; var pathWraps = GetPathWraps(QueryDisplayFlags.OnlyActivePaths, out topologyId); + List _interopDisplays = new List(); + DISPLAY_DEVICE d = new DISPLAY_DEVICE(); + DEVMODE dm = new DEVMODE(); + d.cb = Marshal.SizeOf(d); + + uint deviceID = 0; + while (NativeMethods.EnumDisplayDevices(null, deviceID, ref d, 0)) + { + if (0 != NativeMethods.EnumDisplaySettings(d.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) + _interopDisplays.Add(new DisplayInformation(deviceID, d, dm)); + else + _interopDisplays.Add(new DisplayInformation(deviceID, d)); + deviceID++; + } + foreach (var pathWrap in pathWraps) { var path = pathWrap.Path; - var sourceModeInfo = pathWrap.Modes.First(x => x.infoType == DisplayConfigModeInfoType.Source); - - var resolution = new Size - { - Width = sourceModeInfo.sourceMode.width, - Height = sourceModeInfo.sourceMode.height - }; - int colorDepth = 0; - var refreshRate = - (int)Math.Round((double)path.targetInfo.refreshRate.numerator / path.targetInfo.refreshRate.denominator); - var rotationOriginal = path.targetInfo.rotation; - - - DisplayConfigSourceDeviceName displayConfigSourceDeviceName; - - var displayName = ""; - var nameStatus = GetDisplayConfigSourceDeviceName(sourceModeInfo, - out displayConfigSourceDeviceName); - - if (nameStatus == StatusCode.Success) - displayName = displayConfigSourceDeviceName.viewGdiDeviceName; + DisplayInformation displayInformation = _interopDisplays.FirstOrDefault(di => di.Id.Equals(path.sourceInfo.id)); - Display monitor = new Display(displayName, path.targetInfo.id, sourceModeInfo.id, resolution, refreshRate, colorDepth); - monitors.Add(monitor); + Display display = new Display(displayInformation, path.targetInfo.id); + if (!monitors.Any(m => m.ID.Equals(display.ID))) + monitors.Add(display); } + return monitors; } @@ -253,30 +259,42 @@ public static List GetActiveMonitors() private void MergeMonitors(List activeMonitors) { - List toRemove = new List(); - foreach (Display monitor in Monitors) - { - if (!activeMonitors.Any(m => m.UID.Equals(monitor.UID))) - toRemove.Add(monitor); - } - foreach (Display monitor in toRemove) - Monitors.Remove(monitor); - foreach (Display monitor in activeMonitors) + try { - if (!Settings.Monitors.Any(m => m.UID.Equals(monitor.UID))) - Settings.Monitors.Add(monitor); - else + List toRemove = new List(); + foreach (Display monitor in Monitors) + { + if (!activeMonitors.Any(m => m.UID.Equals(monitor.UID))) + toRemove.Add(monitor); + } + foreach (Display monitor in toRemove) + Monitors.Remove(monitor); + foreach (Display monitor in activeMonitors) { - Display existingMonitor = Monitors.First(m => m.UID.Equals(monitor.UID)); - existingMonitor.Name = monitor.Name; - existingMonitor.ColorDepth = monitor.ColorDepth; - existingMonitor.RefreshRate = monitor.RefreshRate; - existingMonitor.Resolution = monitor.Resolution; + if (!Settings.Monitors.Any(m => m.UID.Equals(monitor.UID))) + Settings.Monitors.Add(monitor); + else + { + Display existingMonitor = Monitors.First(m => m.UID.Equals(monitor.UID)); + existingMonitor.Name = monitor.Name; + existingMonitor.ColorDepth = monitor.ColorDepth; + existingMonitor.RefreshRate = monitor.RefreshRate; + existingMonitor.Resolution = monitor.Resolution; + existingMonitor.DeviceKey = monitor.DeviceKey; + existingMonitor.GraphicsCard = monitor.GraphicsCard; + existingMonitor.ID = monitor.ID; + existingMonitor.IsPrimary = monitor.IsPrimary; + + } } } + catch (Exception ex) + { + Globals.Logs.AddException(ex); + } } - + public void ActivateHDR() @@ -401,8 +419,5 @@ private static StatusCode GetDisplayConfigSourceDeviceName( }; return Wrapper.DisplayConfigGetDeviceInfo(ref displayConfigSourceDeviceName); } - } } - - diff --git a/Source/HDRProfile/Displays/HDRController.cs b/Source/HDRProfile/Displays/HDRController.cs index d220af8..b1edcf9 100644 --- a/Source/HDRProfile/Displays/HDRController.cs +++ b/Source/HDRProfile/Displays/HDRController.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using System.Runtime.InteropServices; +using System.Drawing; namespace AutoHDR.Displays { @@ -27,7 +28,7 @@ public static class HDRController [DllImport("HDRController.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern bool GetResolution(UInt32 uid); + public static extern Size GetResolution(UInt32 uid); } } diff --git a/Source/HDRProfile/Profiles/Actions/CloseProgramAction.cs b/Source/HDRProfile/Profiles/Actions/CloseProgramAction.cs index 8bf16c7..953a8c4 100644 --- a/Source/HDRProfile/Profiles/Actions/CloseProgramAction.cs +++ b/Source/HDRProfile/Profiles/Actions/CloseProgramAction.cs @@ -32,7 +32,6 @@ public class CloseProgramAction : ProfileActionBase public bool Force { get => _force; set { _force = value; OnPropertyChanged(); } } - public override string ActionDescription => $"{Locale_Texts.Close} {ProcessName}"; public RelayCommand GetFileCommand { get; private set; } @@ -53,7 +52,7 @@ public override ActionEndResult RunAction(params object[] parameter) CallNewLog(new LogEntry($"Searching for{ProcessName}...")); string searchName = ProcessName; if (searchName.ToUpperInvariant().EndsWith(".EXE")) - searchName.Substring(0, searchName.Length - 4); + searchName = searchName.Substring(0, searchName.Length - 4); foreach (Process process in runningProcesses) { if (process.ProcessName == searchName) diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs b/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs index 86da6ba..2cbef3b 100644 --- a/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs +++ b/Source/HDRProfile/ProjectResources/Locale_Texts.Designer.cs @@ -384,6 +384,15 @@ public static string DeviceID { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die UID ähnelt. + /// + public static string DeviceUID { + get { + return ResourceManager.GetString("DeviceUID", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Display ähnelt. /// @@ -501,6 +510,15 @@ public static string GlobalAutoHDR { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Graphics card ähnelt. + /// + public static string GraphicsCard { + get { + return ResourceManager.GetString("GraphicsCard", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die HDR ähnelt. /// @@ -546,6 +564,15 @@ public static string InputDevice { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Primary ähnelt. + /// + public static string IsPrimaryMonitor { + get { + return ResourceManager.GetString("IsPrimaryMonitor", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Last action ähnelt. /// diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx b/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx index 7554d5f..7e9dadd 100644 --- a/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx +++ b/Source/HDRProfile/ProjectResources/Locale_Texts.de.resx @@ -219,6 +219,9 @@ Geräte ID + + UID + Displayaktion @@ -252,6 +255,9 @@ Automatischer HDR-Modus für alle Monitore verwenden + + Grafikkarte + HDR @@ -267,6 +273,9 @@ Eingangsgerät + + Hauptmonitor + Letzte Aktion diff --git a/Source/HDRProfile/ProjectResources/Locale_Texts.resx b/Source/HDRProfile/ProjectResources/Locale_Texts.resx index 0a2c0f6..e423fcc 100644 --- a/Source/HDRProfile/ProjectResources/Locale_Texts.resx +++ b/Source/HDRProfile/ProjectResources/Locale_Texts.resx @@ -225,6 +225,9 @@ Device ID + + UID + Display @@ -264,6 +267,9 @@ Use automated HDR Mode for all monitors + + Graphics card + HDR @@ -279,6 +285,9 @@ Input device + + Primary + Last action diff --git a/Source/HDRProfile/Properties/AssemblyInfo.cs b/Source/HDRProfile/Properties/AssemblyInfo.cs index fffe92f..20eff7d 100644 --- a/Source/HDRProfile/Properties/AssemblyInfo.cs +++ b/Source/HDRProfile/Properties/AssemblyInfo.cs @@ -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.7.16.0")] -[assembly: AssemblyFileVersion("1.7.16.0")] +[assembly: AssemblyVersion("1.7.17.0")] +[assembly: AssemblyFileVersion("1.7.17.0")] diff --git a/Source/HDRProfile/UWP/UWPAppsManager.cs b/Source/HDRProfile/UWP/UWPAppsManager.cs index 97966ec..1f6fef0 100644 --- a/Source/HDRProfile/UWP/UWPAppsManager.cs +++ b/Source/HDRProfile/UWP/UWPAppsManager.cs @@ -7,11 +7,9 @@ using System.Management.Automation; using System.Security.Permissions; using System.Security.Principal; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using Windows.ApplicationModel; + using Windows.Management.Deployment; +using Windows.ApplicationModel; namespace AutoHDR.UWP { diff --git a/Source/HDRProfile/UserAppSettings.cs b/Source/HDRProfile/UserAppSettings.cs index 046668f..19c3e68 100644 --- a/Source/HDRProfile/UserAppSettings.cs +++ b/Source/HDRProfile/UserAppSettings.cs @@ -26,8 +26,8 @@ public class UserAppSettings : BaseViewModel private Guid _defaultProfileGuid = Guid.Empty; private SortableObservableCollection _applicationProfileAssignments; - private ObservableCollection _applicationProfiles; - private ObservableCollection _monitors; + private DispatchingObservableCollection _applicationProfiles; + private DispatchingObservableCollection _monitors; [JsonProperty] @@ -59,18 +59,18 @@ public class UserAppSettings : BaseViewModel public SortableObservableCollection ApplicationProfileAssignments { get => _applicationProfileAssignments; set { _applicationProfileAssignments = value; OnPropertyChanged(); } } [JsonProperty(Order = 1)] - public ObservableCollection ApplicationProfiles { get => _applicationProfiles; set { _applicationProfiles = value; OnPropertyChanged(); } } + public DispatchingObservableCollection ApplicationProfiles { get => _applicationProfiles; set { _applicationProfiles = value; OnPropertyChanged(); } } [JsonProperty] - public ObservableCollection Monitors { get => _monitors; set { _monitors = value; OnPropertyChanged(); } } + public DispatchingObservableCollection Monitors { get => _monitors; set { _monitors = value; OnPropertyChanged(); } } public UserAppSettings() { ApplicationProfileAssignments = new SortableObservableCollection(new ObservableCollection()); - ApplicationProfiles = new ObservableCollection(); - Monitors = new ObservableCollection(); + ApplicationProfiles = new DispatchingObservableCollection(); + Monitors = new DispatchingObservableCollection(); } public static UserAppSettings ReadSettings(string path) diff --git a/Source/HDRProfile/Views/AutoHDRMainView.xaml b/Source/HDRProfile/Views/AutoHDRMainView.xaml index 6d5452e..1a82e61 100644 --- a/Source/HDRProfile/Views/AutoHDRMainView.xaml +++ b/Source/HDRProfile/Views/AutoHDRMainView.xaml @@ -12,8 +12,7 @@ xmlns:root="clr-namespace:AutoHDR" mc:Ignorable="d" Title="AutoHDR" Name="MainWindow" MinHeight="480" MinWidth="480" Closing="Window_Closing" Visibility="{Binding ShowView, Mode=TwoWay, Converter={StaticResource VisibilityBooleanConverter}}" - Height="600" - Width="700" Loaded="MainWindow_Loaded"> + Loaded="MainWindow_Loaded"> diff --git a/Source/HDRProfile/Views/DisplayManagerView.xaml b/Source/HDRProfile/Views/DisplayManagerView.xaml index af967b7..f049174 100644 --- a/Source/HDRProfile/Views/DisplayManagerView.xaml +++ b/Source/HDRProfile/Views/DisplayManagerView.xaml @@ -29,25 +29,36 @@ - + + - + - - + + + + + + + + + - - + - - - + - + + + + + + + - + + + + + + +