mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Basic working DisplayProfile writing and reading
Now have the DisplayProfile storing the minimal set of data that it needs. It also recreates the Screens list (used for creating profile bitmaps and icons) and recreates the DisplayProfileBitmaps each time at present. I will add some logic to deerialise the bitmaps again at a later date once I've compeleted actually applying the AMD display confs.
This commit is contained in:
parent
240c69fcdb
commit
04a0b56b59
File diff suppressed because it is too large
Load Diff
@ -22,28 +22,6 @@ namespace DisplayMagicianShared.AMD
|
|||||||
private SafeHandle _safeHandle = new SafeFileHandle(IntPtr.Zero, true);
|
private SafeHandle _safeHandle = new SafeFileHandle(IntPtr.Zero, true);
|
||||||
private IntPtr _adlContextHandle = IntPtr.Zero;
|
private IntPtr _adlContextHandle = IntPtr.Zero;
|
||||||
|
|
||||||
// Struct to be used as the AMD Profile
|
|
||||||
public struct AMDProfile
|
|
||||||
{
|
|
||||||
public List<AMDAdapter> Adapters;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Struct to store the Display
|
|
||||||
public struct AMDAdapter
|
|
||||||
{
|
|
||||||
internal ADLAdapterInfoX2 AdapterInfoX2;
|
|
||||||
internal List<AMDDisplay> Displays;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Struct to store the Display
|
|
||||||
public struct AMDDisplay
|
|
||||||
{
|
|
||||||
internal string DisplayName;
|
|
||||||
internal string DisplayConnector;
|
|
||||||
internal List<ADLMode> DisplayModes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static AMDLibrary() { }
|
static AMDLibrary() { }
|
||||||
public AMDLibrary()
|
public AMDLibrary()
|
||||||
{
|
{
|
||||||
@ -1199,7 +1177,9 @@ namespace DisplayMagicianShared.AMD
|
|||||||
displayToCreate.DisplayModes = new List<ADLMode>();
|
displayToCreate.DisplayModes = new List<ADLMode>();
|
||||||
displayToCreate.DisplayName = oneDisplayInfo.DisplayName;
|
displayToCreate.DisplayName = oneDisplayInfo.DisplayName;
|
||||||
displayToCreate.DisplayConnector = displayConnector.ToString("G");
|
displayToCreate.DisplayConnector = displayConnector.ToString("G");
|
||||||
|
displayToCreate.IsEyefinity = false;
|
||||||
|
displayToCreate.HDRSupported = false;
|
||||||
|
displayToCreate.HDREnabled = false;
|
||||||
|
|
||||||
|
|
||||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display Info for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display Info for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||||
@ -1282,8 +1262,6 @@ namespace DisplayMagicianShared.AMD
|
|||||||
|
|
||||||
ADLDDCInfo2 displayDDCInfo2 = new ADLDDCInfo2();
|
ADLDDCInfo2 displayDDCInfo2 = new ADLDDCInfo2();
|
||||||
displayDDCInfo2.Size = Marshal.SizeOf(displayDDCInfo2);
|
displayDDCInfo2.Size = Marshal.SizeOf(displayDDCInfo2);
|
||||||
// Create a stringbuilder buffer that EDID can be loaded into
|
|
||||||
//displayEDIDData.EDIDData = new StringBuilder(256);
|
|
||||||
|
|
||||||
if (ADL.ADL2_Display_DDCInfo2_Get != null)
|
if (ADL.ADL2_Display_DDCInfo2_Get != null)
|
||||||
{
|
{
|
||||||
@ -1357,6 +1335,8 @@ namespace DisplayMagicianShared.AMD
|
|||||||
adapterToCreate.Displays.Add(displayToCreate);
|
adapterToCreate.Displays.Add(displayToCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add the HDR information to the profile display storage
|
||||||
int HDRSupported = 0;
|
int HDRSupported = 0;
|
||||||
int HDREnabled = 0;
|
int HDREnabled = 0;
|
||||||
if (ADL.ADL2_Display_HDRState_Get != null)
|
if (ADL.ADL2_Display_HDRState_Get != null)
|
||||||
@ -1375,114 +1355,8 @@ namespace DisplayMagicianShared.AMD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayToCreate.HDREnabled = HDREnabled == 0 ? false : true;
|
||||||
// Create an array of all the important display info we need to record
|
displayToCreate.HDRSupported = HDRSupported == 0 ? false : true;
|
||||||
List<string> displayInfoIdentifierSection = new List<string>();
|
|
||||||
displayInfoIdentifierSection.Add("AMD");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(oneAdapter.VendorID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Vendor ID from video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(oneAdapter.AdapterName);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Adapter Name from video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(oneAdapter.VendorID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD VendorID from video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("1002");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(AdapterCapabilities.AdapterID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD AdapterID from video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(displayConnector.ToString("G"));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Display Connector from video card to display. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(oneDisplayInfo.DisplayName);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Display Name from display connected to AMD video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(displayDDCInfo2.ManufacturerID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Manufacturer ID from display connected to AMD video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(displayDDCInfo2.ProductID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Product ID from display connected to AMD video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
displayInfoIdentifierSection.Add(displayDDCInfo2.SerialID.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Serial ID from display connected to AMD video card. Substituting with a # instead");
|
|
||||||
displayInfoIdentifierSection.Add("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a display identifier out of it
|
|
||||||
string displayIdentifier = String.Join("|", displayInfoIdentifierSection);
|
|
||||||
|
|
||||||
// Check first to see if there is already an existing display identifier the same!
|
|
||||||
// This appears to be a bug with the AMD driver, or with the install on my test machine
|
|
||||||
// Either way, it is potentially going to happen in the wild, so I will filter it out if it does
|
|
||||||
if (displayIdentifiers.Contains(displayIdentifier))
|
|
||||||
{
|
|
||||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Your AMD driver reported the following Display Identifier multiple times, so ignoring it as we already have it: {displayIdentifier}");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/GetActiveprofile: DisplayIdentifier: {displayIdentifier}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -1543,37 +1417,6 @@ namespace DisplayMagicianShared.AMD
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public List<ScreenPosition> GenerateScreenPositions(AMDProfile profileToCreate)
|
|
||||||
{
|
|
||||||
List<ScreenPosition> screens = new List<ScreenPosition>();
|
|
||||||
|
|
||||||
|
|
||||||
if (profileToCreate.Adapters.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var adapter in profileToCreate.Adapters)
|
|
||||||
{
|
|
||||||
foreach (var display in adapter.Displays)
|
|
||||||
{
|
|
||||||
foreach (var mode in display.DisplayModes)
|
|
||||||
{
|
|
||||||
ScreenPosition screen = new ScreenPosition();
|
|
||||||
screen.Colour = Color.Red; // represents AMD
|
|
||||||
screen.Name = mode.DisplayID.ToString();
|
|
||||||
screen.ScreenX = mode.XPos;
|
|
||||||
screen.ScreenY = mode.YPos;
|
|
||||||
screen.ScreenWidth = mode.XRes;
|
|
||||||
screen.ScreenHeight = mode.YRes;
|
|
||||||
screen.IsSpanned = false;
|
|
||||||
//screen.Features = mode.ModeValue;
|
|
||||||
|
|
||||||
screens.Add(screen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return screens;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,42 @@ using System.Drawing;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using IWshRuntimeLibrary;
|
using IWshRuntimeLibrary;
|
||||||
|
using ATI.ADL;
|
||||||
//using WK.Libraries.HotkeyListenerNS;
|
//using WK.Libraries.HotkeyListenerNS;
|
||||||
|
|
||||||
namespace DisplayMagicianShared.AMD
|
namespace DisplayMagicianShared.AMD
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Struct to be used as the AMD Profile
|
||||||
|
[JsonObject(MemberSerialization.Fields)]
|
||||||
|
public struct AMDProfile
|
||||||
|
{
|
||||||
|
public List<AMDAdapter> Adapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Struct to store the Display
|
||||||
|
[JsonObject(MemberSerialization.Fields)]
|
||||||
|
public struct AMDAdapter
|
||||||
|
{
|
||||||
|
[JsonProperty]
|
||||||
|
internal ADLAdapterInfoX2 AdapterInfoX2;
|
||||||
|
internal List<AMDDisplay> Displays;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Struct to store the Display
|
||||||
|
[JsonObject(MemberSerialization.Fields)]
|
||||||
|
public struct AMDDisplay
|
||||||
|
{
|
||||||
|
internal string DisplayName;
|
||||||
|
internal string DisplayConnector;
|
||||||
|
[JsonRequired]
|
||||||
|
internal List<ADLMode> DisplayModes;
|
||||||
|
internal bool HDRSupported;
|
||||||
|
internal bool HDREnabled;
|
||||||
|
internal bool IsEyefinity;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class AMDProfileItem : ProfileItem, IComparable
|
public class AMDProfileItem : ProfileItem, IComparable
|
||||||
{
|
{
|
||||||
private static List<AMDProfileItem> _allSavedProfiles = new List<AMDProfileItem>();
|
private static List<AMDProfileItem> _allSavedProfiles = new List<AMDProfileItem>();
|
||||||
@ -20,7 +52,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
private Bitmap _profileBitmap, _profileShortcutBitmap;
|
private Bitmap _profileBitmap, _profileShortcutBitmap;
|
||||||
private List<string> _profileDisplayIdentifiers = new List<string>();
|
private List<string> _profileDisplayIdentifiers = new List<string>();
|
||||||
private List<ScreenPosition> _screens;
|
private List<ScreenPosition> _screens;
|
||||||
private AMDLibrary.AMDProfile _profileData = new AMDLibrary.AMDProfile();
|
private AMDProfile _profileData = new AMDProfile();
|
||||||
private static readonly string uuidV4Regex = @"(?im)^[{(]?[0-9A-F]{8}[-]?(?:[0-9A-F]{4}[-]?){3}[0-9A-F]{12}[)}]?$";
|
private static readonly string uuidV4Regex = @"(?im)^[{(]?[0-9A-F]{8}[-]?(?:[0-9A-F]{4}[-]?){3}[0-9A-F]{12}[)}]?$";
|
||||||
|
|
||||||
private string _uuid = "";
|
private string _uuid = "";
|
||||||
@ -70,7 +102,8 @@ namespace DisplayMagicianShared.AMD
|
|||||||
|
|
||||||
//public Topology.Path[] Paths { get; set; } = new Topology.Path[0];
|
//public Topology.Path[] Paths { get; set; } = new Topology.Path[0];
|
||||||
|
|
||||||
public AMDLibrary.AMDProfile ProfileData
|
[JsonRequired]
|
||||||
|
public AMDProfile ProfileData
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -78,11 +111,7 @@ namespace DisplayMagicianShared.AMD
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_profileData = new AMDLibrary.AMDProfile();
|
_profileData = value;
|
||||||
|
|
||||||
// We also update the screenPositions too so that
|
|
||||||
// the icons will work and graphics will display
|
|
||||||
//GetScreenPositions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,14 +144,23 @@ namespace DisplayMagicianShared.AMD
|
|||||||
}
|
}
|
||||||
return _screens;
|
return _screens;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_screens = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[JsonConverter(typeof(CustomBitmapConverter))]
|
|
||||||
public new Bitmap ProfileBitmap
|
//[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
|
[JsonIgnore]
|
||||||
|
public override Bitmap ProfileBitmap
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
/*if (!ProfileRepository.ProfilesLoaded)
|
||||||
|
return null;*/
|
||||||
|
|
||||||
if (_profileBitmap != null)
|
if (_profileBitmap != null)
|
||||||
return _profileBitmap;
|
return _profileBitmap;
|
||||||
else
|
else
|
||||||
@ -138,6 +176,28 @@ namespace DisplayMagicianShared.AMD
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
|
[JsonIgnore]
|
||||||
|
public override Bitmap ProfileTightestBitmap
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_profileShortcutBitmap != null)
|
||||||
|
return _profileShortcutBitmap;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_profileShortcutBitmap = this.ProfileIcon.ToTightestBitmap();
|
||||||
|
return _profileShortcutBitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_profileShortcutBitmap = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override bool IsValid()
|
public override bool IsValid()
|
||||||
@ -211,6 +271,13 @@ namespace DisplayMagicianShared.AMD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool PerformPostLoadingTasks()
|
||||||
|
{
|
||||||
|
// First thing we do is to set up the Screens
|
||||||
|
_screens = GetScreenPositions();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public override List<ScreenPosition> GetScreenPositions()
|
public override List<ScreenPosition> GetScreenPositions()
|
||||||
{
|
{
|
||||||
@ -228,15 +295,45 @@ namespace DisplayMagicianShared.AMD
|
|||||||
{
|
{
|
||||||
ScreenPosition screen = new ScreenPosition();
|
ScreenPosition screen = new ScreenPosition();
|
||||||
screen.Library = "AMD";
|
screen.Library = "AMD";
|
||||||
//screen.Colour = Color.FromArgb(200, 237, 28, 36); // represents AMD Red
|
|
||||||
screen.Colour = Color.FromArgb(255, 195, 195, 195); // represents normal screen colour
|
|
||||||
screen.Name = display.DisplayName;
|
screen.Name = display.DisplayName;
|
||||||
screen.DisplayConnector = display.DisplayConnector;
|
screen.DisplayConnector = display.DisplayConnector;
|
||||||
screen.ScreenX = mode.XPos;
|
screen.ScreenX = mode.XPos;
|
||||||
screen.ScreenY = mode.YPos;
|
screen.ScreenY = mode.YPos;
|
||||||
screen.ScreenWidth = mode.XRes;
|
screen.ScreenWidth = mode.XRes;
|
||||||
screen.ScreenHeight = mode.YRes;
|
screen.ScreenHeight = mode.YRes;
|
||||||
screen.IsSpanned = false;
|
|
||||||
|
// HDR information
|
||||||
|
if (display.HDRSupported)
|
||||||
|
{
|
||||||
|
screen.HDRSupported = true;
|
||||||
|
if (display.HDREnabled)
|
||||||
|
{
|
||||||
|
screen.HDREnabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screen.HDREnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screen.HDRSupported = false;
|
||||||
|
screen.HDREnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spanned screen options
|
||||||
|
if (display.IsEyefinity)
|
||||||
|
{
|
||||||
|
screen.IsSpanned = true;
|
||||||
|
screen.Colour = Color.FromArgb(200, 237, 28, 36); // represents AMD Red
|
||||||
|
screen.SpannedName = "AMD Eyefinity";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screen.IsSpanned = false;
|
||||||
|
screen.Colour = Color.FromArgb(255, 195, 195, 195); // represents normal screen colour
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Figure out features
|
// Figure out features
|
||||||
|
@ -311,7 +311,7 @@ namespace DisplayMagicianShared
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
private void DrawScreen(Graphics g, ScreenPosition screen)
|
/*private void DrawScreen(Graphics g, ScreenPosition screen)
|
||||||
{
|
{
|
||||||
//var res = NormalizeResolution(screen);
|
//var res = NormalizeResolution(screen);
|
||||||
Rectangle rect = new Rectangle(screen.ScreenX, screen.ScreenY, screen.ScreenWidth, screen.ScreenHeight);
|
Rectangle rect = new Rectangle(screen.ScreenX, screen.ScreenY, screen.ScreenWidth, screen.ScreenHeight);
|
||||||
@ -407,6 +407,115 @@ namespace DisplayMagicianShared
|
|||||||
{
|
{
|
||||||
DrawScreen(g, screen);
|
DrawScreen(g, screen);
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private void DrawView(Graphics g, float width, float height)
|
||||||
|
{
|
||||||
|
// Figure out the sizes we need based on the total size of the screens
|
||||||
|
var viewSize = ProfileIcon.CalculateViewSize(_profile.Screens, PaddingX, PaddingY);
|
||||||
|
var standPadding = height * 0.005f;
|
||||||
|
height -= standPadding * 8;
|
||||||
|
var factor = Math.Min((width - 2 * standPadding - 1) / viewSize.Width,
|
||||||
|
(height - 2 * standPadding - 1) / viewSize.Height);
|
||||||
|
g.ScaleTransform(factor, factor);
|
||||||
|
|
||||||
|
// Make space for the stand
|
||||||
|
var xOffset = ((width - 1) / factor - viewSize.Width) / 2f;
|
||||||
|
var yOffset = ((height - 1) / factor - viewSize.Height) / 2f;
|
||||||
|
g.TranslateTransform(-viewSize.X + xOffset, -viewSize.Y + yOffset);
|
||||||
|
|
||||||
|
// How wide the Bezel is on the screen graphics
|
||||||
|
int screenBezel = 60;
|
||||||
|
int screenWordBuffer = 30;
|
||||||
|
|
||||||
|
// Draw the stand
|
||||||
|
if (standPadding * 6 >= 1)
|
||||||
|
{
|
||||||
|
using (var boundRect = RoundedRect(viewSize, 2 * standPadding / factor))
|
||||||
|
{
|
||||||
|
g.FillPath(new SolidBrush(Color.FromArgb(200, 255, 255, 255)), boundRect);
|
||||||
|
g.DrawPath(new Pen(Color.FromArgb(170, 50, 50, 50), standPadding / factor), boundRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (
|
||||||
|
var boundRect =
|
||||||
|
RoundedRect(
|
||||||
|
new RectangleF(viewSize.Width * 0.375f + viewSize.X,
|
||||||
|
viewSize.Height + standPadding / factor,
|
||||||
|
viewSize.Width / 4, standPadding * 7 / factor), 2 * standPadding / factor))
|
||||||
|
{
|
||||||
|
g.FillPath(new SolidBrush(Color.FromArgb(250, 50, 50, 50)), boundRect);
|
||||||
|
g.DrawPath(new Pen(Color.FromArgb(50, 255, 255, 255), 2 / factor), boundRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.FillRectangle(new SolidBrush(Color.FromArgb(200, 255, 255, 255)), viewSize);
|
||||||
|
g.DrawRectangle(new Pen(Color.FromArgb(170, 50, 50, 50), standPadding / factor), viewSize.X, viewSize.Y,
|
||||||
|
viewSize.Width, viewSize.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now go through and draw the screens
|
||||||
|
foreach (ScreenPosition screen in _profile.Screens)
|
||||||
|
{
|
||||||
|
|
||||||
|
Color screenBgColour;
|
||||||
|
Color lightTextColour = Color.White;
|
||||||
|
Color darkTextColour = Color.Black;
|
||||||
|
|
||||||
|
// draw the screen
|
||||||
|
if (screen.IsSpanned)
|
||||||
|
{
|
||||||
|
//g.FillRectangle(new SolidBrush(Color.FromArgb(150, 106, 185, 0)), targetRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
// Draw the outline of the monitor
|
||||||
|
Rectangle outlineRect = new Rectangle(screen.ScreenX, screen.ScreenY, screen.ScreenWidth, screen.ScreenHeight);
|
||||||
|
g.FillRectangle(new SolidBrush(Color.FromArgb(255, 33, 33, 33)), outlineRect);
|
||||||
|
g.DrawRectangle(Pens.Black, outlineRect);
|
||||||
|
|
||||||
|
// Draw the screen of the monitor
|
||||||
|
Rectangle screenRect = new Rectangle(screen.ScreenX + screenBezel, screen.ScreenY + screenBezel, screen.ScreenWidth - (screenBezel * 2), screen.ScreenHeight - (screenBezel * 2));
|
||||||
|
if (screen.Colour != null)
|
||||||
|
{
|
||||||
|
screenBgColour = screen.Colour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screenBgColour = Color.FromArgb(255, 155, 155, 155);
|
||||||
|
}
|
||||||
|
g.FillRectangle(new SolidBrush(screenBgColour), screenRect);
|
||||||
|
g.DrawRectangle(Pens.Black, screenRect);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Color pickTextColorBasedOnBgColour(Color bgColour, Color lightColour, Color darkColour)
|
||||||
|
{
|
||||||
|
if ((bgColour.R * 0.299 + bgColour.G * 0.587 + bgColour.B * 0.114) > 186)
|
||||||
|
{
|
||||||
|
return darkColour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lightColour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap pickBitmapBasedOnBgColour(Color bgColour, Bitmap lightBitmap, Bitmap darkBitmap)
|
||||||
|
{
|
||||||
|
if ((bgColour.R * 0.299 + bgColour.G * 0.587 + bgColour.B * 0.114) > 186)
|
||||||
|
{
|
||||||
|
return darkBitmap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return lightBitmap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,14 +25,17 @@ namespace DisplayMagicianShared
|
|||||||
public string Library;
|
public string Library;
|
||||||
public bool IsPrimary;
|
public bool IsPrimary;
|
||||||
public Color Colour;
|
public Color Colour;
|
||||||
|
public string DisplayConnector;
|
||||||
|
internal bool HDRSupported;
|
||||||
|
internal bool HDREnabled;
|
||||||
public List<string> Features;
|
public List<string> Features;
|
||||||
// If the screen is AMD Eyefinity or NVIDIA Surround or similar, it has screens that are part of it
|
// If the screen is AMD Eyefinity or NVIDIA Surround or similar, it has screens that are part of it
|
||||||
// These two fields indicate this. THe spanned screens are added to the SpannedScreens field
|
// These fields indicate this. THe spanned screens are added to the SpannedScreens field
|
||||||
public bool IsSpanned;
|
public bool IsSpanned;
|
||||||
|
public string SpannedName;
|
||||||
public List<SpannedScreenPosition> SpannedScreens;
|
public List<SpannedScreenPosition> SpannedScreens;
|
||||||
public int SpannedColumns;
|
public int SpannedColumns;
|
||||||
public int SpannedRows;
|
public int SpannedRows;
|
||||||
public string DisplayConnector;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct SpannedScreenPosition
|
public struct SpannedScreenPosition
|
||||||
@ -178,7 +181,7 @@ namespace DisplayMagicianShared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string Driver { get; } = "Unknown";
|
public virtual string Driver { get; } = "Unknown";
|
||||||
|
|
||||||
public Keys Hotkey {
|
public Keys Hotkey {
|
||||||
get
|
get
|
||||||
@ -195,7 +198,7 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
//public Topology.Path[] Paths { get; set; } = new Topology.Path[0];
|
//public Topology.Path[] Paths { get; set; } = new Topology.Path[0];
|
||||||
|
|
||||||
//public virtual object ProfileData { get; set; }
|
//public virtual ProfileData { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual ProfileIcon ProfileIcon
|
public virtual ProfileIcon ProfileIcon
|
||||||
@ -217,7 +220,6 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual List<ScreenPosition> Screens
|
public virtual List<ScreenPosition> Screens
|
||||||
{
|
{
|
||||||
@ -229,6 +231,10 @@ namespace DisplayMagicianShared
|
|||||||
}
|
}
|
||||||
return _screens;
|
return _screens;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_screens = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SavedProfileIconCacheFilename { get; set; }
|
public string SavedProfileIconCacheFilename { get; set; }
|
||||||
@ -250,7 +256,8 @@ namespace DisplayMagicianShared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(CustomBitmapConverter))]
|
//[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
|
[JsonIgnore]
|
||||||
public virtual Bitmap ProfileBitmap
|
public virtual Bitmap ProfileBitmap
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -270,8 +277,9 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(CustomBitmapConverter))]
|
//[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
public Bitmap ProfileTightestBitmap
|
[JsonIgnore]
|
||||||
|
public virtual Bitmap ProfileTightestBitmap
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -368,6 +376,11 @@ namespace DisplayMagicianShared
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool PerformPostLoadingTasks()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// The public override for the Object.Equals
|
// The public override for the Object.Equals
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
@ -32,6 +32,7 @@ namespace DisplayMagicianShared
|
|||||||
private static List<string> _connectedDisplayIdentifiers = new List<string>();
|
private static List<string> _connectedDisplayIdentifiers = new List<string>();
|
||||||
private static bool notifiedEDIDErrorToUser = false;
|
private static bool notifiedEDIDErrorToUser = false;
|
||||||
private static AMDLibrary AMDLibrary;
|
private static AMDLibrary AMDLibrary;
|
||||||
|
//private static bool _isLoading = false;
|
||||||
|
|
||||||
// Other constants that are useful
|
// Other constants that are useful
|
||||||
public static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician");
|
public static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician");
|
||||||
@ -179,6 +180,17 @@ namespace DisplayMagicianShared
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool ProfilesLoaded {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _profilesLoaded;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_profilesLoaded = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Class Methods
|
#region Class Methods
|
||||||
@ -633,7 +645,6 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: Checking whether the profile {profile.Name} is the currently active profile.");
|
SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: Checking whether the profile {profile.Name} is the currently active profile.");
|
||||||
|
|
||||||
//if (profile.Paths.SequenceEqual(_currentProfile.Paths))
|
|
||||||
if (profile.Equals(_currentProfile))
|
if (profile.Equals(_currentProfile))
|
||||||
{
|
{
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is the currently active profile.");
|
SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is the currently active profile.");
|
||||||
@ -679,7 +690,6 @@ namespace DisplayMagicianShared
|
|||||||
SharedLogger.logger.Error(ex, $"ProfileRepository/LoadProfiles: Tried to parse the JSON in the {_profileStorageJsonFileName} but the JsonConvert threw an exception.");
|
SharedLogger.logger.Error(ex, $"ProfileRepository/LoadProfiles: Tried to parse the JSON in the {_profileStorageJsonFileName} but the JsonConvert threw an exception.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ProfileItem myCurrentProfile = new NVIDIAProfileItem
|
ProfileItem myCurrentProfile = new NVIDIAProfileItem
|
||||||
{
|
{
|
||||||
Name = "Current Display Profile",
|
Name = "Current Display Profile",
|
||||||
@ -690,9 +700,17 @@ namespace DisplayMagicianShared
|
|||||||
|
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Finding the current profile in the Profile Repository");
|
SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Finding the current profile in the Profile Repository");
|
||||||
|
|
||||||
// Lookup all the Profile Names in the Saved Profiles
|
// Go through all the profiles and set up the needed structures (such as the Screens list)
|
||||||
|
// and check if the current profile is used
|
||||||
foreach (ProfileItem loadedProfile in _allProfiles)
|
foreach (ProfileItem loadedProfile in _allProfiles)
|
||||||
{
|
{
|
||||||
|
if (loadedProfile.Driver.Equals("AMD"))
|
||||||
|
{
|
||||||
|
AMDProfileItem amdLoadedProfile = (AMDProfileItem) loadedProfile;
|
||||||
|
amdLoadedProfile.PerformPostLoadingTasks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ProfileRepository.IsActiveProfile(loadedProfile))
|
if (ProfileRepository.IsActiveProfile(loadedProfile))
|
||||||
_currentProfile = loadedProfile;
|
_currentProfile = loadedProfile;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user