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 DemoManager(int width, int height, RenderRequestEventHandler renderHandler = null) { FontRegular = Resources.GetFont(Resources.FontResources.LucidaSansUnicode_8); FontCourierNew10 = Resources.GetFont(Resources.FontResources.CourierNew_10); FontTitle = Resources.GetFont(Resources.FontResources.SegoeUI_BoldItalian_32); Bar = new ImageBrush(GetBitmap(Resources.BinaryResources.Bar, Bitmap.BitmapImageType.Bmp)); gm = new GraphicsManager(width, height); Desktop = gm.Desktop; if (renderHandler != null) gm.OnRenderRequest += renderHandler; }
static UIManager() { //if (Mainboard.NativeBitmapConverter == null) // Mainboard.NativeBitmapConverter = new Gadgeteer.Mainboard.BitmapConvertBPP(delegate(byte[] bitmapBytes, byte[] pixelBytes, GT.Mainboard.BPP bpp) // { // if (bpp != GT.Mainboard.BPP.BPP16_BGR_BE) // throw new ArgumentOutOfRangeException("bpp", "Only BPP16_BGR_LE supported"); // Util.BitmapConvertBPP(bitmapBytes, pixelBytes, Util.BPP_Type.BPP16_BGR_BE); // }); //display = new DisplayS22(1); // Usage example #1. Passing a Bitmap to the driver. //Bitmap bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.test_24b), Bitmap.BitmapImageType.Bmp); //display.Draw(bitmap); //display.SimpleGraphics.DisplayImage(bitmap, 0, 0); ////display.SimpleGraphics.BackgroundColor = GT.Color.Green; //display.SimpleGraphics.DisplayText("Igor, mi bogati!", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 5, 5); //display.SimpleGraphics.DisplayText("Pivo v studiyu!", Resources.GetFont(Resources.FontResources.small), GT.Color.Red, 5, 25); ////Thread.Sleep(2000); ////display.SimpleGraphics.Clear(); //display.SimpleGraphics.DisplayEllipse(GT.Color.Blue, 120, 160, 30, 20); //Thread.Sleep(2000); //DisplayDemo(display); FontRegular = Resources.GetFont(Resources.FontResources.LucidaSansUnicode_8); FontCourierNew10 = Resources.GetFont(Resources.FontResources.CourierNew_10); FontTitle = Resources.GetFont(Resources.FontResources.SegoeUI_BoldItalian_32); gm = new GraphicsManager(320, 240); //gm = new GraphicsManager(480, 272); //gm = new GraphicsManager(800, 480); Desktop = gm.Desktop; //desktop.SuspendLayout(); ImageBrush brush = new ImageBrush(GetBitmap(Resources.BinaryResources.Background, Bitmap.BitmapImageType.Jpeg)); brush.Stretch = Stretch.Fill; Desktop.Background = brush; DebugPage = new DebugPage(); SplashPage = new SplashPage(); //desktop.ResumeLayout(); }
public void Demo() { gm = new GraphicsManager(800, 480); desktop = gm.Desktop; desktop.SuspendLayout(); desktop.Background = new ImageBrush(Program.GetBitmap(Resources.BinaryResources.reWalls, Bitmap.BitmapImageType.Jpeg)) { Stretch = Stretch.Fill }; ImageBrush bar = new ImageBrush(Program.GetBitmap(Resources.BinaryResources.Bar, Bitmap.BitmapImageType.Bmp)); // left panel Panel panelNavigation = new Panel(10, 10, 150, desktop.Height - 20) //460 { Background = new LinearGradientBrush(Color.Bisque, Color.Black, 0, 500, 1000, 500, 120), Border = new Pen(Color.Black, 1) }; desktop.Children.Add(panelNavigation); Panel tlb = new Panel(1, 1, panelNavigation.Width - 2, 25); tlb.Background = bar; tlb.Children.Add(new Label(10, 5, fontCourierNew10, "Navigation") { ForeColor = Color.CornflowerBlue }); //tlb.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb); p = e.Point; }; //tlb.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) { panelNavigation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; //tlb.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) TouchCapture.ReleaseCapture(); }; panelNavigation.Children.Add(tlb); //int d = 15; //int x = 0; ////int y = 5; //RadioButtonGroup rbgNavigation = new RadioButtonGroup(10, 30, 15, panelNavigation.Height - 40); //panelNavigation.Children.Add(rbgNavigation); //rbgNavigation.AddRadioButton(new RadioButton(x, 5, d, true)); //rbgNavigation.AddRadioButton(new RadioButton(x, 25, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 45, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 65, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 85, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 105, d)); //panelNavigation.Children.Add(new Label(30, 35, fontCourierNew10, "Checkboxes") { ForeColor = Color.White }); //panelNavigation.Children.Add(new Label(30, 55, fontCourierNew10, "Buttons") { ForeColor = Color.White }); int x = 5; int w = panelNavigation.Width - 2 * x; int h = 18; int y = 35; int step = h + 5; //Font fnt = fontRegular; Font fnt = fontCourierNew10; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Checkbox", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Button", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Image", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Label", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Level", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "MultiImage", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Panel", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "ProgressBar", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "RadioButton", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Slider", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "TextBlock", Color.White) { BackgroundUnpressed = bar }); y += step; //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step; //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step; foreach (Control ctrl in panelNavigation.Children) { if (ctrl is Button) (ctrl as Button).Click += new EventHandler(Button_Click); } // title TextBlock txtTitle = new TextBlock(panelNavigation.Right + 10, panelNavigation.Y, desktop.Width - (panelNavigation.Right + 20), 60, fontTitle, "MFE graphics") { ForeColor = Color.CornflowerBlue, TextAlignment = TextAlignment.Center, TextVerticalAlignment = VerticalAlignment.Center }; desktop.Children.Add(txtTitle); // right panel int yy = txtTitle.Height + 10; panelPresentation = new Panel(txtTitle.X, panelNavigation.Y + yy, txtTitle.Width, panelNavigation.Height - yy); panelPresentation.Background = new SolidColorBrush(Color.Black); panelPresentation.Background.Opacity = 50; panelPresentation.Border = new Pen(Color.Black, 1); desktop.Children.Add(panelPresentation); tlb2 = new Panel(1, 1, panelPresentation.Width - 2, 25); tlb2.Background = bar; tlb2.Children.Add(lblActiveDemo = new Label(10, 5, fontCourierNew10, "Presentation: [Please select control type on the left]") { ForeColor = Color.CornflowerBlue }); //tlb2.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb2); p = e.Point; }; //tlb2.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) { panelPresentation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; //tlb2.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) TouchCapture.ReleaseCapture(); }; panelPresentation.Children.Add(tlb2); desktop.ResumeLayout(); }