Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Testing basic functionality for CsLglcd");
            Console.WriteLine("Loading applet...");

            using (Lglcd lglcd = new Lglcd())
            {
                Applet helloWorldApplet = new Applet();
                helloWorldApplet.SupportedDevices = SupportedDevices.QVGA;
                helloWorldApplet.Title = "Hello World 2";
                helloWorldApplet.Connect();

                Device<QvgaImageUpdater> qvgaDevice = new Device<QvgaImageUpdater>();
                qvgaDevice.Applet = helloWorldApplet;
                qvgaDevice.DeviceType = Devices.QVGA;
                qvgaDevice.Attach();

                Console.WriteLine("Press ENTER to draw a test image with CsLglcd.UI");
                Console.ReadLine();

                Bitmap testImage = qvgaDevice.SpecializedImageUpdater.CreateValidImage();
                using (Graphics drawer = Graphics.FromImage(testImage))
                {
                    QvgaScreen form = new QvgaScreen(helloWorldApplet, qvgaDevice);
                    ContainerControl controls = new ContainerControl();
                    form.Control = controls;
                    controls.AddControl(new TextControl() { Text = "test", X = 5, BaseFont = form.BaseFont });
                    var progressbarcontrol = new ProgressBarControl() { X = 8, Y = 100 };
                    controls.AddControl(progressbarcontrol);

                    form.Draw(testImage, drawer);
                    Console.WriteLine("Current percentage: {0}%", progressbarcontrol.Percentage * 100);
                    qvgaDevice.SpecializedImageUpdater.SetPixels(testImage);
                    qvgaDevice.Update();

                    Console.WriteLine("Press ENTER for 0%");
                    Console.ReadLine();

                    progressbarcontrol.Current = 0;
                    form.Draw(testImage, drawer);
                    Console.WriteLine("Current percentage: {0}%", progressbarcontrol.Percentage * 100);
                    qvgaDevice.SpecializedImageUpdater.SetPixels(testImage);
                    qvgaDevice.Update();

                    Console.WriteLine("Press ENTER for 100%");
                    Console.ReadLine();

                    progressbarcontrol.Current = 1000;
                    form.Draw(testImage, drawer);
                    Console.WriteLine("Current percentage: {0}%", progressbarcontrol.Percentage * 100);
                    qvgaDevice.SpecializedImageUpdater.SetPixels(testImage);
                    qvgaDevice.Update();

                    // Try raising app to front

                    Console.WriteLine("Press ENTER for 100% and BRING APPLICATION TO FRONT");
                    Console.ReadLine();

                    progressbarcontrol.Current = 1000;
                    form.Draw(testImage, drawer);
                    Console.WriteLine("Current percentage: {0}%", progressbarcontrol.Percentage * 100);
                    qvgaDevice.ForegroundApplet = true;
                    qvgaDevice.SpecializedImageUpdater.SetPixels(testImage);
                    qvgaDevice.Update(UpdatePriorities.Alert);
                }

                Console.WriteLine("Press ENTER to cleanup memory");
                Console.ReadLine();

                testImage.Dispose();
                qvgaDevice.Detach();
                qvgaDevice.Dispose();
                helloWorldApplet.Disconnect();
                helloWorldApplet.Dispose();
            }

            Console.WriteLine("Press ENTER to close application");
            Console.ReadLine();
        }
Пример #2
0
        private void InitializeLcdForm()
        {
            m_DisplaySurface = QvgaDevice.SpecializedImageUpdater.CreateValidImage();
            m_DisplayDrawer = Graphics.FromImage(m_DisplaySurface);

            m_Form = new QvgaScreen(LglcdApplet, QvgaDevice)
            {
                Icon = Properties.Resources.qvga_mediajukebox,
                AppBackground = Properties.Resources.qvga_background
            };

            m_Controls = new ContainerControl();
            m_Form.Control = m_Controls;

            m_CurrentTrackTextControl = new TextControl()
            {
                Width = 304,
                Height = 48,
                X = 8,
                Y = 0,
                Z = 0
            };
            m_CurrentTrackTextControl.Format.Alignment = StringAlignment.Center;
            m_CurrentTrackTextControl.Format.LineAlignment = StringAlignment.Far;

            m_CurrentTrackProgressControl = new ProgressBarControl()
            {
                X = 8,
                Y = 56,
                Z = 1
            };
            m_CurrentTrackPositionTextControl = new TextControl()
            {
                X = 8,
                Y = 76,
                Z = 2,
                Width = 304
            };
            m_CurrentTrackDurationTextControl = new TextControl()
            {
                X = m_CurrentTrackPositionTextControl.X,
                Y = m_CurrentTrackPositionTextControl.Y,
                Z = 3,
                Width = m_CurrentTrackPositionTextControl.Width
            };
            m_CurrentTrackDurationTextControl.Format.Alignment = StringAlignment.Far;

            m_CurrentTrackControls = new ContainerControl()
            {
                Y = (m_Form.Height / 2) - (m_CurrentTrackPositionTextControl.Y) + 8,
                Z = 1
            };

            m_PreviousTrackTextControl = new TextControl()
            {
                X = 8,
                Y = 0,
                Z = 0,
                Height = 48,
                Width = 304
            };
            m_PreviousTrackTextControl.Format.LineAlignment = StringAlignment.Near;
            m_PreviousTrackTextControl.Format.Alignment = StringAlignment.Center;

            m_NextTrackTextControl = new TextControl()
            {
                X = 8,
                Y = 144,
                Z = 2,
                Height = 64,
                Width = 304
            };
            m_NextTrackTextControl.Format.LineAlignment = StringAlignment.Far;
            m_NextTrackTextControl.Format.Alignment = StringAlignment.Center;

            m_CurrentTrackControls.AddControl(m_CurrentTrackTextControl);
            m_CurrentTrackControls.AddControl(m_CurrentTrackProgressControl);
            m_CurrentTrackControls.AddControl(m_CurrentTrackPositionTextControl);
            m_CurrentTrackControls.AddControl(m_CurrentTrackDurationTextControl);

            m_Controls.AddControl(m_PreviousTrackTextControl);
            m_Controls.AddControl(m_CurrentTrackControls);
            m_Controls.AddControl(m_NextTrackTextControl);
        }