Exemplo n.º 1
0
        private static void TestDevice(AlniTimeBoxDevice box)
        {
            //box.ShowPixelArt(COLOR_TEXT_MOM);

            //box.ShowPixelArt(PixelTextHelper.CharToPixelColors(PixelTextHelper.TEXT_CHAR_A, Color.Green));
            //box.ShowPixelArt(PixelTextHelper.CharsToPizelColorsWord(Color.Green, PixelTextHelper.TEXT_CHAR_A));
            string testText = "DAD";

            testText = "abc";
            testText = "bbc";
            testText = "mom";
            Color testColor = Color.Green;

            testColor = Color.DarkRed;
            testColor = Color.Teal;
            testColor = Color.Gold;
            bool[][][] pixelCharText = PixelTextHelper.TextToPixelChars(testText.ToUpper());

            Color[][] pixelText = PixelTextHelper.CharsToPixelColorsWord(pixelCharText, testColor);


            pixelText = CreateMessage(
                "god \n jul".Split(' '), // Merry Christmas in Norwegian
                new Color[] { Color.White, Color.Black, Color.Red }
                );

            /*pixelText = CreateMessage(
             *  "pap \n pa".Split(' '), // Dad in Norwegian
             *  new Color[] { Color.Gray, Color.Black, Color.Gray }
             * );
             *
             * pixelText = CreateMessage(
             *  "mam \n ma".Split(' '), // Mom in Norwegian
             *  new Color[] { Color.Magenta, Color.Black, Color.Magenta }
             * );
             *
             * pixelText = CreateMessage(
             *  "dad \n".Split(' '),
             *  new Color[] { Color.Gray, Color.Black, Color.Gray }
             * );
             *
             * pixelText = CreateMessage(
             *  "mom \n".Split(' '),
             *  new Color[] { Color.Magenta, Color.Black, Color.Magenta }
             * );*/

            pixelText = CreateMessage(
                "123 \n 456".Split(' '),
                new Color[] { Color.DarkBlue, Color.Black, Color.DarkRed }
                );

            pixelText = CreateMessage(
                "789 \n 000".Split(' '),
                new Color[] { Color.DarkBlue, Color.Black, Color.DarkRed }
                );

            //Color[][] pixelText = PixelTextHelper.CharsToPixelColorsWord(PIXEL_TEXT_DAD, Color.Green);
            Color[][] pixelTextFilled = PixelTextHelper.FillDimensions(pixelText);
            box.ShowPixelArt(pixelTextFilled);
            //box.ShowPixelArt(COLOR_ART_PIZZA);

            //box.SetTempUnit(fahrenheit: false);
            //box.SetTempUnitAndColor(Color.Aqua, fahrenheit: false);

            //box.SetVolume(0);
            //box.SetVolume(16);

            //box.ShowImage("C:\\Work\\projects\\Knom.TimeBox\\src\\SampleApp\\testdata\\squares.png");
            //box.SetView(TimeBoxDevice.ViewType.Image);
            //Thread.Sleep(1000);
            //box.ShowImage("C:\\Users\\alexa\\Desktop\\1f355.png");

            //box.AnimateImages("C:\\Work\\projects\\Knom.TimeBox\\src\\SampleApp\\testdata\\exp");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            AlniTimeBoxDevice box = new AlniTimeBoxDevice();

            box.Connect();

            //box.SetView(TimeBoxDevice.ViewType.Clock);
            box.SetTimeColor(Color.Orange);
            box.SetTime(DateTime.Now);

            //TestDevice(box);

            while (true)
            {
                string[] _params = Console.ReadLine().Split(' ');
                string   command = _params[0];
                if (command == "write")
                {
                    _params = string.Join(" ", _params.Skip(1).ToArray()).Split(';');
                    string[]     text   = _params[0].Replace("|", "\n").Split(' ');
                    string[]     color  = _params[1].Split(' ');
                    List <Color> colors = new List <Color>();
                    foreach (string _color in color)
                    {
                        colors.Add(ColorTranslator.FromHtml(_color));
                    }

                    Color[][] message = CreateMessage(
                        text,
                        colors.ToArray()
                        );

                    Color[][] messageFilled = PixelTextHelper.FillDimensions(message);

                    box.ShowPixelArt(messageFilled);
                }
                else if (command == "view")
                {
                    TimeBoxDevice.ViewType defaultView = TimeBoxDevice.ViewType.Clock;
                    TimeBoxDevice.ViewType viewType    = defaultView;
                    if (_params.Length > 1)
                    {
                        string arg = _params[1];
                        try
                        {
                            Type enumType = typeof(TimeBoxDevice.ViewType);

                            viewType = (TimeBoxDevice.ViewType)Enum.Parse(enumType, arg);
                            if (Enum.IsDefined(enumType, viewType) == false)
                            {
                                viewType = defaultView;
                            }
                        }
                        catch (ArgumentException)
                        {
                            viewType = defaultView;
                        }
                    }
                    box.SetView(viewType);
                }
            }
            //Thread.Sleep(Int32.MaxValue);
        }