2011-09-09 17 views

答えて

0

ColorTranslatorはSilverlightには存在しません。

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); 
} 

これは、あなたはそれを使用していますToWin32()メソッドを使用することができるようにも(Color.IsKnownColor & Color.ToKnownColor())のSilverlightには存在しないメンバーを使用しています「既知の色」以外のすべてについて:

public static int ToWin32(Color c) 
{ 
    return (int) c.R | (int) c.G << 8 | (int) c.B << 16; 
}