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)) { //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); } }
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() { 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); } } }
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); } }
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); } } }
/// <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() { 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); } } }
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 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); }
public void Render(Bitmap screen) { Screen = screen; if (Buttons != null) { screen.Clear(); foreach (CalculatorButton button in Buttons) { button.Render(screen, font, ButtonHeight, ButtonWidth, ButtonBorder, ForegroundColor, BackgroundColor); } //calculation result screen.DrawText(input, font, BackgroundColor, 2, 2); screen.DrawText(secondInput + op, font, BackgroundColor, 2, 2 + font.Height + 2); //draw a simple border for the digit display screen.DrawRectangle(ForegroundColor, 1, 1, 1, Program.AgentSize, 28, 0, 0, BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0); //draw a simple border screen.DrawRectangle(Color.White, 1, 1, 1, Program.AgentSize, Program.AgentSize, 0, 0, BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0); screen.Flush(); } }
public override void Run() { try { Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height ); Bitmap src = Resources.GetBitmap( Resources.BitmapResources.SPOTLOGO ); Random 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 < 1000; 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 ); } }
public override void Run() { try { Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height ); Font font = Resources.GetFont( Resources.FontResources.GLANCEABLE ); Random rand = new Random(); for(int x = 0; x < 10; x++) { int baseColor = rand.Next( 0xffff ); for(int i = 0; i < Dimensions.Height; i++) { bmp.Clear(); bmp.DrawText( "Hello World :) 12345", font, (Presentation.Media.Color)(((255 - i) << 16) | baseColor), 0, i ); bmp.Flush(); } } Pass = true; } catch(Exception e) { UnexpectedException( e ); } }