public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    const string text = "Hello World";
                    int textWidth, textHeight;

                    Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
                    font.ComputeExtent(text, out textWidth, out textHeight);
                    int textX = (Dimensions.Width - textWidth)/2;

                    var rand = new Random();

                    for (int x = 0; x < 3; x++)
                    {
                        int baseColor = rand.Next(0xffff);
                        for (int i = 0; i < Dimensions.Height; i++)
                        {
                            bmp.Clear();
                            bmp.DrawText(text, font, (Color) (((255 - i) << 16) | baseColor), textX, i);
                            bmp.Flush();
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    bmp.DrawLine(Colors.Red, 1,
                                 Dimensions.Width/2, Dimensions.Height/2,
                                 Dimensions.Width, Dimensions.Height/2);

                    bmp.DrawLine(Colors.Green, 1,
                                 Dimensions.Width/2, Dimensions.Height/2,
                                 Dimensions.Width/2, 0);

                    bmp.Flush();
                }

                Thread.Sleep(3000);
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
 public void DisplayFile(string fileName)
 {
     var bitmap = new Bitmap(320, 240);
     var image = _sdCardDevice.LoadBitmap(fileName, Bitmap.BitmapImageType.Jpeg);
     bitmap.DrawImage((320 - image.Width) / 2, (240 - image.Height) / 2, image, 0, 0, image.Width, image.Height);
     bitmap.Flush();
 }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var rand = new Random();

                    for (int i = 0; i < 100; i++)
                    {
                        var fillColor = (Color)rand.Next(0xFFFFFF);
                        bmp.DrawRectangle((Color) rand.Next(0xFFFFFF), rand.Next(1),
                                          rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                          rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                          0, 0, fillColor, 0, 0, fillColor, 0, 0, (ushort) rand.Next(256));
                        bmp.Flush();
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
        public override void Run()
        {
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                using (var img = Resources.GetBitmap(Resources.BitmapResources.compass2))
                {
                    int da = 3;
                    for (int angle = 0; angle <= 360 && angle >= 0; angle += da)
                    {
                        bitmap.DrawRectangle(Colors.White, 0, 0, 0,
                                             Dimensions.Width, Dimensions.Height,
                                             0, 0, Colors.White, 0, 0, Colors.White, 0, 0,
                                             Bitmap.OpacityOpaque);

                        int xdst = (Dimensions.Width - img.Width)/2,
                            ydst = (Dimensions.Height - img.Height)/2;
                        bitmap.RotateImage(angle, xdst, ydst, img, 0, 0, img.Width, img.Height, 0x00);
                        
                        bitmap.Flush();

                        if (angle > 180)
                            da = -da;
                    }
                }
            }
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    int size = System.Math.Min(Dimensions.Width, Dimensions.Height);

                    for (int i = 0; i < size; ++i)
                        bmp.SetPixel(i, i, (Color)((255 - i) << 16));

                    for (int i = 0; i < size; i += 2)
                        bmp.SetPixel(size - i, i, (Color)(i << 8));

                    bmp.Flush();
                }

                Thread.Sleep(3000);
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var bitmaps = new[]
                                      {
                                          Resources.BitmapResources.cat2,
                                          Resources.BitmapResources.cat1,
                                          Resources.BitmapResources.cat3
                                      };

                    for (int i = 0; i < bitmaps.Length; i++)
                    {
                        using (Bitmap src = Resources.GetBitmap(bitmaps[i]))
                            bmp.DrawImage(0, 0, src, 0, 0, src.Width, src.Height);

                        bmp.Flush();

                        Thread.Sleep(2000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #8
0
        public static void Main()
        {
            LCD myApplication = new LCD();

            Window mainWindow = myApplication.CreateWindow();
            
            // Start the application
            //myApplication.Run(mainWindow);

            Bitmap bitmap1 = new Bitmap(SystemMetrics.ScreenWidth,SystemMetrics.ScreenHeight);
            Bitmap bitmap2 = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

            int ox = 0;
            int oy = 0;
            int rx = bitmap1.Width;
            int ry = bitmap1.Height;
            int sd=0;
            if (rx < ry)
                sd = rx;
            else
                sd = ry;


	    //
	    // Draw Diagonals
	    //
            bitmap1.DrawLine(Colors.Blue, 3, 0, 0, rx, ry);
            bitmap1.DrawLine(Colors.Blue, 3, rx, 0, 0, ry);

            bitmap2.DrawLine(Colors.Red, 3, 0, 0, rx, ry);
            bitmap2.DrawLine(Colors.Red, 3, rx, 0, 0, ry);


            for(int ioff=0; ioff < sd; ioff += 10)
	    {
		int oX  = ox+ioff;
		int oY  = oy+ioff;
		int wX  = rx - 2*ioff;
		int wY  = ry - 2*ioff;
                bitmap1.DrawRectangle(Colors.White, 1, oX, oY, wX, wY, 1, 1, 
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);
                bitmap2.DrawEllipse(Colors.White, rx/2, ry/2, wX, wY);
	    }

            


            while (true)
            {
                bitmap1.Flush();
                Thread.Sleep(250);
                bitmap2.Flush();
                Thread.Sleep(200);
            }

        }
        public override void Run()
        {
            Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                for (int i = 0; i < 4; i++)
                {
                    bitmap.Clear();
                    bitmap.Flush();
                    Thread.Sleep(1000);

                    bitmap.DrawTextInRect("kodFilemon\n.blogspot\n.com", 0, 10,
                                          Dimensions.Width, Dimensions.Height-10,
                                          Bitmap.DT_AlignmentCenter, Colors.White, font);
                    bitmap.Flush();
                    Thread.Sleep(1000);
                }
            }
        }
Beispiel #10
0
        public static void Main()
        {
            int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
            HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                                      out bitsPerPixel, out orientationDeg);
            //prepare background with a color gradient
            Bitmap backgroundImg = new Bitmap(screenWidth, screenHeight);
            backgroundImg.DrawRectangle(Color.White,           // outline color
                                        0,                     // outline thickness
                                        0, 0,                  // x and y of top left corner
                                        backgroundImg.Width,   // width
                                        backgroundImg.Height,  // height
                                        0, 0,                  // x and y corner radius
                                        Color.White,           // gradient start color
                                        0, 0,                  // gradient start coordinates
                                        Color.Black,           // gradient end color
                                        backgroundImg.Width,   // gradient end x coordinate
                                        backgroundImg.Height,  // gradient end y coordinate
                                        Bitmap.OpacityOpaque); // opacity
            //prepare a working buffer to hold graphics before flushing to display
            Bitmap bufferImg = new Bitmap(screenWidth, screenHeight);
            //our ball
            Bitmap soccerBallImg = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
            //make background of the ball transparent
            //using the color of top left corner pixel
            soccerBallImg.MakeTransparent(soccerBallImg.GetPixel(0, 0));

            int x = 100;
            int y = 50;
            int xOfs = 1;
            int yOfs = 1;
            while (true)
            {
                //copy background to buffer
                bufferImg.DrawImage(0, 0, backgroundImg, 0, 0,
                                    backgroundImg.Width, backgroundImg.Height);
                //paint moving sprite object
                bufferImg.DrawImage(x, y,     // destination coordinates
                                    soccerBallImg, // source image
                                    0, 0,       // source coordinates
                                    soccerBallImg.Width, soccerBallImg.Height,
                                    Bitmap.OpacityOpaque);
                bufferImg.Flush(); //flush buffer to display
                Thread.Sleep(10);
                //invert direction if ball bounces at a wall
                if (x <= 0 || x >= screenWidth - soccerBallImg.Width)
                    xOfs = -xOfs;
                if (y <= 0 || y >= screenHeight - soccerBallImg.Height)
                    yOfs = -yOfs;
                //calculate new coordinates
                x += xOfs;
                y += yOfs;
            }
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    //var resId = Resources.BitmapResources.smile;
                    var resId = Resources.BitmapResources.spotlogo110;
                    using (Bitmap src = Resources.GetBitmap(resId))
                    {
                        if(resId == Resources.BitmapResources.smile)
                            src.MakeTransparent(src.GetPixel(0,0));

                        var rand = new Random();

                        int xPos = rand.Next(Dimensions.Width - src.Width);
                        int yPos = rand.Next(Dimensions.Height - src.Height);

                        int xDir = 3;
                        int yDir = 4;

                        for (int animcount = 0; animcount < 100; animcount++)
                        {
                            bmp.Clear();
                            bmp.DrawImage(xPos, yPos, src, 0, 0, src.Width, src.Height);
                            bmp.Flush();

                            xPos = xPos + xDir;
                            yPos = yPos + yDir;

                            if (xPos + src.Width > bmp.Width || xPos < 0)
                            {
                                xDir = -xDir;
                                xPos += xDir;
                            }
                            if (yPos + src.Height > bmp.Height || yPos < 0)
                            {
                                yDir = -yDir;
                                yPos += yDir;
                            }

                            Thread.Sleep(10);
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #12
0
        public static void Main()
        {
            LCD myApplication = new LCD();

            Window mainWindow = myApplication.CreateWindow();
            
            // Start the application
            //myApplication.Run(mainWindow);

            Bitmap bitmap1 = new Bitmap(SystemMetrics.ScreenWidth,SystemMetrics.ScreenHeight);
            Bitmap bitmap2 = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

            int ox = 0;
            int oy = 0;
            int rx = bitmap1.Width;
            int ry = bitmap1.Height;
            int sd=0;
            if (rx < ry)
                sd = rx;
            else
                sd = ry;


            bitmap1.DrawLine(Colors.Blue, 1, 0, 0, rx, ry);
            bitmap1.DrawLine(Colors.Blue, 1, rx, 0, 0, ry);
            bitmap1.DrawRectangle(Color.White, 10, ox, oy, rx, ry, 1, 1, 
                Color.White, ox, oy, Color.White, rx, ry, 0xFF);

            for(int i=0; i < sd; i += 10)
                bitmap1.DrawRectangle(Color.White, 1, ox+i, oy+i, rx-i, ry-i, 1, 1, 
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);

            
            bitmap2.DrawLine(Colors.Black, 1, 0, 0, rx, ry);
            bitmap2.DrawLine(Microsoft.SPOT.Presentation.Media.Color.Black, 1, rx, 0, 0, ry);

            for (int i = 0; i < sd; i += 10)
                bitmap1.DrawRectangle(Color.White, 1, ox + i, oy + i, rx - i, ry - i, 1, 1,
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);

            while (true)
            {
                bitmap1.Flush();
                Thread.Sleep(50);
                bitmap2.Flush();
                Thread.Sleep(50);
            }

        }
Beispiel #13
0
 public static void Main()
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     Bitmap soccerBall = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
     bmp.StretchImage(100, 50,            // destination coordinates
                   soccerBall,            // source image
                   soccerBall.Width / 2,  // half width
                   soccerBall.Height * 2, // double height
                   Bitmap.OpacityOpaque); // opacity
     bmp.Flush();
     Thread.Sleep(-1); //do not terminate app to see result
 }
        public static void Main()
        {
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);
            _display.DrawText("Waiting.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            var connection = new Connection("COM3", new CSVChannel());
            connection.Open();
            connection.OnReceived+=connection_OnReceived;
            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var bitmaps = new[]
                                      {
                                          Resources.BitmapResources.out0,
                                          Resources.BitmapResources.out1,
                                          Resources.BitmapResources.out2
                                      };

                    for (int i = 0; i < bitmaps.Length; i++)
                    {
                        using (Bitmap src = Resources.GetBitmap(bitmaps[i]))
                        {
                            for (int s = 0; ; s += 3)
                            {
                                int w = s * Dimensions.Width / 200;
                                int h = s * Dimensions.Height / 200;

                                if (w > (Dimensions.Width) && h > (Dimensions.Height))
                                    break;

                                int x = (Dimensions.Width - w) / 2;
                                int y = (Dimensions.Height - h) / 2;

                                bmp.StretchImage(x, y, src, w, h, 256);
                                bmp.Flush();

                                
                            }
                        }

                        Thread.Sleep(1000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #16
0
 static void Main(string[] args)
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     bmp.DrawRectangle(Color.White,           // outline color
                       1,                     // outline thickness
                       100, 100,              // x and y of top left corner
                       200, 100,              // width and height
                       10, 30,                // x and y corner radius
                       Color.White,           // gradient start color
                       0, 0,                  // gradient start coordinate
                       Color.White,           // gradient end color
                       0, 0,                  // gradient end coordinate
                       Bitmap.OpacityOpaque); // opacity
     bmp.Flush();
     Thread.Sleep(-1); //do not terminate app to see result
 }
Beispiel #17
0
 public static void Main()
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     Bitmap soccerBall = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
     //make background of the ball transparent
     //using the color of top left corner pixel
     soccerBall.MakeTransparent(soccerBall.GetPixel(0, 0));
     bmp.DrawImage(100, 50,               // destination coordinates
                   soccerBall,            // source image
                   0, 0,                  // source coordinates
                   soccerBall.Width,      // source width
                   soccerBall.Height,     // source height
                   Bitmap.OpacityOpaque); // opacity
     bmp.Flush();
     Thread.Sleep(-1); //do not terminate app to see result
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
            HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                                      out bitsPerPixel, out orientationDeg);
            Bitmap bmp = new Bitmap(screenWidth, screenHeight);
            //drawing white background
            bmp.DrawRectangle(Color.White,           // outline color
                              0,                     // outline thickness
                              0, 0,                  // x and y of top left corner
                              bmp.Width, bmp.Height, // width and height
                              0, 0,                  // y and y corner radius
                              Color.White,           // gradient start color
                              0, 0,                  // gradient start coordinates
                              Color.White,           // gradient end color
                              0, 0,                  // gradient end coordinates
                              Bitmap.OpacityOpaque); // reduced opacity

            Color[] colors = new Color[] {
                                   ColorUtility.ColorFromRGB(0xFF, 0, 0), // red
                                   ColorUtility.ColorFromRGB(0, 0xFF, 0), // green
                                   ColorUtility.ColorFromRGB(0, 0, 0xFF)  // blue
            };

            for (int i = 0; i < colors.Length; ++i)
            {
                Color color = colors[i];
                bmp.DrawRectangle(color,                    // outline color
                                  0,                        // outline thickness
                                  50 + i * 20, 50 + i * 20, // x and y of top left corner
                                  200, 100,                 // width and height
                                  0, 0,                     // x and y corner radius
                                  color,                    // gradient start color
                                  0, 0,                     // gradient start coordinates
                                  color,                    // gradient end color
                                  0, 0,                     // gradient end coordinates
                                  64);                      // reduced opacity
            }

            bmp.Flush();
            Thread.Sleep(-1); //do not terminate app to see result
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var fonts = new[]
                                    {
                                        new FontItem {Name = "Arial 10", FontId = Resources.FontResources.arial10},
                                        new FontItem {Name = "Small", FontId = Resources.FontResources.small},
                                        new FontItem {Name = "Courier 11", FontId = Resources.FontResources.courier11}
                                    };

                    const string s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

                    foreach (var font in fonts)
                    {
                        bmp.Clear();

                        Font fnt = Resources.GetFont(font.FontId);

                        bmp.DrawRectangle((Color)0xFF0000, 0, 0, 0,
                                          Dimensions.Width, Dimensions.Height,
                                          0, 0, (Color)0xFF0000, 0, 0, (Color)0xFF0000, 0, 0,
                                          Bitmap.OpacityOpaque);

                        const Color color = (Color)0x0000FF;
                        bmp.DrawTextInRect(font.Name + " " + s, 0, 0, Dimensions.Width, Dimensions.Height,
                                           Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft, color, fnt);

                        bmp.Flush();

                        Thread.Sleep(5000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #20
0
 public static void Main()
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     Font font = Resources.GetFont(Resources.FontResources.NinaB);
     string text = "There is another overload of the DrawTextInRect " +
                   "method. That method comes along with reference " +
                   "parameters for the input string and the x and y " +
                   "drawing positions. After drawing text, the " +
                   "method updates the x and y positions to tell you " +
                   "where on the display the drawing of the text " +
                   "finished. This allows you to draw parts of the text " +
                   "with a different color or font. Also, if the method " +
                   "cannot display the complete text within the specified " +
                   "rectangle, it returns the remaining text. " +
                   "In this case, the method returns false to indicate " +
                   "that there is some text left that could not " +
                   "displayed. This enables you to build up a display " +
                   "to show text over mulitple pages.";
     bool completed;
     do
     {
         int x = 0;
         int y = 0;
         //draw frame around text and clear old contents
         bmp.DrawRectangle(Color.White, 1, 20, 20, 150, 150, 0, 0, Color.Black, 0, 0, Color.Black, 0, 0, Bitmap.OpacityOpaque);
         completed = bmp.DrawTextInRect(
                              ref text,
                              ref x, ref y, // x and y text position
                              20, 20,       // x and y (rectangle top left)
                              150, 150,     // width and height of rectangle
                              Bitmap.DT_AlignmentLeft | Bitmap.DT_WordWrap,
                              Color.White,  // color
                              font);        // font
         bmp.Flush();
         Thread.Sleep(3000); //display each page for three seconds
     } while (!completed);
     Thread.Sleep(-1);
 }
        public override void Run()
        {
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                try
                {
                    bitmap.Clear();

                    using (Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Jpeg01Normal))
                        bitmap.DrawImage(0, 0, bmp, 0, 0, bmp.Width, bmp.Height);

                    bitmap.Flush();
                    Thread.Sleep(3000);
                    Pass = true;
                }
                catch (Exception e)
                {
                    UnexpectedException(e);
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// A demonstration as to how to handle multiple button presses at the same time
        /// </summary>

        public static void Main()
        {

            ButtonHelper.ButtonSetup = new Buttons[]{ Buttons.TopRight, Buttons.MiddleRight, Buttons.BottomRight,};
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;

            buttonStates = new Hashtable();
            buttonStates.Add(Buttons.TopRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.MiddleRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.BottomRight, ButtonDirection.Up);

            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            _display.DrawText("Hello world.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
        public override void Run()
        {
            try
            {
                Font font = Resources.GetFont(Resources.FontResources.small);
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    uint[] flags = { 
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft,
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentCenter,
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentRight
                                   };


                    const string s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

                    for (int i = 0; i < flags.Length; i++)
                    {
                        bmp.DrawRectangle((Color) 0xFF0000, 0, 0, 0,
                                          Dimensions.Width, Dimensions.Height,
                                          0, 0, (Color) 0xFF0000, 0, 0, (Color) 0xFF0000, 0, 0,
                                          Bitmap.OpacityOpaque);

                        const Color color = (Color)0x0000FF;
                        bmp.DrawTextInRect(s, 0, 0, Dimensions.Width, Dimensions.Height,
                                           flags[i], color, font);

                        bmp.Flush();

                        Thread.Sleep(2000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #24
0
        public static void Main()
        {
            IPAddress Server = IPAddress.Parse("1.2.3.4");
            string SharedSecret = "SharedSecret";
            string UserName = "******";
            string UserPassword = "******";

            Bitmap screen = new Bitmap(320, 240);   // emulator display size
            Font font = Resources.GetFont(Resources.FontResources.NinaB);

            RadiusResult result;
            using (Client client = new Client(Server, SharedSecret))
            {
                client.AddAttribute(AttributeType.UserName, UserName);
                client.AddAttribute(AttributeType.UserPassword, UserPassword);
                result = client.Authenticate();
            };

            switch (result)
            {
                case RadiusResult.LocalError:
                    screen.DrawText("Result: LocalError", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.NoResponse:
                    screen.DrawText("Result: NoResponse", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.AccessAccept:
                    screen.DrawText("Result: AccessAccept", font, ColorUtility.ColorFromRGB(0, 0xff, 0), 50, 50);
                    break;
                case RadiusResult.AccessReject:
                    screen.DrawText("Result: AccessReject", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.NotImplemented:
                    screen.DrawText("Result: NotImplemented", font, ColorUtility.ColorFromRGB(0, 0, 0xff), 50, 50);
                    break;
            }
            screen.Flush();
            Thread.Sleep(Timeout.Infinite);
        }
 public override void Run()
 {
     try
     {
         using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
         {
             var rand = new Random();
             for (int i = 0; i < 100; i++)
             {
                 bmp.SetPixel(rand.Next(Dimensions.Width),
                              rand.Next(Dimensions.Height),
                              (Color) rand.Next(0xFFFFFF));
                 bmp.Flush();
             }
         }
         Pass = true;
     }
     catch (Exception e)
     {
         UnexpectedException(e);
     }
 }
        public override void Run()
        {
            try
            {
                using (var scratch = new Bitmap(64, 32))
                {
                    for (int x = 0; x < scratch.Width; x++)
                    {
                        for (int y = 0; y < scratch.Height; y++)
                        {
                            Color color = ColorUtility.ColorFromRGB((byte) (x*255/scratch.Width),
                                                                    (byte) (y*255/(scratch.Height)),
                                                                    (byte) (255 - x*255/scratch.Width));
                            scratch.SetPixel(x, y, color);
                        }
                    }

                    using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                    {
                        var rand = new Random();

                        for (int i = 0; i < 100; i++)
                        {
                            bmp.DrawImage(rand.Next(Dimensions.Width),
                                          rand.Next(Dimensions.Height),
                                          scratch, 0, 0,
                                          scratch.Width, scratch.Height);
                            bmp.Flush();
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
        public override void Run()
        {
            int focus = 15;
            
            using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                DateTime barier = DateTime.Now.AddSeconds(5);
                while(DateTime.Now < barier)
                {
                    bmp.Clear();

                    foreach (var star in _stars)
                    {
                        int x = star.X*focus/star.Z + Dimensions.Width/2;
                        int y = Dimensions.Height/2 - star.Y*focus/star.Z;

                        if (x >= 0 && y >= 0 && x <= bmp.Width && y <= bmp.Height)
                        {
                            if (star.Z > 20)
                                bmp.SetPixel(x, y, Color.White);
                            else
                            {
                                bmp.SetPixel(x, y, Color.White);
                                bmp.SetPixel(x - 1, y, Color.White);
                                bmp.SetPixel(x + 1, y, Color.White);
                                bmp.SetPixel(x, y - 1, Color.White);
                                bmp.SetPixel(x, y + 1, Color.White);
                            }
                        }

                        star.Fly();
                    }

                    bmp.Flush();
                    Thread.Sleep(5);
                }
            }
        }
Beispiel #28
0
        public override void Run()
        {
            Bitmap bitmap = new Bitmap( Dimensions.Width, Dimensions.Height );
                
            try
            {
                bitmap.Clear();

                byte[] byteArr = Resources.GetBytes( Resources.BinaryResources.JpegNormal );
                Bitmap bmp = new Bitmap( byteArr, Bitmap.BitmapImageType.Jpeg );

                bitmap.DrawImage( 0, 0, bmp, 0, 0, bmp.Width, bmp.Height );

                bitmap.Flush();
                Thread.Sleep(2000);
                Pass = true;
            }
            catch(Exception e)
            {
                UnexpectedException( e );
            }
            
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var rand = new Random();

                    for (int i = 0; i < 100; i++)
                    {
                        int radius = rand.Next(100);
                        bmp.DrawEllipse((Color) rand.Next(0xFFFFFF), 1,
                                        rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                        radius, radius, 0, 0, 0, 0, 0, 0, 0);
                        bmp.Flush();
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #30
0
        public static void Main()
        {
            ButtonHelper.ButtonSetup = new Buttons[]{Buttons.BottomRight, Buttons.MiddleRight, Buttons.TopRight,  };
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            var drawing = new Agent.Contrib.Drawing.Drawing();
            drawing.DrawAlignedText(_display, Color.White, font, "Connect...", HAlign.Center, 0, VAlign.Middle, 0);
            _display.Flush();
            

            p = new SerialPort("COM1");
            p.DataReceived += p_DataReceived;
            p.Open();




            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }