コード例 #1
0
        public AppletMediaJukebox(MediaJukeboxAutomation mj, MainInterface ui)
        {
            MJ       = mj;
            UI       = ui;
            LgLcdLib = new Lglcd();

            LglcdApplet = new Applet()
            {
                SupportedDevices = SupportedDevices.QVGA,
                Title            = "Media Jukebox"
            };
            QvgaDevice = new Device <QvgaImageUpdater>()
            {
                Applet = LglcdApplet
            };

            LglcdApplet.DeviceArrival += new EventHandler <DeviceEventArgs>(LglcdApplet_DeviceArrival);
            LglcdApplet.DeviceRemoval += new EventHandler <DeviceEventArgs>(LglcdApplet_DeviceRemoval);

            m_RaisePriorityUntil = DateTime.Now.Add(Properties.Settings.Default.RaisedPriorityTimeout);

            /*try
             * {
             *  Initialize();
             *  InitializeLcdForm();
             *  UpdateValues();
             *  UpdateGraphics();
             * }
             * catch (Exception e)
             * {
             *  System.Windows.Forms.MessageBox.Show("A Fatal error has occured while creating plugin:-" + e.Message +
             *          "\n The Failure Occured" +
             *          "\n In Class Object " + e.Source +
             *          "\n when calling Method " + e.TargetSite +
             *          "\n \n The following Inner Exception was caused" + e.InnerException +
             *          "\n \n The Stack Trace Follows: \n\n" + e.StackTrace);
             * }*/

            TrackChange       += new EventHandler <MediaJukeboxEventArgs>(AppletMediaJukebox_TrackChange);
            PlayerStateChange += new EventHandler <MediaJukeboxEventArgs>(AppletMediaJukebox_PlayerStateChange);

            InitializeLcdForm();

            m_InitializationTimer = new Timer(new TimerCallback(TimerHandler), null, TimeSpan.Zero, TimeSpan.FromSeconds(1.0));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Fire-Dragon-DoL/CsLglcd
        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 1";
                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");
                Console.ReadLine();

                Bitmap testImage = qvgaDevice.SpecializedImageUpdater.CreateValidImage();
                using (Graphics g = Graphics.FromImage(testImage))
                {
                    g.FillRectangle(Brushes.Red, 0, 0, testImage.Width, testImage.Height);
                    g.DrawString("Hello world", new Font("monospace", 12f), Brushes.White, 15f, 15f);
                }

                qvgaDevice.SpecializedImageUpdater.SetPixels(testImage);
                qvgaDevice.Update();

                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();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Fire-Dragon-DoL/CsLglcd
        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();
        }