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());
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        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();
            }
        }