//private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksOutside), // Bitmap.BitmapImageType.Gif); //private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksInside), // Bitmap.BitmapImageType.Gif); public override void Render(Bitmap screen) { if (_screen == null) _screen = screen; screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height); var text = "AGENT"; Point textLocation = new Point( AGENT.Center.X - (drawing.MeasureString(text, smallFont) / 2), AGENT.Center.Y - 25); screen.DrawText(text, smallFont, Color.White, textLocation.X, textLocation.Y); var date = Settings.Now.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.MonthDayPattern); ; //time.MonthNameShort + " " + time.Day; Point dateLocation = new Point( AGENT.Center.X - (drawing.MeasureString(date, smallFont) / 2), AGENT.Center.Y + 20); screen.DrawText(date, smallFont, Color.White, dateLocation.X, dateLocation.Y); //draw our hands drawing.PaintSkinnyHands(screen, Settings.Now, AGENT.Center); drawing.DrawTray(screen, _notificationProvider, smallFont); }
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 static void Main() { _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); currentTime = new DateTime(); _azmdrawing = new AZMDrawing(); _point = new AGENT.AZMutil.Point(); colorBackground = Color.Black; colorForeground = Color.White; UpdateTime(null); currentTime = DateTime.Now; dueTime = new TimeSpan(0, 0, 0, 59 - currentTime.Second, 1000 - currentTime.Millisecond); period = new TimeSpan(0, 0, 1, 0, 0); _updateClockTimer = new Timer(UpdateTime, null, dueTime, period); // start our update timer ButtonHelper.Current.OnButtonPress += Current_OnButtonPress; Thread.Sleep(Timeout.Infinite); }
private Program() { OneTimeConfig(); _lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight); Touch.Initialize(this); this.MainWindow = new Window(); this.MainWindow.TouchDown += MainWindow_TouchDown; this.MainWindow.TouchUp += MainWindow_TouchUp; this.MainWindow.TouchMove += MainWindow_TouchMove; var eth = new EthernetBuiltIn(); eth.Open(); if (!eth.CableConnected) { eth.Close(); var wifi = new WiFiRS9110(SPI.SPI_module.SPI1, G400.PD13, G400.PD12, G400.PD15); _netif = wifi; _netif.Open(); wifi.Join("XXX", "XXX"); } else { _netif = eth; } if (!_netif.IsDhcpEnabled) _netif.EnableDhcp(); if (!_netif.IsDynamicDnsEnabled) _netif.EnableDynamicDns(); NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; }
public GraphicsManager(int width, int height) { //mouseManager = new MouseManager(canvas); //mouseManager.OnMouseDblClick = InterceptMouseDblClick; //mouseManager.OnMouseDown = InterceptMouseDown; //mouseManager.OnMouseUp = InterceptMouseUp; //mouseManager.OnMouseMove = InterceptMouseMove; //mouseManager.OnMouseOut = InterceptMouseOut; TouchManager.TouchDown += new TouchEventHandler(TouchManager_TouchDown); TouchManager.TouchMove += new TouchEventHandler(TouchManager_TouchMove); TouchManager.TouchUp += new TouchEventHandler(TouchManager_TouchUp); TouchManager.TouchGestureStarted += new TouchGestureEventHandler(TouchManager_TouchGestureStarted); TouchManager.TouchGestureChanged += new TouchGestureEventHandler(TouchManager_TouchGestureChanged); TouchManager.TouchGestureEnded += new TouchGestureEventHandler(TouchManager_TouchGestureEnded); TouchManager.Initialize(); bitmap = new Bitmap(width, height); desktop = new Desktop(width, height, this); cw = new CalibrationWindow(width, height, this) { Background = new SolidColorBrush(Color.CornflowerBlue), CrosshairPen = new Pen(Color.Red, 1) }; if (CalibrationManager.IsCalibrated) CalibrationManager.ApplyCalibrationPoints(); desktop.Invalidate(); }
public void Render(Bitmap screen, bool military, ArrayList forecast) { DateTime now = DateTime.Now; string display = ""; string hour, minute = now.Minute.ToString(); if (military) { hour = now.Hour.ToString(); } else { int h = now.Hour; if (h >= 12) h = h - 12; if (h == 0) h = 12; hour = h.ToString(); } if (minute.Length == 1) minute = "0" + minute; display = hour + ":" + minute; screen.DrawLine(Color.White, 2, 0, Program.AgentSize/2, Program.AgentSize, Program.AgentSize/2); int left = Program.AgentSize - Program.MeasureString(display, bigfont); screen.DrawText(display, bigfont, Color.White, left, (Program.AgentSize/2) +2); string dow = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[(int) now.DayOfWeek]; screen.DrawText(dow.ToString(), font, Color.White, 5, 10); string date = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames[(int) now.Month]; date = date + " " + now.Day.ToString(); screen.DrawText(date, font, Color.White, 5, 30); }
public static bool SetBootLogo(Bitmap logo, int x, int y) { if (Utils.IsEmulator) return false; if (logo != null) { // New settings were saved, must reboot // The start-up logo will take effect after the first reset bool res = Configuration.StartUpLogo.Set(logo.GetBitmap(), x, y); Thread.Sleep(1000); // to set logo bitmap Configuration.StartUpLogo.Enabled = true; return res; //return Configuration.StartUpLogo.Set(logo.GetBitmap(), (int)(ScreenWidth - logo.Width) / 2, (int)(ScreenHeight - logo.Height) / 2); } else { if (Configuration.StartUpLogo.Enabled) { Configuration.StartUpLogo.Enabled = false; return true; } else return false; } }
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)) { 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); } }
void camera_BitmapStreamed(GTM.GHIElectronics.Camera sender, Bitmap bitmap) { //320*240 displayT35.SimpleGraphics.DisplayImage(bitmap, 0, 0); detectionMove(bitmap); }
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height) { Color outlineColor = (pen != null) ? pen.Color : (Color)0x0; ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0; int x1, y1; int x2, y2; switch (MappingMode) { case BrushMappingMode.RelativeToBoundingBox: x1 = x + (int)((long)(width - 1) * StartX / RelativeBoundingBoxSize); y1 = y + (int)((long)(height - 1) * StartY / RelativeBoundingBoxSize); x2 = x + (int)((long)(width - 1) * EndX / RelativeBoundingBoxSize); y2 = y + (int)((long)(height - 1) * EndY / RelativeBoundingBoxSize); break; default: //case BrushMappingMode.Absolute: x1 = StartX; y1 = StartY; x2 = EndX; y2 = EndY; break; } bmp.DrawRectangle((MSMedia.Color)outlineColor, outlineThickness, x, y, width, height, 0, 0, (MSMedia.Color)StartColor, x1, y1, (MSMedia.Color)EndColor, x2, y2, Opacity); }
/// <summary> /// Constructs a TinyBitmap from a preexisting bitmap. /// </summary> /// <param name="bitmap">The bitmap to construct from.</param> public TinyBitmap(Bitmap bitmap) { this.Width = (uint)bitmap.Width; this.Height = (uint)bitmap.Height; this.Data = new byte[this.Width * this.Height * 2]; Util.BitmapConvertBPP(bitmap.GetBitmap(), this.Data, Util.BPP_Type.BPP16_BGR_BE); }
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); } }
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); } }
static ResourceManager() { BmpCheckboxClear = Resources.GetBitmap(Resources.BitmapResources.CheckboxClear); BmpCheckboxChecked = Resources.GetBitmap(Resources.BitmapResources.CheckboxChecked); BmpRadioButtonClear = Resources.GetBitmap(Resources.BitmapResources.RadiobuttonClear); BmpRadioButtonChecked = Resources.GetBitmap(Resources.BitmapResources.RadiobuttonChecked); }
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 Render(Bitmap screen) { if (base._screen == null) _screen = screen; // simple bitmap Point[] sq = { new Point(10, 10), new Point(10, 40), new Point(40, 40), new Point(40, 10)}; Point[] sq2 = { new Point(60, 60), new Point(60, 100), new Point(100, 100), new Point(100, 60) }; Point[] sq3 = { new Point(20, 20), new Point(80, 90), new Point(100, 100), new Point(100, 60) }; Point[] sq4 = { new Point(30, 30), new Point(30, 70), new Point(100, 70), new Point(100, 30), new Point(80, 20), new Point(70, 30), new Point(70, 45), new Point(50, 45), new Point(50, 30) }; drawing.DrawPoly(screen, sq, Color.White, 2, Color.White, PolyFill.POLYFILL_SOLID); drawing.DrawPoly(screen, sq3, Color.White, 2, Color.White, PolyFill.POLYFILL_EMPTY); drawing.DrawPoly(screen, sq2, Color.White, 1, Color.White, PolyFill.POLYFILL_CROSS_RIGHT); drawing.DrawPoly(screen, sq4, Color.Black, 2, Color.White, PolyFill.POLYFILL_DOTS); }
public static void Main() { _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); _azmdrawing = new AZMDrawing(); colorForeground = new Color(); colorBackground = new Color(); colorBackgroundOld = new Color(); colorEraser = new Color(); screenWidth = _display.Width; screenHeight = _display.Height; screenCenterX = screenWidth / 2; screenCenterY = screenHeight / 2; _bmpEraser = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Eraser), Bitmap.BitmapImageType.Gif); eraserWidth = _bmpEraser.Width; eraserHeight =_bmpEraser.Height; eraserCenterX = eraserWidth / 2; eraserCenterY = eraserHeight / 2; _bmpEraserWork = new Bitmap(eraserWidth, eraserHeight); currentTime = new DateTime(); currentTime = DateTime.Now; dueTime = new TimeSpan(0, 0, 0, 59 - currentTime.Second, 1000 - currentTime.Millisecond); period = new TimeSpan(0, 0, 1, 0, 0); dueTimeHandWriting = new TimeSpan(0, 0, 0, 0, 0); periodHandWriting = new TimeSpan(0, 0, 0, 0, MILLISECOND_HAND_WRITING_INTERVAL); dueTimeDigital = new TimeSpan(0, 0, 0, 0, 1000 - currentTime.Millisecond); periodDigital = new TimeSpan(0, 0, 0, 1, 0); displayMode = DISPLAY_MODE_BLACK_12; SetDisplayMode(displayMode); //_bmpEraserWork.DrawImage(0, 0, _bmpEraser, 0, 0, eraserWidth, eraserHeight); //colorEraser = Color.Black; eraser = false; oldMM = -1; UpdateTime(null); _updateClockTimer = new Timer(UpdateTime, null, dueTime, period); ButtonHelper.ButtonSetup = new Buttons[] { Buttons.BottomRight, Buttons.MiddleRight, Buttons.TopRight }; ButtonHelper.Current.OnButtonPress += Current_OnButtonPress; Thread.Sleep(Timeout.Infinite); }
public static void Main() { _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); _azmdrawing = new AZMDrawing(); screenWidth = _display.Width; screenHeight = _display.Height; screenCenterX = screenWidth / 2; screenCenterY = screenHeight / 2; colorForeground = Color.White; colorBackground = Color.Black; showDigital = false; currentTime = new DateTime(); currentTime = DateTime.Now; UpdateTime(null); currentTime = DateTime.Now; dueTime = new TimeSpan(0, 0, 0, 0, 1000 - currentTime.Millisecond); period = new TimeSpan(0, 0, 0, 1, 0); _updateClockTimer = new Timer(UpdateTime, null, dueTime, period); ButtonHelper.Current.OnButtonPress += Current_OnButtonPress; Thread.Sleep(Timeout.Infinite); }
public void PaintCentered(byte[] ImageData, Bitmap.BitmapImageType ImageType) { var img = new Bitmap(ImageData, ImageType); int x = (bitmap.Width / 2) - (img.Width / 2); int y = (bitmap.Height / 2) - (img.Height / 2); bitmap.DrawImage(x, y, img, 0, 0, img.Width, img.Height); }
public static void Main() { // initialize display buffer and properties _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); fRadius = _display.Height / 2; fCenterX = _display.Width / 2; fCenterY = _display.Height / 2; fHourLength = (float)_display.Height / 3 / 1.85F; fMinLength = (float)_display.Height / 3 / 1.20F; fSecLength = (float)_display.Height / 3 / 1.15F; fHourThickness = (float)_display.Height / 100; fMinThickness = (float)_display.Height / 150; fSecThickness = (float)_display.Height / 200; fCenterCircleRadius = _display.Height / 50; // obtain the current time var currentTime = DateTime.Now; // set up timer to refresh time every minute // start timer at beginning of next second var dueTime = new TimeSpan(0, 0, 0, 0, 1000 - currentTime.Millisecond); // update time every second var period = new TimeSpan(0, 0, 0, 1, 0); // start our update timer updateClockTimer = new Timer(UpdateTime, null, dueTime, period); Thread.Sleep(Timeout.Infinite); }
public static int MaxClickWaitTime = 250; //how fast can you click the button xNumber of times for it to count? public static void Main() { //wire up three button clicks to the TripleClick Method _buttonResponses.Add(new Buttons[] { Buttons.MiddleRight, Buttons.MiddleRight, Buttons.MiddleRight }, new HandleClicks(TripleClick)); _buttonResponses.Add(new Buttons[] { Buttons.MiddleRight, Buttons.MiddleRight }, new HandleClicks(DoubleClick)); _buttonResponses.Add(new Buttons[] { Buttons.MiddleRight }, new HandleClicks(SingleClick)); ButtonHelper.Current.OnButtonPress += Current_OnButtonPress; // initialize our display buffer _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); // display the time immediately UpdateTime(null); // obtain the current time DateTime currentTime = DateTime.Now; // set up timer to refresh time every minute TimeSpan dueTime = new TimeSpan(0, 0, 0, 59 - currentTime.Second, 1000 - currentTime.Millisecond); // start timer at beginning of next minute TimeSpan period = new TimeSpan(0, 0, 1, 0, 0); // update time every minute _updateClockTimer = new Timer(UpdateTime, null, dueTime, period); // start our update timer clickTimer = new Timer(clickTimer_callback, null, Timeout.Infinite, Timeout.Infinite); // go to sleep; time updates will happen automatically every minute Thread.Sleep(Timeout.Infinite); }
public static void ChangeBitmapColor(Bitmap img, Color anyDifferentColor, Color changeTo) { for (int x = 0; x < img.Width; x++) for (int y = 0; y < img.Height; y++) if (img.GetPixel(x, y) != anyDifferentColor) img.SetPixel(x, y, changeTo); }
public void Render(Bitmap screen) { if (_screen == null) _screen = screen; _screen.DrawLine(Color.White, 2, 0, AGENT.Contrib.Device.Size / 2, AGENT.Contrib.Device.Size, AGENT.Contrib.Device.Size / 2); DateTime now = DateTime.Now; int counter = (int) now.DayOfWeek; counter++; int left = buffer; for (int x = 0; x <= days; x++) { if (counter >= 7) counter = 0; string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[counter]; if (dayName.Length >= 3) dayName = dayName.Substring(0, 3); int width = drawing.MeasureString(dayName, font); _screen.DrawText(dayName, font, Color.White, left, top); IForecast current = CurrentConditions.CurrentWeekForecast[x] as IForecast; _screen.DrawText(current.Temperature.ToString(), font, Color.White, left + 4, top + font.Height + 2); counter++; if (counter > 6) counter = 0; left += width + buffer; } string display = CurrentConditions.CurrentForecast.Temperature.ToString(); int forecastLeft = AGENT.Contrib.Device.Size - drawing.MeasureString(display, bigfont); _screen.DrawText(display, bigfont, Color.White, forecastLeft, (AGENT.Contrib.Device.Size/2) + 2); _screen.DrawText(CurrentConditions.CurrentForecast.TimeStamp.ToString(), smallFont, Color.White, 3, (AGENT.Contrib.Device.Size / 2) - smallFont.Height - 1); }
public Image(int x, int y, int width, int height, Bitmap bitmap, ushort opacity) : base(x, y, width, height) { brush = new ImageBrush(bitmap); brush.Stretch = Stretch.Fill; Opacity = opacity; }
void camera_BitmapStreamed(Camera sender, Bitmap bitmap) { if (!picTimeout.IsRunning && GT.Timer.GetMachineTime() >= webcamStreamStopTime) { //Debug.Print("Stopping bitmap streaming"); camera.StopStreamingBitmaps(); } if (responders.Count > 0) { byte[] bmpFile = new byte[bitmap.Width * bitmap.Height * 3 + 54]; GHI.Premium.System.Util.BitmapToBMPFile(bitmap.GetBitmap(), bitmap.Width, bitmap.Height, bmpFile); GT.Picture picture = new GT.Picture(bmpFile, GT.Picture.PictureEncoding.BMP); numresponses++; Debug.Print("Sending webcam response " + numresponses + " to " + responders.Count + " clients"); foreach (HomeOSGadgeteer.Networking.Responder responder in responders) { try { responder.Respond(picture); } catch { } } responders.Clear(); } if (picTimeout.IsRunning) { oledDisplay.SimpleGraphics.DisplayImage(lastBitmap, 0, 0); oledDisplay.SimpleGraphics.Redraw(); Debug.Print("Picture streamed -> screen"); } }
public void Main(string ApplicationPath, string[] Args) { Form frmPacman = new Form("frmPacman"); frmPacman.ButtonPressed += frmPacman_ButtonPressed; Bitmap bmpGame; Picturebox pbGame; bmpGame = new Bitmap(320, 240); if (Prompt.Show("Resolution Adjust", "Would you like to play at 640x480?", Fonts.Calibri18Bold, Fonts.Calibri14, PromptType.YesNo) == PromptResult.Yes) { pbGame = new Picturebox("pbGame", bmpGame, frmPacman.Width / 2 - 320, frmPacman.Height / 2 - 240, 640, 480, BorderStyle.BorderNone); pbGame.ScaleMode = ScaleMode.Stretch; } else pbGame = new Picturebox("pbGame", bmpGame, frmPacman.Width / 2 - 160, frmPacman.Height / 2 - 140, BorderStyle.BorderNone); pbGame.Background = Colors.Black; game = new PacmanGame(bmpGame, pbGame); frmPacman.AddControl(pbGame); Graphics.ActiveContainer = frmPacman; Thread.Sleep(100); if (joystick != null) { game.InputManager.AddInputProvider(joystick); game.Initialize(); } }
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 static void Main() { MultiButtonHelper mbh = new MultiButtonHelper(); mbh.AddButtonHandler(new Buttons[] {Buttons.TopRight, Buttons.BottomRight,}, new MultiButtonHelper.HandleClicks(ResetAll)); // initialize display buffer _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); _drawing = new Drawing(_display); menu = new Menu(menuFont, _display); menu.OnMenuItemClicked += menu_OnMenuItemClicked; menu.Items.Add(new MenuItem() {Title = "1 Minute", CommandArg = "1"}); menu.Items.Add(new MenuItem() {Title = "2 Minutes", CommandArg = "2"}); menu.Items.Add(new MenuItem() {Title = "3 Minutes", CommandArg = "3"}); menu.Items.Add(new MenuItem() {Title = "4 Minutes", CommandArg = "4"}); menu.Items.Add(new MenuItem() {Title = "5 Minutes", CommandArg = "5"}); menu.Items.Add(new MenuItem() {Title = "10 Minutes", CommandArg = "10"}); menu.Items.Add(new MenuItem() {Title = "15 Minutes", CommandArg = "15"}); menu.Items.Add(new MenuItem() {Title = "20 Minutes", CommandArg = "20"}); menu.Items.Add(new MenuItem() {Title = "30 Minutes", CommandArg = "30"}); menu.Items.Add(new MenuItem() {Title = "45 Minutes", CommandArg = "45"}); menu.Items.Add(new MenuItem() {Title = "60 Minutes", CommandArg = "60"}); ShowMenu(); // go to sleep; all further code should be timer-driven or event-driven Thread.Sleep(Timeout.Infinite); }
public void Render(Bitmap screen, bool military, ArrayList forecast) { screen.DrawLine(Color.White, 2, 0, Program.AgentSize / 2, Program.AgentSize, Program.AgentSize / 2); DateTime now = DateTime.Now; int counter = (int) now.DayOfWeek; counter++; int left = buffer; Forecast nowForecast = null; bool needsDate = false; DateTime lastUpdated = DateTime.Now; for (int x = 0; x <= days; x++) { string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[counter]; if (dayName.Length >= 3) dayName = dayName.Substring(0, 3); int width = Program.MeasureString(dayName, font); screen.DrawText(dayName, font, Color.White, left, top); if (forecast != null && forecast.Count > 0) { Forecast current = null; var startDate = now.Date.AddDays(x); foreach (Forecast f in forecast) { if (f.Date.Year == now.Date.Year && f.Date.Month == now.Date.Month && f.Date.Day == now.Date.Day) nowForecast = f; if (startDate.Year == f.Date.Year && startDate.Month == f.Date.Month && startDate.Day == f.Date.Day) { Debug.Print("Found match"); current = f; break; } } if (current != null) { needsDate = true; screen.DrawText(current.Current.ToString(), font, Color.White, left+4, top+font.Height + 2); lastUpdated = current.LastUpdated; } } counter++; if (counter > 6) counter = 0; left += width + buffer; } if (nowForecast != null) { string display = nowForecast.Current.ToString(); int forecastLeft = Program.AgentSize - Program.MeasureString(display, bigfont); screen.DrawText(display, bigfont, Color.White, forecastLeft, (Program.AgentSize / 2) + 2); needsDate = true; lastUpdated = nowForecast.LastUpdated; } if (needsDate) { screen.DrawText(lastUpdated.ToString(), smallFont, Color.White, 3, (Program.AgentSize / 2)-smallFont.Height-1); } }
/** * This method sum the value of green of 9 squares * of dimension 8x8 taken from a bitmap. */ public Int32 heuristicSum(Microsoft.SPOT.Bitmap bitmapB) { Int32 RA = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { RA += ColorUtility.GetGValue(bitmapB.GetPixel(x, y)); } } for (int y = 116; y < 124; y++) { for (int x = 0; x < 8; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } for (int y = 232; y < 240; y++) { for (int x = 0; x < 8; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } for (int y = 232; y < 240; y++) { for (int x = 156; x < 164; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } for (int y = 116; y < 124; y++) { for (int x = 156; x < 164; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } for (int y = 0; y < 8; y++) { for (int x = 156; x < 164; x++) { RA += ColorUtility.GetGValue(bitmapB.GetPixel(x, y)); } } for (int y = 0; y < 8; y++) { for (int x = 312; x < 320; x++) { RA += ColorUtility.GetGValue(bitmapB.GetPixel(x, y)); } } for (int y = 116; y < 124; y++) { for (int x = 312; x < 320; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } for (int y = 232; y < 240; y++) { for (int x = 312; x < 320; x++) { RA += ColorUtility.GetRValue(bitmapB.GetPixel(x, y)); } } return(RA); }