diff --git a/HeliosPlus.Shared/ProfileItem.cs b/HeliosPlus.Shared/ProfileItem.cs index 46d7398..a91d9d3 100644 --- a/HeliosPlus.Shared/ProfileItem.cs +++ b/HeliosPlus.Shared/ProfileItem.cs @@ -29,7 +29,7 @@ namespace HeliosPlus.Shared private static List _availableDisplays; private static List _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 Version _version; @@ -160,7 +160,7 @@ namespace HeliosPlus.Shared public string Name { get; set; } - public ProfileViewport[] Viewports { get; set; } = new ProfileViewport[0]; + public Topology.Path[] Viewports { get; set; } = new Topology.Path[0]; [JsonIgnore] public ProfileIcon ProfileIcon @@ -190,7 +190,7 @@ namespace HeliosPlus.Shared { if (_profileDisplayIdentifiers.Count == 0) { - _profileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers(); + _profileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers(); } return _profileDisplayIdentifiers; } @@ -367,7 +367,7 @@ namespace HeliosPlus.Shared 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) { uncheckedFilename = uncheckedFilename.Replace(c.ToString(), ""); diff --git a/HeliosPlus.Shared/ProfileRepository.cs b/HeliosPlus.Shared/ProfileRepository.cs index 4acfb69..01f7e10 100644 --- a/HeliosPlus.Shared/ProfileRepository.cs +++ b/HeliosPlus.Shared/ProfileRepository.cs @@ -26,6 +26,7 @@ using System.Resources; using System.Net.NetworkInformation; using NvAPIWrapper.Mosaic; using NvAPIWrapper.Native.Mosaic; +using PathInfos = HeliosPlus.Shared.Topology.PathInfo; namespace HeliosPlus.Shared @@ -39,11 +40,11 @@ namespace HeliosPlus.Shared private static bool _profilesLoaded = false; public static Version Version = new Version(1, 0, 0); // Other constants that are useful - public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus"); - public static string AppIconPath = Path.Combine(AppDataPath, $"Icons"); - public static string AppHeliosPlusIconFilename = Path.Combine(AppIconPath, @"HeliosPlus.ico"); - private static string AppProfileStoragePath = Path.Combine(AppDataPath, $"Profiles"); - private static string _profileStorageJsonFileName = Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json"); + public static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus"); + public static string AppIconPath = System.IO.Path.Combine(AppDataPath, $"Icons"); + public static string AppHeliosPlusIconFilename = System.IO.Path.Combine(AppIconPath, @"HeliosPlus.ico"); + private static string AppProfileStoragePath = System.IO.Path.Combine(AppDataPath, $"Profiles"); + private static string _profileStorageJsonFileName = System.IO.Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json"); private static uint _lastProfileId; private static ProfileItem _currentProfile; //private static List _availableDisplays; @@ -358,7 +359,7 @@ namespace HeliosPlus.Shared ProfileItem activeProfile = new ProfileItem { 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); @@ -459,7 +460,7 @@ namespace HeliosPlus.Shared ProfileItem myCurrentProfile = new ProfileItem { Name = "Current Display Profile", - Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray() + Viewports = PathInfo.GetActivePaths().Select(info => new Path(info)).ToArray() }; _currentProfile = myCurrentProfile; @@ -484,7 +485,7 @@ namespace HeliosPlus.Shared ProfileItem myCurrentProfile = new ProfileItem { Name = "Current Display Profile", - Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray() + Viewports = PathInfo.GetActivePaths().Select(info => new Path(info)).ToArray() }; _currentProfile = myCurrentProfile; @@ -544,7 +545,7 @@ namespace HeliosPlus.Shared { // 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; try @@ -562,13 +563,15 @@ namespace HeliosPlus.Shared } } + + public static List GenerateProfileDisplayIdentifiers() { List displayIdentifiers = new List(); // If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs(); - if (myLogicalGPUs.Length == 0) + if (myLogicalGPUs.Length > 0) { foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs) @@ -626,13 +629,13 @@ namespace HeliosPlus.Shared if (displayDevices.Count == 0) continue; - /*Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); + Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DN : {displayAdapter.DeviceName}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}"); Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}"); - Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");*/ + Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}"); foreach (DisplayDevice displayDevice in displayDevices) { @@ -644,24 +647,21 @@ namespace HeliosPlus.Shared if (!displayDevice.IsAvailable) continue; - /*Console.WriteLine($"DDA : {displayDevice.Adapter}"); + Console.WriteLine($"DDA : {displayDevice.Adapter}"); Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}"); Debug.WriteLine($"DDDN : {displayDevice.DeviceName}"); Debug.WriteLine($"DDDP : {displayDevice.DevicePath}"); Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}"); Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}"); Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}"); - Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");*/ - - /*Console.WriteLine($"PDSA : {pathDisplaySource.Adapter}"); + Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}"); + Debug.WriteLine($"PDSA : {pathDisplaySource.Adapter}"); Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}"); Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}"); Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}"); Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}"); - Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");*/ - - /*Console.WriteLine($"PDTA : {pathDisplayTarget.Adapter}"); - //Console.WriteLine($"PDTBP : {pathDisplayTarget.BootPersistence}"); + Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}"); + Debug.WriteLine($"PDTA : {pathDisplayTarget.Adapter}"); Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}"); Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}"); Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}"); @@ -672,7 +672,7 @@ namespace HeliosPlus.Shared Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}"); Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}"); 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 string[] displayInfo = { @@ -706,7 +706,7 @@ namespace HeliosPlus.Shared // If the Video Card is an NVidia, then we should generate specific NVidia displayIdentifiers NvAPIWrapper.GPU.LogicalGPU[] myLogicalGPUs = NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs(); - if (myLogicalGPUs.Length == 0) + if (myLogicalGPUs.Length > 0) { foreach (NvAPIWrapper.GPU.LogicalGPU myLogicalGPU in myLogicalGPUs) @@ -758,13 +758,13 @@ namespace HeliosPlus.Shared PathDisplayAdapter pathDisplayAdapter = displayAdapter.ToPathDisplayAdapter(); List displayDevices = displayAdapter.GetDisplayDevices().ToList(); - /*Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); + Debug.WriteLine($"DP : {displayAdapter.DevicePath}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"DN : {displayAdapter.DeviceName}"); Debug.WriteLine($"DK : {displayAdapter.DeviceKey}"); Debug.WriteLine($"AI : {pathDisplayAdapter.AdapterId}"); Debug.WriteLine($"AIDP : {pathDisplayAdapter.DevicePath}"); - Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}");*/ + Debug.WriteLine($"AIII : {pathDisplayAdapter.IsInvalid}"); foreach (DisplayDevice displayDevice in displayDevices) { @@ -772,24 +772,21 @@ namespace HeliosPlus.Shared PathDisplaySource pathDisplaySource = displayDevice.ToPathDisplaySource(); PathDisplayTarget pathDisplayTarget = displayDevice.ToPathDisplayTarget(); - /*Console.WriteLine($"DDA : {displayDevice.Adapter}"); + Debug.WriteLine($"DDA : {displayDevice.Adapter}"); Debug.WriteLine($"DDDK : {displayDevice.DeviceKey}"); Debug.WriteLine($"DDDN : {displayDevice.DeviceName}"); Debug.WriteLine($"DDDP : {displayDevice.DevicePath}"); Debug.WriteLine($"DDDiFN : {displayDevice.DisplayFullName}"); Debug.WriteLine($"DDDiN : {displayDevice.DisplayName}"); Debug.WriteLine($"DDDiIA : {displayDevice.IsAvailable}"); - Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}");*/ - - /*Console.WriteLine($"PDSA : {pathDisplaySource.Adapter}"); + Debug.WriteLine($"DDDiIV : {displayDevice.IsValid}"); + Debug.WriteLine($"PDSA : {pathDisplaySource.Adapter}"); Debug.WriteLine($"PDSCDS : {pathDisplaySource.CurrentDPIScale}"); Debug.WriteLine($"PDSDN : {pathDisplaySource.DisplayName}"); Debug.WriteLine($"PDSMDS : {pathDisplaySource.MaximumDPIScale}"); Debug.WriteLine($"PDSRDS : {pathDisplaySource.RecommendedDPIScale}"); - Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}");*/ - - /*Console.WriteLine($"PDTA : {pathDisplayTarget.Adapter}"); - //Console.WriteLine($"PDTBP : {pathDisplayTarget.BootPersistence}"); + Debug.WriteLine($"PDSSI : {pathDisplaySource.SourceId}"); + Debug.WriteLine($"PDTA : {pathDisplayTarget.Adapter}"); Debug.WriteLine($"PDTCI : {pathDisplayTarget.ConnectorInstance}"); Debug.WriteLine($"PDTDP : {pathDisplayTarget.DevicePath}"); Debug.WriteLine($"PDTEMC : {pathDisplayTarget.EDIDManufactureCode}"); @@ -800,7 +797,7 @@ namespace HeliosPlus.Shared Debug.WriteLine($"PDTPR : {pathDisplayTarget.PreferredResolution}"); Debug.WriteLine($"PDTPSM : {pathDisplayTarget.PreferredSignalMode}"); 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 string[] displayInfo = { @@ -829,7 +826,7 @@ namespace HeliosPlus.Shared return displayIdentifiers; } - public static bool ApplyTopology(ProfileItem profile) + public static bool ApplyTopology(ProfileItem profile) { Debug.Print("ProfileRepository.ApplyTopology()"); @@ -881,7 +878,12 @@ namespace HeliosPlus.Shared try { + // If Nvidia then we need to handle NVidia style + 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); return true; } @@ -895,7 +897,7 @@ namespace HeliosPlus.Shared 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) + "]"); if (regInvalidFileName.IsMatch(testName)) { return false; }; @@ -905,7 +907,7 @@ namespace HeliosPlus.Shared 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) { uncheckedFilename = uncheckedFilename.Replace(c.ToString(), ""); diff --git a/HeliosPlus.Shared/Topology/ProfileViewport.cs b/HeliosPlus.Shared/Topology/ProfileViewport.cs deleted file mode 100644 index 0a9d2ad..0000000 --- a/HeliosPlus.Shared/Topology/ProfileViewport.cs +++ /dev/null @@ -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 - { - // 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; - } - - } -} \ No newline at end of file diff --git a/HeliosPlus/Program.cs b/HeliosPlus/Program.cs index 01e084a..78f2581 100644 --- a/HeliosPlus/Program.cs +++ b/HeliosPlus/Program.cs @@ -328,9 +328,9 @@ namespace HeliosPlus { }); // 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 topologyForm = new ApplyingProfileForm(applyTopologyTask, 30, $"Applying Profile '{profile.Name}' Topology", "Step one of two...", Color.Red); - ApplyingProfileForm pathInfoForm = new ApplyingProfileForm(applyPathInfoTask, 30, $"Applying Profile '{profile.Name}' Path", "Step two of two...", Color.Green); + ApplyingProfileForm timeoutForm = new ApplyingProfileForm(null, 3, $"Changing to '{profile.Name}' Profile", "Press ESC to cancel", Color.Orange, true); + ApplyingProfileForm topologyForm = new ApplyingProfileForm(applyTopologyTask, 15, $"Changing to '{profile.Name}' Profile", "Applying Topology (Step one of two)", Color.Aquamarine); + 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) { diff --git a/HeliosPlus/UIForms/ApplyingProfileForm.Designer.cs b/HeliosPlus/UIForms/ApplyingProfileForm.Designer.cs index a925ba1..1a631e2 100644 --- a/HeliosPlus/UIForms/ApplyingProfileForm.Designer.cs +++ b/HeliosPlus/UIForms/ApplyingProfileForm.Designer.cs @@ -50,11 +50,11 @@ // // 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.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.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.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -72,10 +72,10 @@ this.progressBar.MarqueeAnimationSpeed = 2000; this.progressBar.Name = "progressBar"; this.progressBar.OuterColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.progressBar.OuterMargin = -8; - this.progressBar.OuterWidth = 6; + this.progressBar.OuterMargin = -15; + this.progressBar.OuterWidth = 15; 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.Size = new System.Drawing.Size(135, 135); this.progressBar.StartAngle = 270; diff --git a/HeliosPlus/UIForms/ApplyingProfileForm.cs b/HeliosPlus/UIForms/ApplyingProfileForm.cs index 8a27ec4..75f1426 100644 --- a/HeliosPlus/UIForms/ApplyingProfileForm.cs +++ b/HeliosPlus/UIForms/ApplyingProfileForm.cs @@ -35,7 +35,7 @@ namespace HeliosPlus.UIForms public ApplyingProfileForm(Task taskToRun = null, int countdown = 0, string title = null, string message = null, Color progressColor = default(Color), bool cancellable = false, int displayChangeMaxDelta = 5) : this() { - _countdownCounter = countdown; + _countdownCounter = countdown; _lastCount = _countdownCounter; _displayChangeMaxDelta = displayChangeMaxDelta; Cancellable = cancellable; @@ -111,10 +111,13 @@ namespace HeliosPlus.UIForms lbl_message.Text = Title; lbl_sub_message.Text = Message; progressBar.ProgressColor = ProgressColor; - progressBar.Text = (progressBar.Value = progressBar.Maximum = _countdownCounter).ToString(); + progressBar.Maximum = _countdownCounter; + progressBar.Value = _countdownCounter; + progressBar.Text = (_countdownCounter).ToString(); t_countdown.Start(); if (TaskToRun is Task) TaskToRun.Start(); + } else { @@ -207,7 +210,11 @@ namespace HeliosPlus.UIForms 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(); DialogResult = DialogResult.OK; @@ -215,13 +222,8 @@ namespace HeliosPlus.UIForms return; } - - HandleDisplayChangeDelta(); - - progressBar.Value = _countdownCounter; - progressBar.Text = progressBar.Value.ToString(); - _countdownCounter--; Reposition(); + _countdownCounter--; } protected override void WndProc(ref Message m)