Added SemaphoreSlim control to make sure that only one task at a time can be run. If any other task (Display Profile change or a Game Shortcut run) is attempted, it is silently ignored by DisplayMagician. This code then means that only a single instance of DisplayMagician is loaded.
Also found a bug in the StopProcess function that was stopping processes from properly being stopped. This has now been corrected, and fixes#75
Works fine, but still locks the UI. There is the potential for a race condition now as we have multiple pathways to run a shortcut or change the display profile. Next step is to stop that from being a problem.
Now instead of needing to be specified within the main Program file, we now have something that is defined and run from the SingleInstance class. I'll be adding the code to actually handle the different commandline options shortly.
The code now starts a namedpipeserver if it's the first instance, and if it's the 2nd instances it sends the full command line as an array to the first instance to get it to perform the work.
Mainly based on Johan Larsson Gu.Wpf.SingleInstance and Novotnyllc SingleInstanceHelper code, extracting the various bits that make sense for DisplayMagician. Using a mutex, and System.Runtime.Remoting.Channels.Ipc
I redeveloped the help wiki at the guthub site, and took the opportunity to add some guidance to the different UI windows that would be most helpful there. I also added a new 'Initial displaymagician setup' wiki page to help people just starting out.
Hopefully helps with #70
DisplayMagician can now run a Main Application, Start ptogram or Stop Program as Administrator (usin 'Runas') which will bring up a UAC prompt. Works fine for all three types of process stat, so will keep it there :)
Please note, there isn't any run as administrator fuctionality for the Games Launchers as they don't support that at all, and if I tried to add it, it would get really tricky really quickly. This functionality should suffice for 99% of use cases.
Changed the majority of the Shortcut loading code to be way more robust, and clearer to follow. The code had grown organically since the beginning of DisplayMagician, and really, really required some changes to make it all more robust and easier to make changes in the future. This is the first commit of that code so that I can ensure I have an offsite backup.
There is still a bit more of testing and bug hunting to do before I can be sure that it is all ready to release.
Fixes#68. The reason DisplayMagician was crashing was that it was hitting a Uplay Game in the Steam Library. This was not a valid thing to see. The reason DisplayMagician was doing that was because of a bug in the way that the list of installed games was combined. This bug has been in all 2.x versions of DisplayMagician, and would have affected anyone with Steam and any one more GameLibrary (e.g. GOG, Epic, Uplay etc).
I also managed to find a potential issue with editing shortcuts that I've hopefully now averted.
Properly clear out the form and all it's storage variables when the form loads (done)
Add in some protection logic to avoid a crash even if this situation occurs again (partly done)
Additionally, I found a recursive logic flaw that meant that DisplayMagician used WAAAAAAAAAAAAAY more memory than it needed to. I'm talking 5GB of memory rather than the 129MB it was supposed to do. So I'm so thankful that you logged this issue so I could find that one :).
Improved the minimum form sizes for multiple forms to stop them looking bad.
Updated the DisplayMagician and DisplayMagicianShared assembly versions to v2.1.2.0 in preparation for release as the next version of DisplayMagician.
This version adds USB device support, and SuperDisplay detection (it is a way to use an Android Tablet as another windows display).
Also fixes cloned displays so that it uses the path priority rather than relying on HDR settings for mapping the cloned display ID to the real Display ID. This corrects some errors which occurred when some earlier screens didn't support HDR or the advanced Windows colour settings. It will now work in those situations.
Now supports multiple display adapters. Has been tested by @matthex with his 7 screens and 2 display adapters and works. Should fix#60 finally.
Also changed the way that cloned display configurations are patched. Was using the HDR structure previously as that contains a direct mapping, but of course it completely breaks if HDR information isn't supported by the monitor, or provided over the connection technology used. So the changes I made now use the display path priority order to figure out which cloned monitor belongs to which item.
Firstly, the UID's are pulled from the physical displays so that we have a list of them. We then go through the paths, and for each target we check if there is a matching physical UID. If there is NOT a matching physical ID, then it is a cloned display target. We store that for later.
Next, we go through the paths again, and we figure out which physical displays are NOT in use as display targets. When we have that list, we then map the left over physical displays to the cloned displays in path priority order.
Finally, we then go through each cloned display target in the paths array, and set it to the configuration that windows needs so it will make a cloned display. We also go through the modes array, and set the physical display id to the corresponding mapped physical UID we calculated earlier.
All of this results in Windows accepting the cloned display configuration as expected.
This corrects some errors with the WinLibrary and how it handles cloned displays.
Also removed the 0.5 second delay between the end of the NVIDIALibrary call, and the start of the WinLibrary one, because they do not appear to be needed based on the NVIDIALibrary testing we've been doing with NVIDIAInfo.
Also corrected some log entries and comments.
I *think* that NVIDIA Surround and AMD Eyefinity changes are so great that WinLibrary gets confused and gives up. NVIDIA Surround and AMD Eyefinity affects the windows display layout so much. This change adds a windows config refresh after the NVIDIA or AMD config is applied to make sure that the winLibrary calls are using the latest updated active config that results from the NVIDIALibrary and AMDLibrary config changes.
This version of WinLibrary improves handling of multiple display adapters to cope with multiple displays across multiple display adapters. Hopefully fixes#60 (but no guarantees yet)