[WIP] Initial working AMD displayview

Have managed to get a working displayview
for AMD (not working in spanned mode) and
currently playing with the colours and layout.
Once I have something locked in, I'll troubleshoot
the ProfileDisplay file writing.
This commit is contained in:
Terry MacDonald 2021-06-26 21:54:11 +12:00
parent 6a3068fb32
commit 99d43bc245
14 changed files with 338 additions and 150 deletions

View File

@ -340,6 +340,8 @@
<None Include="Resources\Epic.png" /> <None Include="Resources\Epic.png" />
<None Include="Resources\Origin.png" /> <None Include="Resources\Origin.png" />
<None Include="Resources\GOG.png" /> <None Include="Resources\GOG.png" />
<None Include="Resources\amdblack.png" />
<None Include="Resources\amdwhite.png" />
<Content Include="Resources\redarrows.png" /> <Content Include="Resources\redarrows.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -60,6 +60,26 @@ namespace DisplayMagician.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap amdblack {
get {
object obj = ResourceManager.GetObject("amdblack", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap amdwhite {
get {
object obj = ResourceManager.GetObject("amdwhite", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary> /// </summary>

View File

@ -154,4 +154,10 @@
<data name="GOG" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="GOG" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GOG.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\GOG.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="amdblack" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\amdblack.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="amdwhite" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\amdwhite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -54,11 +54,11 @@ namespace DisplayMagician.UIForms
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.tt_selected = new System.Windows.Forms.ToolTip(this.components); this.tt_selected = new System.Windows.Forms.ToolTip(this.components);
this.lbl_save_profile = new System.Windows.Forms.Label(); this.lbl_save_profile = new System.Windows.Forms.Label();
this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView();
this.btn_save = new System.Windows.Forms.Button(); this.btn_save = new System.Windows.Forms.Button();
this.dialog_save = new System.Windows.Forms.SaveFileDialog(); this.dialog_save = new System.Windows.Forms.SaveFileDialog();
this.btn_hotkey = new System.Windows.Forms.Button(); this.btn_hotkey = new System.Windows.Forms.Button();
this.lbl_hotkey_assigned = new System.Windows.Forms.Label(); this.lbl_hotkey_assigned = new System.Windows.Forms.Label();
this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView();
this.menu_profiles.SuspendLayout(); this.menu_profiles.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -290,22 +290,6 @@ namespace DisplayMagician.UIForms
" DisplayMagician and click \'Save As\' to save this Display Profile."; " DisplayMagician and click \'Save As\' to save this Display Profile.";
this.lbl_save_profile.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lbl_save_profile.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// dv_profile
//
this.dv_profile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dv_profile.BackColor = System.Drawing.Color.DimGray;
this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue;
this.dv_profile.Location = new System.Drawing.Point(0, 63);
this.dv_profile.Margin = new System.Windows.Forms.Padding(18);
this.dv_profile.Name = "dv_profile";
this.dv_profile.PaddingX = 100;
this.dv_profile.PaddingY = 100;
this.dv_profile.Profile = null;
this.dv_profile.Size = new System.Drawing.Size(976, 517);
this.dv_profile.TabIndex = 4;
//
// btn_save // btn_save
// //
this.btn_save.Anchor = System.Windows.Forms.AnchorStyles.None; this.btn_save.Anchor = System.Windows.Forms.AnchorStyles.None;
@ -360,6 +344,22 @@ namespace DisplayMagician.UIForms
this.lbl_hotkey_assigned.Visible = false; this.lbl_hotkey_assigned.Visible = false;
this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click);
// //
// dv_profile
//
this.dv_profile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dv_profile.BackColor = System.Drawing.Color.DimGray;
this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue;
this.dv_profile.Location = new System.Drawing.Point(0, 63);
this.dv_profile.Margin = new System.Windows.Forms.Padding(18);
this.dv_profile.Name = "dv_profile";
this.dv_profile.PaddingX = 100;
this.dv_profile.PaddingY = 100;
this.dv_profile.Profile = null;
this.dv_profile.Size = new System.Drawing.Size(976, 517);
this.dv_profile.TabIndex = 4;
//
// DisplayProfileForm // DisplayProfileForm
// //
this.AcceptButton = this.btn_apply; this.AcceptButton = this.btn_apply;

View File

@ -277,30 +277,30 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLMode internal struct ADLMode
{ {
/// <summary> Display IDs. </summary>
internal ADLDisplayID DisplayID;
/// <summary> Screen refresh rate. </summary>
internal float RefreshRate;
/// <summary> Adapter index. </summary> /// <summary> Adapter index. </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> Display IDs. </summary>
internal ADLDisplayID DisplayID;
/// <summary> Screen position X coordinate. </summary>
internal int XPos;
/// <summary> Screen position Y coordinate. </summary>
internal int YPos;
/// <summary> Screen resolution Width. </summary>
internal int XRes;
/// <summary> Screen resolution Height. </summary>
internal int YRes;
/// <summary> Screen Color Depth. E.g., 16, 32. </summary> /// <summary> Screen Color Depth. E.g., 16, 32. </summary>
internal int ColourDepth; internal int ColourDepth;
/// <summary> Screen refresh rate. </summary>
internal float RefreshRate;
/// <summary> Screen orientation. E.g., 0, 90, 180, 270. </summary>
internal int Orientation;
/// <summary> Vista mode flag indicating Progressive or Interlaced mode. </summary> /// <summary> Vista mode flag indicating Progressive or Interlaced mode. </summary>
internal int ModeFlag; internal int ModeFlag;
/// <summary> The bit mask identifying the number of bits this Mode is currently using. </summary> /// <summary> The bit mask identifying the number of bits this Mode is currently using. </summary>
internal int ModeMask; internal int ModeMask;
/// <summary> The bit mask identifying the display status. </summary> /// <summary> The bit mask identifying the display status. </summary>
internal int ModeValue; internal int ModeValue;
/// <summary> Screen orientation. E.g., 0, 90, 180, 270. </summary>
internal int Orientation;
/// <summary> Screen position X coordinate. </summary>
internal int XPos;
/// <summary> Screen resolution Width. </summary>
internal int XRes;
/// <summary> Screen position Y coordinate. </summary>
internal int YPos;
/// <summary> Screen resolution Height. </summary>
internal int YRes;
} }
internal struct ConvertedDisplayModeFlags internal struct ConvertedDisplayModeFlags
@ -457,19 +457,20 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLDisplayEDIDData internal struct ADLDisplayEDIDData
{ {
/// <summary> Size</summary>
internal int Size;
/// <summary> Flag</summary>
internal int Flag;
/// <summary> EDIDSize </summary>
internal int EDIDSize;
/// <summary> Block Index </summary>
internal int BlockIndex;
/// <summary> EDIDData [256] </summary> /// <summary> EDIDData [256] </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)ADL.ADL_MAX_EDIDDATA_SIZE)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)ADL.ADL_MAX_EDIDDATA_SIZE)]
internal string EDIDData; internal string EDIDData;
/// <summary> Block Index </summary> [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
internal int BlockIndex; internal int[] Reserved;
/// <summary> EDIDSize </summary>
internal int EDIDSize;
/// <summary> Flag</summary>
internal int Flag;
/// <summary> Reserved </summary>
internal int Reserved;
/// <summary> Size</summary>
internal int Size;
} }
@ -670,6 +671,8 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLDisplayConfig internal struct ADLDisplayConfig
{ {
/// <summary> Size of this data structure </summary>
internal long Size;
/// <summary> HDTV Connector Type </summary> /// <summary> HDTV Connector Type </summary>
internal long ConnectorType; internal long ConnectorType;
/// <summary> HDTV Capabilities themselves </summary> /// <summary> HDTV Capabilities themselves </summary>
@ -678,26 +681,25 @@ namespace ATI.ADL
internal long OverriddedDeviceData; internal long OverriddedDeviceData;
/// <summary> Reserved for future use</summary> /// <summary> Reserved for future use</summary>
internal long Reserved; internal long Reserved;
/// <summary> Size of this data structure </summary>
internal long Size;
} }
/// <summary> ADLDisplayMap Structure</summary> /// <summary> ADLDisplayMap Structure</summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLDisplayMap internal struct ADLDisplayMap
{ {
/// <summary> The Display Mode for the current map.</summary>
internal ADLMode DisplayMode;
/// <summary> The current display map index. It is the OS desktop index. For example, if the OS index 1 is showing clone mode, the display map will be 1. </summary> /// <summary> The current display map index. It is the OS desktop index. For example, if the OS index 1 is showing clone mode, the display map will be 1. </summary>
internal int DisplayMapIndex; internal int DisplayMapIndex;
/// <summary> The Display Mode for the current map.</summary>
internal ADLMode DisplayMode;
/// <summary> The number of display targets belongs to this map </summary>
internal int NumDisplayTarget;
/// <summary> The first target array index in the Target array </summary>
internal int FirstDisplayTargetArrayIndex;
/// <summary> The bit mask identifies the number of bits DisplayMap is currently using. It is the sum of all the bit definitions defined in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.</summary> /// <summary> The bit mask identifies the number of bits DisplayMap is currently using. It is the sum of all the bit definitions defined in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.</summary>
internal int DisplayMapMask; internal int DisplayMapMask;
/// <summary> The bit mask identifies the display status. The detailed definition is in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.</summary> /// <summary> The bit mask identifies the display status. The detailed definition is in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.</summary>
internal int DisplayMapValue; internal int DisplayMapValue;
/// <summary> The first target array index in the Target array </summary>
internal int FirstDisplayTargetArrayIndex;
/// <summary> The number of display targets belongs to this map </summary>
internal int NumDisplayTarget;
} }
/// <summary> ADLDisplayMapArray Array</summary> /// <summary> ADLDisplayMapArray Array</summary>
@ -741,14 +743,14 @@ namespace ATI.ADL
{ {
/// <summary> The Adapter index </summary> /// <summary> The Adapter index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The grid column </summary>
internal int SLSGridColumn;
/// <summary> The grid index </summary> /// <summary> The grid index </summary>
internal int SLSGridIndex; internal int SLSGridIndex;
/// <summary> The grid bit mask identifies the number of bits DisplayMap is currently using. </summary>
internal int SLSGridMask;
/// <summary>The grid row. </summary> /// <summary>The grid row. </summary>
internal int SLSGridRow; internal int SLSGridRow;
/// <summary> The grid column </summary>
internal int SLSGridColumn;
/// <summary> The grid bit mask identifies the number of bits DisplayMap is currently using. </summary>
internal int SLSGridMask;
/// <summary> The grid bit value identifies the display status. </summary> /// <summary> The grid bit value identifies the display status. </summary>
internal int SLSGridValue; internal int SLSGridValue;
} }
@ -757,58 +759,59 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLSLSMap internal struct ADLSLSMap
{ {
/// <summary> The current grid </summary>
internal ADLSLSGrid Grid;
/// <summary> The Adapter Index </summary> /// <summary> The Adapter Index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The first bezel mode array index in the native mode array </summary>
internal int FirstBezelModeArrayIndex;
/// <summary> The first bezel offset array index in the native mode array </summary>
internal int FirstBezelOffsetArrayIndex;
/// <summary>The first native mode array index in the native mode array. </summary>
internal int FirstNativeModeArrayIndex;
/// <summary> The first target array index in the Target array. </summary>
internal int FirstSLSTargetArrayIndex;
/// <summary> The number of bezel modes belongs to this map. </summary>
internal int NumBezelMode;
/// <summary> The number of bezel offsets belongs to this map. </summary>
internal int NumBezelOffset;
/// <summary> The number of native modes belongs to this map. </summary>
internal int NumNativeMode;
/// <summary> The number of display targets belongs to this map. </summary>
internal int NumSLSTarget;
/// <summary> Screen orientation. E.g., 0, 90, 180, 270. </summary>
internal int Orientation;
/// <summary> The current display map index. It is the OS Desktop index. </summary> /// <summary> The current display map index. It is the OS Desktop index. </summary>
internal int SLSMapIndex; internal int SLSMapIndex;
/// <summary> The current grid </summary>
internal ADLSLSGrid Grid;
/// <summary> OS Surface Index </summary>
internal int SurfaceMapIndex;
/// <summary> Screen orientation. E.g., 0, 90, 180, 270. </summary>
internal int Orientation;
/// <summary> The number of display targets belongs to this map. </summary>
internal int NumSLSTarget;
/// <summary> The first target array index in the Target array. </summary>
internal int FirstSLSTargetArrayIndex;
/// <summary> The number of native modes belongs to this map. </summary>
internal int NumNativeMode;
/// <summary>The first native mode array index in the native mode array. </summary>
internal int FirstNativeModeArrayIndex;
/// <summary> The number of bezel modes belongs to this map. </summary>
internal int NumBezelMode;
/// <summary> The first bezel mode array index in the native mode array </summary>
internal int FirstBezelModeArrayIndex;
/// <summary> The number of bezel offsets belongs to this map. </summary>
internal int NumBezelOffset;
/// <summary> The first bezel offset array index in the native mode array </summary>
internal int FirstBezelOffsetArrayIndex;
/// <summary> Bitmask identifies display map status </summary> /// <summary> Bitmask identifies display map status </summary>
internal int SLSMapMask; internal int SLSMapMask;
/// <summary> Bitmask identifies display map status </summary> /// <summary> Bitmask identifies display map status </summary>
internal int SLSMapValue; internal int SLSMapValue;
/// <summary> OS Surface Index </summary>
internal int SurfaceMapIndex;
} }
/// <summary> ADLSLSTarget Structure</summary> /// <summary> ADLSLSTarget Structure</summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLSLSTarget internal struct ADLSLSTarget
{ {
/// <summary> The target ID. </summary>
internal ADLDisplayTarget DisplayTarget;
/// <summary> The Adapter Index </summary> /// <summary> The Adapter Index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The SLS map index. </summary>
internal int SLSMapIndex;
/// <summary> The target ID. </summary>
internal ADLDisplayTarget DisplayTarget;
/// <summary> Target postion X in SLS grid </summary> /// <summary> Target postion X in SLS grid </summary>
internal int SLSGridPositionX; internal int SLSGridPositionX;
/// <summary> Target postion Y in SLS grid </summary> /// <summary> Target postion Y in SLS grid </summary>
internal int SLSGridPositionY; internal int SLSGridPositionY;
/// <summary> The SLS map index. </summary> /// <summary> The view size width, height and rotation angle per SLS Target. </summary>
internal int SLSMapIndex; internal ADLMode ViewSize;
/// <summary> The bit mask identifies the bits in iSLSTargetValue are currently used. </summary> /// <summary> The bit mask identifies the bits in iSLSTargetValue are currently used. </summary>
internal int SLSTargetMask; internal int SLSTargetMask;
/// <summary> The bit mask identifies status info. </summary> /// <summary> The bit mask identifies status info. </summary>
internal int SLSTargetValue; internal int SLSTargetValue;
/// <summary> The view size width, height and rotation angle per SLS Target. </summary>
internal ADLMode ViewSize;
} }
/// <summary> ADLSLSTarget Array</summary> /// <summary> ADLSLSTarget Array</summary>
@ -824,14 +827,14 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLSLSMode internal struct ADLSLSMode
{ {
/// <summary> The target ID. </summary>
internal ADLMode DisplayMode;
/// <summary> The Adapter Index </summary> /// <summary> The Adapter Index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The current display map index. It is the OS Desktop index. </summary> /// <summary> The current display map index. It is the OS Desktop index. </summary>
internal int SLSMapIndex; internal int SLSMapIndex;
/// <summary> The mode index. </summary> /// <summary> The mode index. </summary>
internal int SLSModeIndex; internal int SLSModeIndex;
/// <summary> The target ID. </summary>
internal ADLMode DisplayMode;
/// <summary> The bit mask identifies the number of bits Mode is currently using. </summary> /// <summary> The bit mask identifies the number of bits Mode is currently using. </summary>
internal int SLSNativeModeMask; internal int SLSNativeModeMask;
/// <summary> The bit mask identifies the display status. </summary> /// <summary> The bit mask identifies the display status. </summary>
@ -843,48 +846,49 @@ namespace ATI.ADL
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLBezelTransientMode internal struct ADLBezelTransientMode
{ {
/// <summary> The target ID. </summary>
internal ADLMode DisplayMode;
/// <summary> The Adapter Index </summary> /// <summary> The Adapter Index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The first bezel offset array index in the native mode array. </summary>
internal int FirstBezelOffsetArrayIndex;
/// <summary> The number of bezel offsets belongs to this map. </summary>
internal int NumBezelOffset;
/// <summary> The bit mask identifies the bits this structure is currently using. </summary>
internal int SLSBezelTransientModeMask;
/// <summary> The bit mask identifies the display status. </summary>
internal int SLSBezelTransientModeValue;
/// <summary> SLS Map Index. </summary> /// <summary> SLS Map Index. </summary>
internal int SLSMapIndex; internal int SLSMapIndex;
/// <summary> SLS Mode Index. </summary> /// <summary> SLS Mode Index. </summary>
internal int SLSModeIndex; internal int SLSModeIndex;
/// <summary> The target ID. </summary>
internal ADLMode DisplayMode;
/// <summary> The number of bezel offsets belongs to this map. </summary>
internal int NumBezelOffset;
/// <summary> The first bezel offset array index in the native mode array. </summary>
internal int FirstBezelOffsetArrayIndex;
/// <summary> The bit mask identifies the bits this structure is currently using. </summary>
internal int SLSBezelTransientModeMask;
/// <summary> The bit mask identifies the display status. </summary>
internal int SLSBezelTransientModeValue;
} }
/// <summary> ADLSLSOffset Structure</summary> /// <summary> ADLSLSOffset Structure</summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ADLSLSOffset internal struct ADLSLSOffset
{ {
/// <summary> The target ID. </summary>
internal ADLMode DisplayMode;
/// <summary> The Adapter Index </summary> /// <summary> The Adapter Index </summary>
internal int AdapterIndex; internal int AdapterIndex;
/// <summary> The bit mask identifies the display status. </summary> /// <summary> The current display map index. It is the OS Desktop index. </summary>
internal int BezelOffsetValue; internal int SLSMapIndex;
/// <summary> The target ID. </summary>
internal ADLDisplayID DisplayID;
/// <summary> SLS Bezel Mode Index. </summary> /// <summary> SLS Bezel Mode Index. </summary>
internal int BezelModeIndex; internal int BezelModeIndex;
/// <summary> The bit mask identifies the number of bits Offset is currently using. </summary>
internal int BezelOffsetMask;
/// <summary>SLS Bezel Offset X. </summary> /// <summary>SLS Bezel Offset X. </summary>
internal int BezelOffsetX; internal int BezelOffsetX;
/// <summary>SLS Bezel Offset Y. </summary> /// <summary>SLS Bezel Offset Y. </summary>
internal int BezelOffsetY; internal int BezelOffsetY;
/// <summary> SLS Display Height. </summary>
internal int DisplayHeight;
/// <summary> SLS Display Width. </summary> /// <summary> SLS Display Width. </summary>
internal int DisplayWidth; internal int DisplayWidth;
/// <summary> The current display map index. It is the OS Desktop index. </summary> /// <summary> SLS Display Height. </summary>
internal int SLSMapIndex; internal int DisplayHeight;
/// <summary> The bit mask identifies the number of bits Offset is currently using. </summary>
internal int BezelOffsetMask;
/// <summary> The bit mask identifies the display status. </summary>
internal int BezelOffsetValue;
} }
#endregion ADLSLS #endregion ADLSLS

View File

@ -38,6 +38,8 @@ namespace DisplayMagicianShared.AMD
// Struct to store the Display // Struct to store the Display
public struct AMDDisplay public struct AMDDisplay
{ {
internal string DisplayName;
internal string DisplayConnector;
internal List<ADLMode> DisplayModes; internal List<ADLMode> DisplayModes;
} }
@ -1190,12 +1192,15 @@ namespace DisplayMagicianShared.AMD
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is connected and mapped in Windows OS"); SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is connected and mapped in Windows OS");
// Store the Display information for later ADL.ADLDisplayConnectionType displayConnector = (ADL.ADLDisplayConnectionType)oneDisplayInfo.DisplayConnector;
// Store the Display information for later
AMDDisplay displayToCreate = new AMDDisplay(); AMDDisplay displayToCreate = new AMDDisplay();
displayToCreate.DisplayModes = new List<ADLMode>(); displayToCreate.DisplayModes = new List<ADLMode>();
displayToCreate.DisplayName = oneDisplayInfo.DisplayName;
displayToCreate.DisplayConnector = displayConnector.ToString("G");
ADL.ADLDisplayConnectionType displayConnector = (ADL.ADLDisplayConnectionType)oneDisplayInfo.DisplayConnector;
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} ###");
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Connector = {displayConnector.ToString("G")}"); SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Connector = {displayConnector.ToString("G")}");
@ -1476,8 +1481,6 @@ namespace DisplayMagicianShared.AMD
continue; continue;
} }
// Add it to the list of display identifiers so we can return it
displayIdentifiers.Add(displayIdentifier);
SharedLogger.logger.Debug($"ProfileRepository/GetActiveprofile: DisplayIdentifier: {displayIdentifier}"); SharedLogger.logger.Debug($"ProfileRepository/GetActiveprofile: DisplayIdentifier: {displayIdentifier}");
} }
@ -1519,7 +1522,7 @@ namespace DisplayMagicianShared.AMD
{ {
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: There were no AMD adapters found by AMD ADL."); SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: There were no AMD adapters found by AMD ADL.");
} }
// Return the profile // Return the profile
return profileToCreate; return profileToCreate;
@ -1540,13 +1543,37 @@ namespace DisplayMagicianShared.AMD
return true; return true;
} }
public List<ScreenPosition> GenerateScreenPositions() /*public List<ScreenPosition> GenerateScreenPositions(AMDProfile profileToCreate)
{ {
List<ScreenPosition> screens = new List<ScreenPosition>(); 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; return screens;
} }*/
} }
} }

