public virtual void Draw(VirtualCanvas canvas) { if (!Dirty) { return; } if (Area.Radius == 0) { if (Clicked) { canvas.DrawRectangleFilled(Area.X, Area.Y, Area.X + Area.Width - 1, Area.Y + Area.Height - 1, (ushort)BasicColor.Red); } else { canvas.DrawRectangleFilled(Area.X, Area.Y, Area.X + Area.Width - 1, Area.Y + Area.Height - 1, (ushort)BasicColor.Black); } } else { if (Clicked) { canvas.DrawCircleFilled(Area.X, Area.Y, Area.Radius, (ushort)BasicColor.Red); } else { canvas.DrawCircleFilled(Area.X, Area.Y, Area.Radius, (ushort)BasicColor.Black); } } Dirty = false; }
public static void RenderPrimitiveShapes(VirtualCanvas canvas) { canvas.DrawLine(5, 65, 200, 65, (ushort)BasicColor.Red); canvas.DrawLine(5, 67, 200, 67, (ushort)BasicColor.Green); canvas.DrawLine(5, 69, 200, 69, (ushort)BasicColor.Blue); canvas.DrawCircleFilled(30, 105, 23, (ushort)ColorHelpers.GetRGB24toRGB565(0x33, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 19, (ushort)ColorHelpers.GetRGB24toRGB565(0x66, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 15, (ushort)ColorHelpers.GetRGB24toRGB565(0x99, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 11, (ushort)ColorHelpers.GetRGB24toRGB565(0xCC, 0x00, 0x00)); canvas.DrawCircleFilled(30, 105, 7, (ushort)ColorHelpers.GetRGB24toRGB565(0xFF, 0x00, 0x00)); canvas.DrawRectangleFilled(80, 80, 180, 125, (ushort)GrayScaleValues.Gray_15); canvas.DrawRectangleFilled(85, 85, 175, 120, (ushort)GrayScaleValues.Gray_30); canvas.DrawRectangleFilled(90, 90, 170, 115, (ushort)GrayScaleValues.Gray_50); canvas.DrawRectangleFilled(95, 95, 165, 110, (ushort)GrayScaleValues.Gray_80); canvas.DrawRectangleFilled(100, 100, 160, 105, (ushort)GrayScaleValues.Gray_128); }
public static void BasicTouchEventTest(VirtualCanvas canvas) { var message = "Touch Event Test"; var fontInfo = new DejaVuSansBold9().GetFontInfo(); var stringLength = fontInfo.GetStringWidth(message); canvas.SetOrientation(Orientation.Portrait); canvas.DrawFill(ColorBackground); canvas.DrawString( (canvas.Width - stringLength) / 2, 150, (ushort)BasicColor.Black, fontInfo.ID, message); canvas.TouchscreenWaitForEvent(); canvas.DrawCircleFilled(lastTouchX, lastTouchY, 4, (ushort)BasicColor.Red); canvas.Execute(); Thread.Sleep(1000); }
public static void NonBlockingTouchEventTest(VirtualCanvas canvas) { var message = "Touch To Continue"; var fontInfo = new DejaVuSansBold9().GetFontInfo(); var stringLength = fontInfo.GetStringWidth(message); canvas.DrawFill(ColorBackground); canvas.DrawString( (canvas.Width - stringLength) / 2, 150, (ushort)BasicColor.Black, fontInfo.ID, message); var random = new Random(lastTouchX * lastTouchY); lastTouchIsValid = 0; while (lastTouchIsValid == 0) { canvas.DrawCircleFilled(random.Next(canvas.Width), random.Next(canvas.Height), 4, (ushort)BasicColor.Red); canvas.Execute(); canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking); } }