Page 1 of 1

Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 8:17 am
by BCTest
Hi,

looks like I made something seriously stupid but I don't know how to troubleshoot.
I want to use
Color.ControlDarkDark
(https://docs.microsoft.com/de-de/dotnet ... work-4.7.2) in Ranorex but got a compiler error
Error CS0117: 'System.Drawing.Color' enthält keine Definition für 'ControlDarkDark'.
('System.Drawing.Color' does not contain a definition for 'ControlDarkDark'.)
How can I solve it?
:oops:

BTW:
Color.Red
eg. works.

Thanks in advance,
bctest

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 8:21 am
by BCTest
Just an addition:
Validate.AttributeEqual(repo.ReportItemInfo, "BackColor", "ControlDarkDark");
works fine.

Regards,
bcTest

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 8:23 am
by odklizec
Hi,

Please post entire code, include applied "usings".

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 8:38 am
by BCTest
Here:
        private void Init()
        {
            var colorRed = System.Drawing.Color.Red;
            var colorDarkGray = System.Drawing.Color.DarkGray;
            var colorSysGray = System.Drawing.Color.ControlDarkDark;
        }
color.png

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 9:23 am
by odklizec
Hi,

Apparently, ControlDarkDark cannot be used directly, as other colors? Maybe it's available in higher .NET version? But it's definitely not available in 4.7.2...
ControlDarkDark.png
But you can do it this way:

Code: Select all

var colorSysGray = System.Drawing.Color.FromName("ControlDarkDark");
You may find this link useful...
http://rnddev.blogspot.com/2011/03/any- ... s-net.html

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 1:03 pm
by BCTest
Hi odklizec,

yes, your hint was very useful,
thanks a lot.

Only to clarify: the link I posted before (https://docs.microsoft.com/de-de/dotnet ... work-4.7.2) was from Microsoft for Framework 4.7.2. so this color should be definied ... at least that's what the documentation says.

Nevermind now it works for me.

Regards,
bcTest

Re: Rx 9.3.2 with .NET 4.7.2: Using Named Colors

Posted: Fri Oct 23, 2020 1:08 pm
by odklizec
Hi,

Yes, I saw in the doc, that it should work with 4.7.2, except it does not :D Anyway, the workaround should be viable substitute.