View File

@ -191,38 +191,66 @@ namespace DisplayMagicianShared.AMD
return IsValid(); return IsValid();
} }
public override bool CreateProfileFromCurrentDisplaySettings()
{
AMDLibrary amdLibrary = AMDLibrary.GetLibrary();
if (amdLibrary.IsInstalled)
{
// Create the profile data from the current config
_profileData = amdLibrary.GetActiveProfile();
// Now, since the ActiveProfile has changed, we need to regenerate screen positions
_screens = GetScreenPositions();
return true;
}
else
{
return false;
}
}
public override List<ScreenPosition> GetScreenPositions() public override List<ScreenPosition> GetScreenPositions()
{ {
if (_screens.Count == 0) // Now we create the screens structure from the AMD profile information
_screens = new List<ScreenPosition>();
if ( _profileData.Adapters.Count > 0)
{ {
// Now we create the screens structure from the AMD profile information foreach ( var adapter in _profileData.Adapters)
_screens = new List<ScreenPosition>();
if ( _profileData.Adapters.Count > 0)
{ {
foreach ( var adapter in _profileData.Adapters) foreach (var display in adapter.Displays)
{ {
foreach (var display in adapter.Displays) foreach (var mode in display.DisplayModes)
{ {
foreach (var mode in display.DisplayModes) ScreenPosition screen = new ScreenPosition();
{ screen.Library = "AMD";
ScreenPosition screen = new ScreenPosition(); //screen.Colour = Color.FromArgb(255,237,28,36); // represents AMD Red
screen.Colour = Color.Red; // represents AMD screen.Colour = Color.FromArgb(200, 237, 28, 36); // represents AMD Red
screen.Name = mode.DisplayID.ToString(); screen.Name = display.DisplayName;
screen.ScreenX = mode.XPos; screen.DisplayConnector = display.DisplayConnector;
screen.ScreenY = mode.YPos; screen.ScreenX = mode.XPos;
screen.ScreenWidth = mode.XRes; screen.ScreenY = mode.YPos;
screen.ScreenHeight = mode.YRes; screen.ScreenWidth = mode.XRes;
screen.IsSpanned = false; screen.ScreenHeight = mode.YRes;
//screen.Features = mode.ModeValue; screen.IsSpanned = false;
// Figure out features
_screens.Add(screen); //ATI.ADL.ADL.ConvertDisplayModeFlags(mode.ModeValue);
}
//screen.Features = mode.ModeValue;
_screens.Add(screen);
} }
} }
} }
} }
return _screens; return _screens;
} }

