/// <summary>
/// This method receives three parameters and returns a color object from those values.
/// In VFP, this method returned a value whereas, in this case we are actually returning
/// a System.Drawing.Color object.
/// <p/><pre>
/// Example:
/// Color o = VFPToolkit.common.RGB(255,255,255);
/// </pre>
/// </summary>
/// <param name="R"></param>
/// <param name="G"></param>
/// <param name="B"></param>
/// <returns></returns>
public static System.Drawing.Color RGB(int R, int G, int B)
{
return System.Drawing.Color.FromArgb(R,G,B);
}
Why creating a new function, when you can already use directly Color.FromArgb(r,g,b) ?
The only reason RGB() was implemented in X# is because it is a function available in VO, used in conjunction with the system classes of VO, some of which indeed expect colors in the form of dword values. In Windows.Forms/.Net GDI classes, there's a special class used for representing Colors, that's the Color class, so you'd normally simply use the static method of this class, to obtain your desired color with Color.FromArgb().
Why creating a new function, when you can already use directly Color.FromArgb(r,g,b) ?
FoxPro compatibility, so we don’t have to change VFP code.
Ah, OK, so there's a function named RGB() also in VFP? What value does it return? Obviously not a System.Drawing.Color...
In case it does not return a numeric value (which I suspect it does), then we will need to do what Robert said, move the current RGB() function to the XSharp.VO library, and implement a new one in XSharp.VFP, which will behave exactly as it behaves in VFP. People who port VO apps will be using the XSharp.VO library and people porting VFP apps will be using the XSharp.VFP library.
See my code sample to Robert above where the VFP Toolkit for .Net has a RGB() function to return Color type.
Most all VFP Functions have been implemented in .Net flavor in that Toolkit.
OK, so people who will be using the Toolkit, will be using this version of RGB(). But in order to be fully compatible with VFP in the official X# runtime/VFP dialect, we will probably need to implement RGB() in a way that it returns the same thing as it does in VFP. Possibly the already implemented function will do.