Resolved How to extract colors from ProfessionalColorTable

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
47
Programming Experience
10+
I'm looking at MS' code

public class ProfessionalColorTable

and see many tables of color:



'Private void InitCommonColors(ref Dictionary<knowncolors, color> rgbTable)
'internal void InitSystemColors(ref Dictionary<knowncolors, color> rgbTable)
'internal void InitOliveLunaColors(ref Dictionary<knowncolors, color> rgbTable)
'internal void InitSilverLunaColors(ref Dictionary<knowncolors, color> rgbTable)
'Private void InitRoyaleColors(ref Dictionary<knowncolors, color> rgbTable)
'internal void InitThemedColors(ref Dictionary<knowncolors, color> rgbTable)
'internal void InitBlueLunaColors(ref Dictionary<knowncolors, color> rgbTable)



I can see the color definitions and would like to extract the tables but can't figure out how to do that.

If I could use VB.Net to enumerate using Reflection somehow to get the entries that would be great.

Got any suggestions as to how I can do that?



The above is what I really need but if you happen to know anything about

DisplayInformation.LowResolution

which I see used there but never set, I'm curious about that.



I
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,438
Location
Norway
Programming Experience
10+
VB.NET:
Dim table As New ProfessionalColorTable
Dim mInfo = table.GetType.GetMethod("InitBlueLunaColors", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
Dim pType = mInfo.GetParameters(0).ParameterType
Dim typeArgs = pType.GetGenericArguments
Dim genericType = GetType(Dictionary(Of ,)).MakeGenericType(typeArgs)
Dim dict = CType(Activator.CreateInstance(genericType), IDictionary)
mInfo.Invoke(table, {dict})

Dim aKey = System.Enum.Parse(typeArgs(0), "msocbvcrWPText")
Dim aValue = dict(aKey)
 

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
47
Programming Experience
10+
Amazing! So close but I havn't been able to enumerate all the colors in a table.
I keep bumpig up against KnoenColors enum is marked internal. At least that is what I think my problem is.
Can you enumerate all the colors in a table.
I see that to get a key you hard coded "msocbvcrWPText"
I've been trying to get that string programmatically and can't fid the way.
 
Top Bottom