View File

@ -9,6 +9,7 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using IWshRuntimeLibrary; using IWshRuntimeLibrary;
using DisplayMagicianShared.AMD;
//using WK.Libraries.HotkeyListenerNS; //using WK.Libraries.HotkeyListenerNS;
namespace DisplayMagicianShared namespace DisplayMagicianShared
@ -21,6 +22,7 @@ namespace DisplayMagicianShared
public int ScreenWidth; public int ScreenWidth;
public int ScreenHeight; public int ScreenHeight;
public string Name; public string Name;
public string Library;
public bool IsPrimary; public bool IsPrimary;
public Color Colour; public Color Colour;
public List<string> Features; public List<string> Features;
@ -30,6 +32,7 @@ namespace DisplayMagicianShared
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
@ -192,7 +195,7 @@ namespace DisplayMagicianShared
//public Topology.Path[] Paths { get; set; } = new Topology.Path[0]; //public Topology.Path[] Paths { get; set; } = new Topology.Path[0];
//public VideoLibraryProfileData ProfileData { get; set; } //public virtual object ProfileData { get; set; }
[JsonIgnore] [JsonIgnore]
public virtual ProfileIcon ProfileIcon public virtual ProfileIcon ProfileIcon
@ -360,6 +363,12 @@ namespace DisplayMagicianShared
} }
public virtual bool CreateProfileFromCurrentDisplaySettings()
{
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)
{ {

View File

@ -567,14 +567,17 @@ namespace DisplayMagicianShared
AMDLibrary amdLibrary = AMDLibrary.GetLibrary(); AMDLibrary amdLibrary = AMDLibrary.GetLibrary();
if (amdLibrary.IsInstalled) if (amdLibrary.IsInstalled)
{ {
activeProfile = new AMDProfileItem AMDProfileItem amdProfile = new AMDProfileItem
{ {
Name = "Current Display Profile", Name = "Current Display Profile" ,
ProfileData = amdLibrary.GetActiveProfile() //ProfileData = amdLibrary.GetActiveProfile(),
//Screens = amdLibrary.GenerateScreenPositions()
//ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers() //ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers()
}; };
//activeProfile.ProfileIcon = new ProfileIcon(activeProfile); //activeProfile.ProfileIcon = new ProfileIcon(activeProfile);
//activeProfile.ProfileBitmap = activeProfile.ProfileIcon.ToBitmap(256, 256); //activeProfile.ProfileBitmap = activeProfile.ProfileIcon.ToBitmap(256, 256);
amdProfile.CreateProfileFromCurrentDisplaySettings();
activeProfile = amdProfile;
} }
else { else {
SharedLogger.logger.Debug($"ProfileRepository/UpdateActiveProfile: Trying to access things using the NVIDIA video card driver"); SharedLogger.logger.Debug($"ProfileRepository/UpdateActiveProfile: Trying to access things using the NVIDIA video card driver");

View File

@ -42,35 +42,37 @@ namespace DisplayMagicianShared.UserControls
} }
} }
private void DrawScreen(Graphics g, ScreenPosition screen) /*private void DrawScreen(Graphics g, ScreenPosition screen)
{ {
//var res = ProfileIcon.NormalizeResolution(screens); //var res = ProfileIcon.NormalizeResolution(screens);
var rect = new Rectangle(screen.ScreenX, screen.ScreenY, screen.ScreenWidth, screen.ScreenHeight); var rect = new Rectangle(screen.ScreenX, screen.ScreenY, screen.ScreenWidth, screen.ScreenHeight);
g.FillRectangle(new SolidBrush(Color.FromArgb(15, Color.White)), rect); g.FillRectangle(new SolidBrush(Color.FromArgb(15, Color.White)), rect);
g.DrawRectangle(Pens.Black, rect); g.DrawRectangle(Pens.Black, rect);
/*DrawString(g, path.Position.IsEmpty ? "[Primary]" : $"[{path.Position.X}, {path.Position.Y}]", rect.Size, *//*DrawString(g, path.Position.IsEmpty ? "[Primary]" : $"[{path.Position.X}, {path.Position.Y}]", rect.Size,
new PointF(rect.X + PaddingY / 2, rect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Near);*/ new PointF(rect.X + PaddingY / 2, rect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Near);*//*
var str = $"DISPLAY {screen.Name}{Environment.NewLine}{rect.Width}×{rect.Height}"; var str = $"DISPLAY {screen.Name}{Environment.NewLine}{rect.Width}×{rect.Height}";
var strSize = DrawString(g, str, rect.Size, new PointF(rect.X - PaddingX / 2, rect.Y + PaddingY / 2), var strSize = DrawString(g, str, rect.Size, new PointF(rect.X - PaddingX / 2, rect.Y + PaddingY / 2),
StringAlignment.Near, StringAlignment.Far); StringAlignment.Near, StringAlignment.Far);
var rows = rect.Width < rect.Height ? screen.SpannedScreens.Count : 1;
var cols = rect.Width >= rect.Height ? screen.SpannedScreens.Count : 1;
for (var i = 0; i < screen.SpannedScreens.Count; i++) var rows = rect.Width < rect.Height ? screen.Count : 1;
var cols = rect.Width >= rect.Height ? screen.Count : 1;
for (var i = 0; i < screen.Count; i++)
{ {
DrawTarget(g, screen, DrawTarget(g, screen,
new Rectangle(rect.X + PaddingX, rect.Y + strSize.Height + PaddingY, rect.Width - 2 * PaddingX, new Rectangle(rect.X + PaddingX, rect.Y + strSize.Height + PaddingY, rect.Width - 2 * PaddingX,
rect.Height - strSize.Height - 2 * PaddingY), rect.Height - strSize.Height - 2 * PaddingY),
rows > 1 ? i : 0, cols > 1 ? i : 0, rows, cols); rows > 1 ? i : 0, cols > 1 ? i : 0, rows, cols);
} }
} }*/
private Size DrawString( private Size DrawString(
Graphics g, Graphics g,
string str, string str,
Color colour,
SizeF drawingSize = default(SizeF), SizeF drawingSize = default(SizeF),
PointF? drawingPoint = null, PointF? drawingPoint = null,
StringAlignment vertical = StringAlignment.Center, StringAlignment vertical = StringAlignment.Center,
@ -80,13 +82,13 @@ namespace DisplayMagicianShared.UserControls
{ {
Alignment = horizontal, Alignment = horizontal,
LineAlignment = vertical, LineAlignment = vertical,
FormatFlags = StringFormatFlags.NoClip FormatFlags = StringFormatFlags.NoClip
}; };
var stringSize = g.MeasureString(str, Font, drawingSize, format); var stringSize = g.MeasureString(str, Font, drawingSize, format);
if (drawingPoint != null) if (drawingPoint != null)
{ {
g.DrawString(str, Font, new SolidBrush(ForeColor), new RectangleF(drawingPoint.Value, drawingSize), g.DrawString(str, Font, new SolidBrush(colour), new RectangleF(drawingPoint.Value, drawingSize),
format); format);
} }
@ -202,7 +204,7 @@ namespace DisplayMagicianShared.UserControls
break; break;
} }
*/ *//*
if (screen.IsSpanned) if (screen.IsSpanned)
{ {
var strSize = DrawString(g, str, targetRect.Size, var strSize = DrawString(g, str, targetRect.Size,
@ -218,10 +220,10 @@ namespace DisplayMagicianShared.UserControls
else else
{ {
DrawString(g, str, targetRect.Size, targetRect.Location); DrawString(g, str, targetRect.Size, targetRect.Location);
} }*/
} }
private void DrawView(Graphics g) /*private void DrawView(Graphics g)
{ {
var viewSize = ProfileIcon.CalculateViewSize(_profile.Screens, PaddingX, PaddingY); var viewSize = ProfileIcon.CalculateViewSize(_profile.Screens, PaddingX, PaddingY);
var factor = Math.Min(Width / viewSize.Width, Height / viewSize.Height); var factor = Math.Min(Width / viewSize.Width, Height / viewSize.Height);
@ -235,6 +237,93 @@ namespace DisplayMagicianShared.UserControls
{ {
DrawScreen(g, screen); DrawScreen(g, screen);
} }
}*/
private void DrawView(Graphics g)
{
var viewSize = ProfileIcon.CalculateViewSize(_profile.Screens, PaddingX, PaddingY);
var factor = Math.Min(Width / viewSize.Width, Height / viewSize.Height);
g.ScaleTransform(factor, factor);
var xOffset = (Width / factor - viewSize.Width) / 2f;
var yOffset = (Height / 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;
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);
Rectangle wordRect = new Rectangle(screen.ScreenX + screenBezel + screenWordBuffer, screen.ScreenY + screenBezel + screenWordBuffer, screen.ScreenWidth - (screenBezel * 2) - (screenWordBuffer * 2), screen.ScreenHeight - (screenBezel * 2) - (screenWordBuffer * 2));
Color wordTextColour = pickTextColorBasedOnBgColour(screenBgColour, lightTextColour, darkTextColour);
// Draw the name of the screen and the size of it
var str = $"{screen.Name}{Environment.NewLine}{screen.ScreenWidth}×{screen.ScreenHeight}";
DrawString(g, str, wordTextColour, wordRect.Size, wordRect.Location);
// Draw the position of the screen
str = $"[{screen.ScreenX},{screen.ScreenY}]";
DrawString(g, str, wordTextColour, wordRect.Size, wordRect.Location, StringAlignment.Near, StringAlignment.Near);
}
}
}
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;
}
} }
private void DrawEmptyView(Graphics g) private void DrawEmptyView(Graphics g)