本文整理汇总了C#中NSCoder.DecodeBytesForKey方法的典型用法代码示例。如果您正苦于以下问题:C# NSCoder.DecodeBytesForKey方法的具体用法?C# NSCoder.DecodeBytesForKey怎么用?C# NSCoder.DecodeBytesForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSCoder
的用法示例。
在下文中一共展示了NSCoder.DecodeBytesForKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitWithCoder
public override id InitWithCoder(NSCoder aDecoder)
{
id self = this;
if (aDecoder.AllowsKeyedCoding)
{
int colorSpace = aDecoder.DecodeIntForKey(@"NSColorSpace");
if ((colorSpace == 1) || (colorSpace == 2))
{
int length = 0;
byte[] data = null;
double red = 0.0;
double green = 0.0;
double blue = 0.0;
double alpha = 1.0;
NSString str = null;
NSScanner scanner = null;
if (aDecoder.ContainsValueForKey(@"NSRGB"))
{
data = aDecoder.DecodeBytesForKey(@"NSRGB", ref length);
str = (NSString)NSString.Alloc().InitWithBytes(data, (uint)data.Length, NSStringEncoding.NSASCIIStringEncoding);
scanner = (NSScanner)NSScanner.Alloc().InitWithString(str);
scanner.ScanDouble(ref red);
scanner.ScanDouble(ref green);
scanner.ScanDouble(ref blue);
scanner.ScanDouble(ref alpha);
}
if (colorSpace == 1)
{
self = NSColor.ColorWithCalibratedRed((double)red, (double)green, (double)blue, (double)alpha);
}
else
{
self = NSColor.ColorWithDeviceRed((double)red, (double)green, (double)blue, (double)alpha);
}
}
else if ((colorSpace == 3) || (colorSpace == 4))
{
int length = 0;
byte[] data = null;
double white = 0.0;
double alpha = 0.0;
NSString str = null;
NSScanner scanner = null;
if (aDecoder.ContainsValueForKey(@"NSWhite"))
{
data = aDecoder.DecodeBytesForKey(@"NSWhite", ref length);
str = (NSString)NSString.Alloc().InitWithBytes(data, (uint)data.Length, NSStringEncoding.NSASCIIStringEncoding);
scanner = (NSScanner)NSScanner.Alloc().InitWithString(str);
scanner.ScanDouble(ref white);
scanner.ScanDouble(ref alpha);
}
if (colorSpace == 3)
{
self = NSColor.ColorWithCalibratedWhite((double)white, (double)alpha);
}
else
{
self = NSColor.ColorWithDeviceWhite((double)white, (double)alpha);
}
}
else if (colorSpace == 5)
{
int length = 0;
byte[] data = null;
double cyan = 0.0;
double yellow = 0.0;
double magenta = 0.0;
double black = 0.0;
double alpha = 1.0;
NSString str = null;
NSScanner scanner = null;
if (aDecoder.ContainsValueForKey(@"NSCYMK"))
{
data = aDecoder.DecodeBytesForKey(@"NSCYMK", ref length);
str = (NSString)NSString.Alloc().InitWithBytes(data, (uint)data.Length, NSStringEncoding.NSASCIIStringEncoding);
scanner = (NSScanner)NSScanner.Alloc().InitWithString(str);
scanner.ScanDouble(ref cyan);
scanner.ScanDouble(ref yellow);
scanner.ScanDouble(ref magenta);
scanner.ScanDouble(ref black);
scanner.ScanDouble(ref alpha);
}
self = NSColor.ColorWithDeviceCyan((double)cyan, (double)magenta, (double)yellow, (double)black, (double)alpha);
}
else if (colorSpace == 6)
{
NSString catalog = (NSString)aDecoder.DecodeObjectForKey(@"NSCatalogName");
NSString name = (NSString)aDecoder.DecodeObjectForKey(@"NSColorName");
//NSColor color = (NSColor)aDecoder.DecodeObjectForKey(@"NSColor");
self = NSColor.ColorWithCatalogName(catalog, name);
}
else if (colorSpace == 10)
{
//.........这里部分代码省略.........