Beispiel #1
0
        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();
        }
Beispiel #3
0
        public static void Demo1()
        {
            GraphicsManager gm = new GraphicsManager(800, 480);

            Desktop desktop = gm.Desktop;

            int k = desktop.Height / 240;
            Font font = Resources.GetFont(Resources.FontResources.CourierNew_10);

            desktop.SuspendLayout();

            ImageBrush brush = new ImageBrush(GetBitmap(Resources.BinaryResources.Background_800_600, Bitmap.BitmapImageType.Jpeg));
            brush.Stretch = Stretch.Fill;
            desktop.Background = brush;

            int statusbarHeight = 24;
            Panel statusbar = new Panel(0, desktop.Height - statusbarHeight, desktop.Width, statusbarHeight);
            statusbar.Background = new ImageBrush(GetBitmap(Resources.BinaryResources.Bar, Bitmap.BitmapImageType.Bmp));
            desktop.Children.Add(statusbar);

            Label lblClock = new Label(statusbar.Width - 70, 4, font, "00:00:00");
            lblClock.ForeColor = Color.White;
            statusbar.Children.Add(lblClock);

            Level lvl2 = new Level(statusbar.Width - 120, 7, 40, 10, Orientation.Horizontal, 10);
            lvl2.Foreground = new LinearGradientBrush(Color.LimeGreen, Color.Black);
            lvl2.Value = 50;
            statusbar.Children.Add(lvl2);

            statusbar.Children.Add(new Image(statusbar.Width - 160, 1, 23, 23, GetBitmap(Resources.BinaryResources.Drive, Bitmap.BitmapImageType.Gif)));
            statusbar.Children.Add(new Image(statusbar.Width - 185, 1, 23, 23, GetBitmap(Resources.BinaryResources.Mouse, Bitmap.BitmapImageType.Gif)));
            statusbar.Children.Add(new Image(statusbar.Width - 210, 1, 23, 23, GetBitmap(Resources.BinaryResources.Keyboard, Bitmap.BitmapImageType.Gif)));

            ////ToolButton btnHome = new ToolButton(10, 0, 70, statusbar.Height);
            //Button btnHome = new Button(10, 0, 70, statusbar.Height, null, "", Color.Black);
            //btnHome.Foreground = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Home));
            //btnHome.Border = null;
            ////btnHome.Enabled = false;
            //statusbar.Children.Add(btnHome);

            //-------------------------------

            //desktop.Children.Add(new Checkbox(20*k, 20*k, 20*k, 20*k));
            desktop.Children.Add(new Checkbox(20, 20, 20, 20));

            //return;
            desktop.Children.Add(new TextBlock(50, 10, 100, 100, font, "Hello world! I'm a text block. I'm very cool!")
            {
                ForeColor = Color.White,
                Background = new LinearGradientBrush(Color.Aquamarine, Color.Yellow) { Opacity = 70 },
                TextAlignment = TextAlignment.Center,
                TextVerticalAlignment = VerticalAlignment.Top,
                TextWrap = true
            });

            //    Level lvl = new Level(20, 40, 60, 20, Orientation.Horizontal, 10);
            //    lvl.Foreground = new LinearGradientBrush(Color.Blue, Color.Black);
            //    //lvl.Value = 0;
            //    Children.Add(lvl);

            ProgressBar pg = new ProgressBar(20, 80, 100, 10);
            pg.Foreground = new LinearGradientBrush(Color.LimeGreen, Color.Red);
            //pg.Foreground.Opacity = 220;
            desktop.Children.Add(pg);

            //    Panel pnl = new Panel(20, 100, 100, 100);
            //    pnl.Background = new LinearGradientBrush(Color.Blue, Color.LimeGreen);
            //    //pnl.Background.Opacity = 80;
            //    Children.Add(pnl);

            //    Button btn = new Button(20, 220, 80, 30, font, "<", Color.White);
            //    Children.Add(btn);

            //    Button btn2 = new Button(60, 0, 80, 25, font, "Button 2 wwwwwwww", Color.White)
            //    {
            //        //BackgroundUnpressed = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.ButtonBackground)) { Opacity = 100 };
            //        //BackgroundPressed = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.ButtonBackground)) { Opacity = 220 };
            //    };
            //    btn2.Click += delegate(object sender, EventArgs e)
            //    {
            //        wndModal dlg = new wndModal(0, 0, 0, 0);
            //        dlg.ShowModal();

            //        int a = 0;
            //        int b = a;

            //        //Close();
            //    };
            //    statusbar.Children.Add(btn2);

            //    RadioButtonGroup rbg = new RadioButtonGroup(20, 260, 25, 70);
            //    rbg.Background = new LinearGradientBrush(Color.White, Color.DarkGray);
            //    //rbg.Background.Opacity = 120;
            //    rbg.AddRadioButton(new RadioButton(5, 5, 15, true));
            //    rbg.AddRadioButton(new RadioButton(5, 25, 15));
            //    rbg.AddRadioButton(new RadioButton(5, 45, 15));
            //    Children.Add(rbg);

            //    ToolButton tbtn;

            //    tbtn = new ToolButton(300, 150, 128, 128);
            //    //tbtn.BackgroundUnpressed = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.ButtonBackground)) { Opacity = 100 };
            //    //tbtn.BackgroundPressed = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.ButtonBackground)) { Opacity = 220 };
            //    tbtn.Foreground = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Database));
            //    tbtn.Foreground.Opacity = 200;
            //    Children.Add(tbtn);

            //    tbtn = new ToolButton(450, 150, 128, 128);
            //    tbtn.Foreground = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Operation));
            //    tbtn.Foreground.Opacity = 200;
            //    Children.Add(tbtn);

            //    tbtn = new ToolButton(600, 150, 128, 128);
            //    tbtn.Foreground = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Settings));
            //    tbtn.Foreground.Opacity = 200;
            //    Children.Add(tbtn);

            desktop.Children.Add(new Slider(250, 20, 150, 30, 15, Orientation.Horizontal)
            {
                Value = 80,
                Background = new ImageBrush(GetBitmap(Resources.BinaryResources.Bar, Bitmap.BitmapImageType.Bmp)),
                Foreground = new LinearGradientBrush(Color.LightGray, Color.Black) { Opacity = 50 }
            });
            desktop.Children.Add(new Slider(200, 20, 30, 150, 12, Orientation.Vertical)
            {
                Value = 70,
                Background = new SolidColorBrush(Color.White) { Opacity = 100 }
            });

            //    Slider slider = new Slider(250, 60, 150, 30, 30, Orientation.Horizontal)
            //    {
            //        Value = 80,
            //        Background = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Bar)),
            //        Foreground = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.GHILogo)) { Opacity = 200 },
            //    };
            //    Children.Add(slider);
            //    Label lbl = new Label(250, 100, font, slider.Value.ToString()) { ForeColor = Color.White };
            //    Children.Add(lbl);
            //    slider.ValueChanged += delegate(object sender, ValueChangedEventArgs e) { lbl.Text = e.Value.ToString(); };

            new Thread(delegate()
            {
                int v = 0;
                while (true)
                {
                    desktop.SuspendLayout();

                    DateTime dt = DateTime.Now;

                    string hour = (dt.Hour < 10) ? "0" + dt.Hour.ToString() : dt.Hour.ToString();
                    string minute = (dt.Minute < 10) ? "0" + dt.Minute.ToString() : dt.Minute.ToString();
                    string second = (dt.Second < 10) ? "0" + dt.Second.ToString() : dt.Second.ToString();
                    string result = hour + ":" + minute + ":" + second;
                    lblClock.Text = result;

                    v += 10;
                    if (v > 100)
                        v = 0;

                    //lvl.Value = v;
                    pg.Value = v;
                    lvl2.Value = v;

                    //Color temp = ((LinearGradientBrush)pnl.Background).StartColor;
                    //((LinearGradientBrush)pnl.Background).StartColor = ((LinearGradientBrush)pnl.Background).EndColor;
                    //((LinearGradientBrush)pnl.Background).EndColor = temp;
                    //pnl.Invalidate();

                    desktop.ResumeLayout();

                    Thread.Sleep(500);
                }
            }).Start();

            //wndModal wndModal = new wndModal();
            //wndModal.Show();

            desktop.ResumeLayout();
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        public void Demo22()
        {
            display = new Display_SP22(1);

            gm = new GraphicsManager(240, 320);
            gm.OnRender += delegate(Bitmap bitmap, Rect dirtyArea)
            {
                display.SimpleGraphics.DisplayImage(bitmap, (uint)dirtyArea.X, (uint)dirtyArea.Y, (uint)dirtyArea.X, (uint)dirtyArea.Y, (uint)dirtyArea.Width, (uint)dirtyArea.Height);
            };

            desktop.SuspendLayout();

            ImageBrush brush = new ImageBrush(Program.GetBitmap(Resources.BinaryResources.reWalls, Bitmap.BitmapImageType.Jpeg));
            brush.Stretch = Stretch.Fill;
            //desktop.Background = brush;

            int statusbarHeight = 24;
            Panel statusbar = new Panel(0, desktop.Height - statusbarHeight, desktop.Width, statusbarHeight);
            statusbar.Background = new ImageBrush(new Bitmap(Resources.GetBytes(Resources.BinaryResources.Bar), Bitmap.BitmapImageType.Bmp));
            desktop.Children.Add(statusbar);

            Label lblClock = new Label(statusbar.Width - 70, 4, fontRegular, "00:00:00");
            lblClock.ForeColor = Color.White;
            statusbar.Children.Add(lblClock);

            Level lvl2 = new Level(statusbar.Width - 120, 7, 40, 10, Orientation.Horizontal, 10);
            lvl2.Foreground = new LinearGradientBrush(Color.LimeGreen, Color.Black);
            lvl2.Value = 50;
            statusbar.Children.Add(lvl2);

            desktop.ResumeLayout();

            new Thread(() =>
            {
                int v = 0;
                while (true)
                {
                    desktop.SuspendLayout();

                    DateTime dt = DateTime.Now;

                    string hour = (dt.Hour < 10) ? "0" + dt.Hour.ToString() : dt.Hour.ToString();
                    string minute = (dt.Minute < 10) ? "0" + dt.Minute.ToString() : dt.Minute.ToString();
                    string second = (dt.Second < 10) ? "0" + dt.Second.ToString() : dt.Second.ToString();
                    string result = hour + ":" + minute + ":" + second;
                    lblClock.Text = result;

                    v += 10;
                    if (v > 100)
                        v = 0;

                    //lvl.Value = v;
                    //pg.Value = v;
                    lvl2.Value = v;

                    //Color temp = ((LinearGradientBrush)pnl.Background).StartColor;
                    //((LinearGradientBrush)pnl.Background).StartColor = ((LinearGradientBrush)pnl.Background).EndColor;
                    //((LinearGradientBrush)pnl.Background).EndColor = temp;
                    //pnl.Invalidate();

                    desktop.ResumeLayout();

                    Thread.Sleep(500);
                }
            }).Start();
        }