本文整理汇总了C#中Color.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# Color.SelectMany方法的具体用法?C# Color.SelectMany怎么用?C# Color.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.SelectMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorSortedSecuenceWrite
public static OperationMessage ColorSortedSecuenceWrite(ushort homeDeviceAddress, byte seconds, Color[] colors)
{
List<byte> args = new List<byte>();
args.Add(seconds);
args.AddRange(colors.SelectMany(c => new byte[] { c.R, c.G, c.B }));
return BaseMessage(OPCodes.ColorSortedSecuenceWrite, homeDeviceAddress, args.ToArray());
}
示例2: FromPixels
/// <summary>
/// Constructs an image from a 2d list of pixels.
/// </summary>
/// <param name="colors">2d rectangular list of colors representing the pixels.</param>
public static Bitmap FromPixels(Color[][] colors)
{
var height = colors.Length;
var width = colors[0].Length;
var rgbVals = colors.SelectMany(row => row);
return FromPixelsHelper(rgbVals, width, height);
}
示例3: Main
static void Main(string[] args)
{
try
{
const string uriText = "net.pipe://localhost/mailnotifier/sign";
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
EndpointAddress endpointAddress = new EndpointAddress(uriText);
MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress);
if (args.Length == 1 && args[0] == "rainbow")
{
var colors = new Color []
{
Color.Red,
Color.Yellow,
Color.Green,
Color.Blue,
Color.Purple
};
var colorBytes = colors
.SelectMany(c => new byte[] { c.R, c.G, c.B })
.ToArray();
Console.WriteLine("Rainbow...");
client.FadeToMultiRgb(colorBytes);
}
else if (args.Length == 3)
{
byte red = byte.Parse(args[0]);
byte green = byte.Parse(args[1]);
byte blue = byte.Parse(args[2]);
Color color = Color.FromArgb(red, green, blue);
client.SetColorRgb(color.R, color.G, color.B);
Console.WriteLine("Color set to " + color.Name);
}
else if (args.Length == 4 && args[0] == "fade")
{
byte red = byte.Parse(args[1]);
byte green = byte.Parse(args[2]);
byte blue = byte.Parse(args[3]);
Console.WriteLine("Fading...");
client.FadeToRgb(red, green, blue);
}
else if (args.Length != 1)
{
return;
}
else
{
Color color = Color.FromName(args[0]);
byte red = RoundToNotifierColorValue(color.R);
byte green = RoundToNotifierColorValue(color.G);
byte blue = RoundToNotifierColorValue(color.B);
client.SetColorRgb(red, green, blue);
var notifierColor = Color.FromArgb(red, green, blue);
Console.WriteLine("Color set to " + notifierColor.Name);
}
client.Close();
}
catch (Exception e)
{
Console.WriteLine("She broke. :(" + e);
Console.ReadLine();
}
}