[WIP] trying to fix path error

This commit is contained in:
Terry MacDonald 2020-10-06 23:49:10 +13:00
parent 95d87e92f1
commit f0088d08e2
6 changed files with 62 additions and 244 deletions

View File

@ -29,7 +29,7 @@ namespace HeliosPlus.Shared
private static List<WindowsDisplayAPI.Display> _availableDisplays; private static List<WindowsDisplayAPI.Display> _availableDisplays;
private static List<WindowsDisplayAPI.UnAttachedDisplay> _unavailableDisplays; private static List<WindowsDisplayAPI.UnAttachedDisplay> _unavailableDisplays;
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus"); internal static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
private string _uuid = ""; private string _uuid = "";
private Version _version; private Version _version;
@ -160,7 +160,7 @@ namespace HeliosPlus.Shared
public string Name { get; set; } public string Name { get; set; }
public ProfileViewport[] Viewports { get; set; } = new ProfileViewport[0]; public Topology.Path[] Viewports { get; set; } = new Topology.Path[0];
[JsonIgnore] [JsonIgnore]
public ProfileIcon ProfileIcon public ProfileIcon ProfileIcon
@ -367,7 +367,7 @@ namespace HeliosPlus.Shared
private static string GetValidFilename(string uncheckedFilename) private static string GetValidFilename(string uncheckedFilename)
{ {
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); string invalid = new string(System.IO.Path.GetInvalidFileNameChars()) + new string(System.IO.Path.GetInvalidPathChars());
foreach (char c in invalid) foreach (char c in invalid)
{ {
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), ""); uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");

View File

@ -26,6 +26,7 @@ using System.Resources;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using NvAPIWrapper.Mosaic; using NvAPIWrapper.Mosaic;
using NvAPIWrapper.Native.Mosaic; using NvAPIWrapper.Native.Mosaic;
using PathInfos = HeliosPlus.Shared.Topology.PathInfo;
namespace HeliosPlus.Shared namespace HeliosPlus.Shared
@ -39,11 +40,11 @@ namespace HeliosPlus.Shared
private static bool _profilesLoaded = false; private static bool _profilesLoaded = false;
public static Version Version = new Version(1, 0, 0); public static Version Version = new Version(1, 0, 0);
// Other constants that are useful // Other constants that are useful
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus"); public static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
public static string AppIconPath = Path.Combine(AppDataPath, $"Icons"); public static string AppIconPath = System.IO.Path.Combine(AppDataPath, $"Icons");
public static string AppHeliosPlusIconFilename = Path.Combine(AppIconPath, @"HeliosPlus.ico"); public static string AppHeliosPlusIconFilename = System.IO.Path.Combine(AppIconPath, @"HeliosPlus.ico");
private static string AppProfileStoragePath = Path.Combine(AppDataPath, $"Profiles"); private static string AppProfileStoragePath = System.IO.Path.Combine(AppDataPath, $"Profiles");
private static string _profileStorageJsonFileName = Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json"); private static string _profileStorageJsonFileName = System.IO.Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json");
private static uint _lastProfileId; private static uint _lastProfileId;
private static ProfileItem _currentProfile; private static ProfileItem _currentProfile;
//private static List<Display> _availableDisplays; //private static List<Display> _availableDisplays;
@ -358,7 +359,7 @@ namespace HeliosPlus.Shared
ProfileItem activeProfile = new ProfileItem ProfileItem activeProfile = new ProfileItem
{ {
Name = "Current Display Profile", Name = "Current Display Profile",
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray() Viewports = PathInfo.GetActivePaths().Select(info => new Path(info)).ToArray()
}; };
activeProfile.ProfileIcon = new ProfileIcon(activeProfile); activeProfile.ProfileIcon = new ProfileIcon(activeProfile);
@ -459,7 +460,7 @@ namespace HeliosPlus.Shared
ProfileItem myCurrentProfile = new ProfileItem ProfileItem myCurrentProfile = new ProfileItem
{ {
Name = "Current Display Profile", Name = "Current Display Profile",
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray() Viewports = PathInfo.GetActivePaths().Select(info => new Path(info)).ToArray()
}; };
_currentProfile = myCurrentProfile; _currentProfile = myCurrentProfile;
@ -484,7 +485,7 @@ namespace HeliosPlus.Shared
ProfileItem myCurrentProfile = new ProfileItem ProfileItem myCurrentProfile = new ProfileItem
{ {
Name = "Current Display Profile", Name = "Current Display Profile",
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray() Viewports = PathInfo.GetActivePaths().Select(info => new Path(info)).ToArray()
}; };
_currentProfile = myCurrentProfile; _currentProfile = myCurrentProfile;
@ -544,7 +545,7 @@ namespace HeliosPlus.Shared
{ {
// Work out the name of the Profile we'll save. // Work out the name of the Profile we'll save.
profile.SavedProfileIconCacheFilename = Path.Combine(AppProfileStoragePath, String.Concat(@"profile-", profile.UUID, @".ico")); profile.SavedProfileIconCacheFilename = System.IO.Path.Combine(AppProfileStoragePath, string.Concat(@"profile-", profile.UUID, @".ico"));
MultiIcon ProfileIcon; MultiIcon ProfileIcon;
try try
@ -562,13 +563,15 @@ namespace HeliosPlus.Shared
} }
} }
public static List<string> GenerateProfileDisplayIdentifiers() public static List<string> GenerateProfileDisplayIdentifiers()
{ {
List<string> displayIdentifiers = new List<string>(); List<string> displayIdentifiers = new List<string>();
// If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers // If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers
NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs(); NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs();
if (myLogicalGPUs.Length == 0) if (myLogicalGPUs.Length > 0)
{ {
foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs) foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs)
@ -626,13 +629,13 @@ namespace HeliosPlus.Shared
if (displayDevices.Count == 0) if (displayDevices.Count == 0)
continue; continue;
/*Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); Debug.WriteLine($"DP : {displayAdapter.DevicePath}");
Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}");
Debug.WriteLine($"DN : {displayAdapter.DeviceName}"); Debug.WriteLine($"DN : {displayAdapter.DeviceName}");
Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}");
Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}"); Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}");
Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}"); Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}");
Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");*/ Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");
foreach (DisplayDevice displayDevice in displayDevices) foreach (DisplayDevice displayDevice in displayDevices)
{ {
@ -644,24 +647,21 @@ namespace HeliosPlus.Shared
if (!displayDevice.IsAvailable) if (!displayDevice.IsAvailable)
continue; continue;
/*Console.WriteLine($"DDA : {displayDevice.Adapter}"); Console.WriteLine($"DDA : {displayDevice.Adapter}");
Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}"); Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}");
Debug.WriteLine($"DDDN : {displayDevice.DeviceName}"); Debug.WriteLine($"DDDN : {displayDevice.DeviceName}");
Debug.WriteLine($"DDDP : {displayDevice.DevicePath}"); Debug.WriteLine($"DDDP : {displayDevice.DevicePath}");
Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}"); Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}");
Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}"); Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}");
Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}"); Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}");
Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");*/ Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");
Debug.WriteLine($"PDSA : {pathDisplaySource.Adapter}");
/*Console.WriteLine($"PDSA : {pathDisplaySource.Adapter}");
Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}"); Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}");
Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}"); Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}");
Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}"); Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}");
Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}"); Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}");
Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");*/ Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");
Debug.WriteLine($"PDTA : {pathDisplayTarget.Adapter}");
/*Console.WriteLine($"PDTA : {pathDisplayTarget.Adapter}");
//Console.WriteLine($"PDTBP : {pathDisplayTarget.BootPersistence}");
Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}"); Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}");
Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}"); Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}");
Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}"); Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}");
@ -672,7 +672,7 @@ namespace HeliosPlus.Shared
Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}"); Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}");
Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}"); Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}");
Debug.WriteLine($"PDTTI : {pathDisplayTarget.TargetId}"); Debug.WriteLine($"PDTTI : {pathDisplayTarget.TargetId}");
Debug.WriteLine($"PDTVRS : {pathDisplayTarget.VirtualResolutionSupport}");*/ Debug.WriteLine($"PDTVRS : {pathDisplayTarget.VirtualResolutionSupport}");
// Create an array of all the important display info we need to record // Create an array of all the important display info we need to record
string[] displayInfo = { string[] displayInfo = {
@ -706,7 +706,7 @@ namespace HeliosPlus.Shared
// If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers // If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers
NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs(); NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs();
if (myLogicalGPUs.Length == 0) if (myLogicalGPUs.Length > 0)
{ {
foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs) foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs)
@ -758,13 +758,13 @@ namespace HeliosPlus.Shared
PathDisplayAdapter pathDisplayAdapter = displayAdapter.ToPathDisplayAdapter(); PathDisplayAdapter pathDisplayAdapter = displayAdapter.ToPathDisplayAdapter();
List<DisplayDevice> displayDevices = displayAdapter.GetDisplayDevices().ToList(); List<DisplayDevice> displayDevices = displayAdapter.GetDisplayDevices().ToList();
/*Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); Debug.WriteLine($"DP : {displayAdapter.DevicePath}");
Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}");
Debug.WriteLine($"DN : {displayAdapter.DeviceName}"); Debug.WriteLine($"DN : {displayAdapter.DeviceName}");
Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}");
Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}"); Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}");
Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}"); Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}");
Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");*/ Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");
foreach (DisplayDevice displayDevice in displayDevices) foreach (DisplayDevice displayDevice in displayDevices)
{ {
@ -772,24 +772,21 @@ namespace HeliosPlus.Shared
PathDisplaySource pathDisplaySource = displayDevice.ToPathDisplaySource(); PathDisplaySource pathDisplaySource = displayDevice.ToPathDisplaySource();
PathDisplayTarget pathDisplayTarget = displayDevice.ToPathDisplayTarget(); PathDisplayTarget pathDisplayTarget = displayDevice.ToPathDisplayTarget();
/*Console.WriteLine($"DDA : {displayDevice.Adapter}"); Debug.WriteLine($"DDA : {displayDevice.Adapter}");
Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}"); Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}");
Debug.WriteLine($"DDDN : {displayDevice.DeviceName}"); Debug.WriteLine($"DDDN : {displayDevice.DeviceName}");
Debug.WriteLine($"DDDP : {displayDevice.DevicePath}"); Debug.WriteLine($"DDDP : {displayDevice.DevicePath}");
Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}"); Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}");
Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}"); Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}");
Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}"); Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}");
Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");*/ Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");
Debug.WriteLine($"PDSA : {pathDisplaySource.Adapter}");
/*Console.WriteLine($"PDSA : {pathDisplaySource.Adapter}");
Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}"); Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}");
Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}"); Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}");
Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}"); Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}");
Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}"); Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}");
Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");*/ Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");
Debug.WriteLine($"PDTA : {pathDisplayTarget.Adapter}");
/*Console.WriteLine($"PDTA : {pathDisplayTarget.Adapter}");
//Console.WriteLine($"PDTBP : {pathDisplayTarget.BootPersistence}");
Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}"); Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}");
Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}"); Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}");
Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}"); Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}");
@ -800,7 +797,7 @@ namespace HeliosPlus.Shared
Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}"); Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}");
Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}"); Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}");
Debug.WriteLine($"PDTTI : {pathDisplayTarget.TargetId}"); Debug.WriteLine($"PDTTI : {pathDisplayTarget.TargetId}");
Debug.WriteLine($"PDTVRS : {pathDisplayTarget.VirtualResolutionSupport}");*/ Debug.WriteLine($"PDTVRS : {pathDisplayTarget.VirtualResolutionSupport}");
// Create an array of all the important display info we need to record // Create an array of all the important display info we need to record
string[] displayInfo = { string[] displayInfo = {
@ -829,7 +826,7 @@ namespace HeliosPlus.Shared
return displayIdentifiers; return displayIdentifiers;
} }
public static bool ApplyTopology(ProfileItem profile) public static bool ApplyTopology(ProfileItem profile)
{ {
Debug.Print("ProfileRepository.ApplyTopology()"); Debug.Print("ProfileRepository.ApplyTopology()");
@ -881,7 +878,12 @@ namespace HeliosPlus.Shared
try try
{ {
// If Nvidia then we need to handle NVidia style
var pathInfos = profile.Viewports.Select(viewport => viewport.ToPathInfo()).Where(info => info != null).ToArray(); var pathInfos = profile.Viewports.Select(viewport => viewport.ToPathInfo()).Where(info => info != null).ToArray();
var test = new NvAPIWrapper.Display.PathInfo;
var v2obj = test.GetPathInfoV2();
WindowsDisplayAPI.DisplayConfig.PathInfo.ApplyPathInfos(pathInfos, true, true, true); WindowsDisplayAPI.DisplayConfig.PathInfo.ApplyPathInfos(pathInfos, true, true, true);
return true; return true;
} }
@ -895,7 +897,7 @@ namespace HeliosPlus.Shared
public static bool IsValidFilename(string testName) public static bool IsValidFilename(string testName)
{ {
string strTheseAreInvalidFileNameChars = new string(Path.GetInvalidFileNameChars()); string strTheseAreInvalidFileNameChars = new string(System.IO.Path.GetInvalidFileNameChars());
Regex regInvalidFileName = new Regex("[" + Regex.Escape(strTheseAreInvalidFileNameChars) + "]"); Regex regInvalidFileName = new Regex("[" + Regex.Escape(strTheseAreInvalidFileNameChars) + "]");
if (regInvalidFileName.IsMatch(testName)) { return false; }; if (regInvalidFileName.IsMatch(testName)) { return false; };
@ -905,7 +907,7 @@ namespace HeliosPlus.Shared
public static string GetValidFilename(string uncheckedFilename) public static string GetValidFilename(string uncheckedFilename)
{ {
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); string invalid = new string(System.IO.Path.GetInvalidFileNameChars()) + new string(System.IO.Path.GetInvalidPathChars());
foreach (char c in invalid) foreach (char c in invalid)
{ {
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), ""); uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");

View File

@ -1,186 +0,0 @@
using System;
using System.Drawing;
using System.Linq;
using WindowsDisplayAPI.DisplayConfig;
using WindowsDisplayAPI.Native.DisplayConfig;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
namespace HeliosPlus.Shared.Topology
{
public class ProfileViewport
{
public ProfileViewport(PathInfo pathInfo)
{
SourceId = pathInfo.DisplaySource.SourceId;
PixelFormat = pathInfo.PixelFormat;
Position = pathInfo.Position;
Resolution = pathInfo.Resolution;
TargetDisplays = pathInfo.TargetsInfo.Select(targetDisplay => new ProfileViewportTargetDisplay(targetDisplay)).ToArray();
}
public ProfileViewport()
{
}
[JsonConverter(typeof(StringEnumConverter))]
public DisplayConfigPixelFormat PixelFormat { get; set; }
public Point Position { get; set; }
public Size Resolution { get; set; }
public uint SourceId { get; set; }
public ProfileViewportTargetDisplay[] TargetDisplays { get; set; }
public override string ToString()
{
return $"\\\\.\\DISPLAY{SourceId}";
}
public PathInfo ToPathInfo()
{
var targetDisplays = TargetDisplays.Select(target => target.ToPathTargetInfo()).Where(info => info != null).ToArray();
if (targetDisplays.Any())
{
return new PathInfo(new PathDisplaySource(targetDisplays.First().DisplayTarget.Adapter, SourceId), Position,
Resolution, PixelFormat, targetDisplays);
}
return null;
}
// The public override for the Object.Equals
public override bool Equals(object obj)
{
return this.Equals(obj as ProfileViewport);
}
// Profiles are equal if their contents (except name) are equal
public bool Equals(ProfileViewport other)
{
// If parameter is null, return false.
if (Object.ReferenceEquals(other, null))
return false;
// Optimization for a common success case.
if (Object.ReferenceEquals(this, other))
return true;
// If run-time types are not exactly the same, return false.
if (this.GetType() != other.GetType())
return false;
// Check whether the Profile Viewport properties are equal
// Two profiles are equal only when they have the same viewport data exactly
if (PixelFormat == other.PixelFormat &&
Position.Equals(other.Position) &&
Resolution.Equals(other.Resolution) &&
SourceId == other.SourceId)
{
// If the above all match, then we need to check the DisplayTargets
foreach (ProfileViewportTargetDisplay targetDisplay in TargetDisplays)
{
if (!other.TargetDisplays.Contains(targetDisplay))
return false;
}
return true;
}
else
return false;
}
// If Equals() returns true for this object compared to another
// then GetHashCode() must return the same value for these objects.
public override int GetHashCode()
{
// Get hash code for the PixelFormat field if it is not null.
int hashPixelFormat = PixelFormat.GetHashCode();
// Get hash code for the Position field if it is not null.
int hashPosition = Position == null ? 0 : Position.GetHashCode();
// Get hash code for the Resolution field if it is not null.
int hashResolution = Resolution == null ? 0 : Resolution.GetHashCode();
// Get hash code for the SourceId field if it is not null.
int hashSourceId = SourceId.GetHashCode();
// Get hash code for the TargetDisplays field if it is not null.
int hashTargetDisplays = TargetDisplays == null ? 0 : TargetDisplays.GetHashCode();
//Calculate the hash code for the product.
return hashPixelFormat ^ hashPosition ^ hashResolution ^ hashSourceId ^ hashTargetDisplays;
}
}
// Custom comparer for the ProfileViewport class
class ProfileViewportComparer : IEqualityComparer<ProfileViewport>
{
// Products are equal if their names and product numbers are equal.
public bool Equals(ProfileViewport x, ProfileViewport y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
// Check whether the Profile Viewport properties are equal
// Two profiles are equal only when they have the same viewport data exactly
if (x.PixelFormat == y.PixelFormat &&
x.Position.Equals(y.Position) &&
x.Resolution.Equals(y.Resolution) &&
x.SourceId == y.SourceId)
{
// If the above all match, then we need to check the DisplayTargets
// If they aren't equal then we need to return false;
if (!x.TargetDisplays.SequenceEqual(y.TargetDisplays))
return false;
else
return true;
/* foreach (ProfileViewportTargetDisplay xTargetDisplay in x.TargetDisplays)
{
if (!y.TargetDisplays.Contains(xTargetDisplay))
return false;
}*/
//return true;
}
else
return false;
}
// If Equals() returns true for a pair of objects
// then GetHashCode() must return the same value for these objects.
public int GetHashCode(ProfileViewport profileViewport)
{
// Check whether the object is null
if (Object.ReferenceEquals(profileViewport, null)) return 0;
// Get hash code for the PixelFormat field if it is not null.
int hashPixelFormat = profileViewport.PixelFormat.GetHashCode();
// Get hash code for the Position field if it is not null.
int hashPosition = profileViewport.Position == null ? 0 : profileViewport.Position.GetHashCode();
// Get hash code for the Resolution field if it is not null.
int hashResolution = profileViewport.Resolution == null ? 0 : profileViewport.Resolution.GetHashCode();
// Get hash code for the SourceId field if it is not null.
int hashSourceId = profileViewport.SourceId.GetHashCode();
// Get hash code for the TargetDisplays field if it is not null.
int hashTargetDisplays = profileViewport.TargetDisplays == null ? 0 : profileViewport.TargetDisplays.GetHashCode();
//Calculate the hash code for the product.
return hashPixelFormat ^ hashPosition ^ hashResolution ^ hashSourceId ^ hashTargetDisplays;
}
}
}

View File

@ -328,9 +328,9 @@ namespace HeliosPlus {
}); });
// Set up the UI forms to show // Set up the UI forms to show
ApplyingProfileForm timeoutForm = new ApplyingProfileForm(null, 3, $"Applying Profile '{profile.Name}'", "Press ESC to cancel!", Color.Blue, true); ApplyingProfileForm timeoutForm = new ApplyingProfileForm(null, 3, $"Changing to '{profile.Name}' Profile", "Press ESC to cancel", Color.Orange, true);
ApplyingProfileForm topologyForm = new ApplyingProfileForm(applyTopologyTask, 30, $"Applying Profile '{profile.Name}' Topology", "Step one of two...", Color.Red); ApplyingProfileForm topologyForm = new ApplyingProfileForm(applyTopologyTask, 15, $"Changing to '{profile.Name}' Profile", "Applying Topology (Step one of two)", Color.Aquamarine);
ApplyingProfileForm pathInfoForm = new ApplyingProfileForm(applyPathInfoTask, 30, $"Applying Profile '{profile.Name}' Path", "Step two of two...", Color.Green); ApplyingProfileForm pathInfoForm = new ApplyingProfileForm(applyPathInfoTask, 15, $"Changing to '{profile.Name}' Profile", "Applying Path Info (Step two of two)", Color.LawnGreen);
if (timeoutForm.ShowDialog() == DialogResult.Cancel) if (timeoutForm.ShowDialog() == DialogResult.Cancel)
{ {

View File

@ -50,11 +50,11 @@
// //
// lbl_sub_message // lbl_sub_message
// //
this.lbl_sub_message.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbl_sub_message.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_sub_message.ForeColor = System.Drawing.Color.White; this.lbl_sub_message.ForeColor = System.Drawing.Color.White;
this.lbl_sub_message.Location = new System.Drawing.Point(159, 87); this.lbl_sub_message.Location = new System.Drawing.Point(148, 67);
this.lbl_sub_message.Name = "lbl_sub_message"; this.lbl_sub_message.Name = "lbl_sub_message";
this.lbl_sub_message.Size = new System.Drawing.Size(300, 16); this.lbl_sub_message.Size = new System.Drawing.Size(330, 30);
this.lbl_sub_message.TabIndex = 2; this.lbl_sub_message.TabIndex = 2;
this.lbl_sub_message.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lbl_sub_message.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
@ -72,10 +72,10 @@
this.progressBar.MarqueeAnimationSpeed = 2000; this.progressBar.MarqueeAnimationSpeed = 2000;
this.progressBar.Name = "progressBar"; this.progressBar.Name = "progressBar";
this.progressBar.OuterColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.progressBar.OuterColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.progressBar.OuterMargin = -8; this.progressBar.OuterMargin = -15;
this.progressBar.OuterWidth = 6; this.progressBar.OuterWidth = 15;
this.progressBar.ProgressColor = System.Drawing.Color.DodgerBlue; this.progressBar.ProgressColor = System.Drawing.Color.DodgerBlue;
this.progressBar.ProgressWidth = 10; this.progressBar.ProgressWidth = 15;
this.progressBar.SecondaryFont = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.progressBar.SecondaryFont = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.progressBar.Size = new System.Drawing.Size(135, 135); this.progressBar.Size = new System.Drawing.Size(135, 135);
this.progressBar.StartAngle = 270; this.progressBar.StartAngle = 270;

View File

@ -111,10 +111,13 @@ namespace HeliosPlus.UIForms
lbl_message.Text = Title; lbl_message.Text = Title;
lbl_sub_message.Text = Message; lbl_sub_message.Text = Message;
progressBar.ProgressColor = ProgressColor; progressBar.ProgressColor = ProgressColor;
progressBar.Text = (progressBar.Value = progressBar.Maximum = _countdownCounter).ToString(); progressBar.Maximum = _countdownCounter;
progressBar.Value = _countdownCounter;
progressBar.Text = (_countdownCounter).ToString();
t_countdown.Start(); t_countdown.Start();
if (TaskToRun is Task) if (TaskToRun is Task)
TaskToRun.Start(); TaskToRun.Start();
} }
else else
{ {
@ -207,7 +210,11 @@ namespace HeliosPlus.UIForms
private void t_countdown_Tick(object sender, EventArgs e) private void t_countdown_Tick(object sender, EventArgs e)
{ {
if (_countdownCounter < 0) HandleDisplayChangeDelta();
progressBar.Value = _countdownCounter;
progressBar.Text = progressBar.Value.ToString();
if (_countdownCounter <= 0)
{ {
t_countdown.Stop(); t_countdown.Stop();
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
@ -215,13 +222,8 @@ namespace HeliosPlus.UIForms
return; return;
} }
HandleDisplayChangeDelta();
progressBar.Value = _countdownCounter;
progressBar.Text = progressBar.Value.ToString();
_countdownCounter--;
Reposition(); Reposition();
_countdownCounter--;
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)