在silverlight 4中的System.Drawing.ColorTranslator.ToOle

Silverlight 4中System.Drawing.ColorTranslator.ToOle的等价性是什么?

这是我的代码:

.Range(“C1:F23”)。Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.FromArgb(100,255,255,153))''这一行是失败..

Silverlight中不存在ColorTranslator。

DotPeek显示下面的System.Drawing.ColorTranslator.ToOle()的来源:

 public static int ToOle(Color c) { if (c.IsKnownColor) { switch (c.ToKnownColor()) { case KnownColor.ActiveBorder: return -2147483638; case KnownColor.ActiveCaption: return -2147483646; case KnownColor.ActiveCaptionText: return -2147483639; case KnownColor.AppWorkspace: return -2147483636; case KnownColor.Control: return -2147483633; case KnownColor.ControlDark: return -2147483632; case KnownColor.ControlDarkDark: return -2147483627; case KnownColor.ControlLight: return -2147483626; case KnownColor.ControlLightLight: return -2147483628; case KnownColor.ControlText: return -2147483630; case KnownColor.Desktop: return -2147483647; case KnownColor.GrayText: return -2147483631; case KnownColor.Highlight: return -2147483635; case KnownColor.HighlightText: return -2147483634; case KnownColor.HotTrack: return -2147483622; case KnownColor.InactiveBorder: return -2147483637; case KnownColor.InactiveCaption: return -2147483645; case KnownColor.InactiveCaptionText: return -2147483629; case KnownColor.Info: return -2147483624; case KnownColor.InfoText: return -2147483625; case KnownColor.Menu: return -2147483644; case KnownColor.MenuText: return -2147483641; case KnownColor.ScrollBar: return int.MaxValue; case KnownColor.Window: return -2147483643; case KnownColor.WindowFrame: return -2147483642; case KnownColor.WindowText: return -2147483640; case KnownColor.ButtonFace: return -2147483633; case KnownColor.ButtonHighlight: return -2147483628; case KnownColor.ButtonShadow: return -2147483632; case KnownColor.GradientActiveCaption: return -2147483621; case KnownColor.GradientInactiveCaption: return -2147483620; case KnownColor.MenuBar: return -2147483618; case KnownColor.MenuHighlight: return -2147483619; } } return ColorTranslator.ToWin32(c); } 

这使用了Silverlight(Color.IsKnownColor&Color.ToKnownColor())中不存在的成员,所以你可以使用ToWin32()方法,除了“已知颜色”

 public static int ToWin32(Color c) { return (int) cR | (int) cG << 8 | (int) cB << 16; }