Пример #1
0
        public static void Main()
        {
            Applet = new LcdApplet("G15 Process Manager", LcdAppletCapabilities.Monochrome);

            Applet.Configure += new EventHandler(Applet_Configure);

            Applet.Connect();

            Device = (LcdDeviceMonochrome)Applet.OpenDeviceByType(LcdDeviceType.Monochrome);

            Device.SoftButtonsChanged += new EventHandler<LcdSoftButtonsEventArgs>(Device_SoftButtonsChanged);

            CurrentIndex = 0;
            CreateGDIPages();

            do
            {
                Device.DoUpdateAndDraw();
                Thread.Sleep(3000);
            }
            while (!_mustExit);

            Applet.Disconnect();

               //Console.ReadKey();
        }
Пример #2
0
        internal static void Main()
        {
            LcdApplet applet = new LcdApplet("GammaJul LgLcd GDI+ Sample", LcdAppletCapabilities.Both);

            // Register to events to know when a device arrives, then connects the applet to the LCD Manager
            applet.Configure        += Applet_Configure;
            applet.DeviceArrival    += Applet_DeviceArrival;
            applet.DeviceRemoval    += Applet_DeviceRemoval;
            applet.IsEnabledChanged += Applet_IsEnabledChanged;
            applet.Connect();

            // We are waiting for the handler thread to warn us for device arrival
            LcdDeviceMonochrome monoDevice = null;

            _waitAre.WaitOne();

            do
            {
                // A monochrome device was connected: creates a monochrome device or reopens an old one
                if (_monoArrived)
                {
                    if (monoDevice == null)
                    {
                        monoDevice = (LcdDeviceMonochrome)applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                        monoDevice.SoftButtonsChanged += MonoDevice_SoftButtonsChanged;
                        CreateMonochromeGdiPages(monoDevice);
                    }
                    else
                    {
                        monoDevice.ReOpen();
                    }
                    _monoArrived = false;
                }

                if (_qvgaArrived)
                {
                    _qvgaArrived = false;
                }

                // We are calling DoUpdateAndDraw in this loop.
                // Note that updating and drawing only happens if the objects in a LcdGdiPage are modified.
                // Even if you call this method very quickly, update and draw will only occur at the frame
                // rate specified by LcdPage.DesiredFrameRate, which is 30 by default.
                if (applet.IsEnabled && monoDevice != null && !monoDevice.IsDisposed)
                {
                    monoDevice.DoUpdateAndDraw();
                }

                Thread.Sleep(5);
            }while (!_mustExit);
        }
        internal static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            devicesList.Lock = new object();
            entriesList.Lock = new object();

            LcdApplet applet = new LcdApplet("Yubico Authenticator", LcdAppletCapabilities.Monochrome);

            // Register to events to know when a device arrives, then connects the applet to the LCD Manager
            applet.Configure        += AppletConfigure;
            applet.DeviceArrival    += AppletDeviceArrival;
            applet.DeviceRemoval    += AppletDeviceRemoval;
            applet.IsEnabledChanged += AppletIsEnableChanged;
            applet.Connect();

            LcdDeviceMonochrome device = null;
            int tick = 0;

            while (true)
            {
                lock (deviceArrivedLock)
                {
                    if (deviceArrived)
                    {
                        if (device == null)
                        {
                            device = (LcdDeviceMonochrome)applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                            device.SoftButtonsChanged += DeviceSoftButtonsChanged;
                            CreatePages(device);
                            device.SetAsForegroundApplet = true;
                        }
                        else
                        {
                            device.ReOpen();
                        }
                    }

                    deviceArrived = false;
                }

                if (applet.IsEnabled && device != null && !device.IsDisposed)
                {
                    device.DoUpdateAndDraw();
                }

                TickTimers(33, ref tick);
                Thread.Sleep(33);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            LcdApplet applet = new LcdApplet("My Test App", LcdAppletCapabilities.Both);

            applet.Configure        += Applet_Configure;
            applet.DeviceArrival    += Applet_DeviceArrival;
            applet.DeviceRemoval    += Applet_DeviceRemoval;
            applet.IsEnabledChanged += Applet_IsEnabledChanged;
            applet.Connect();

            LcdDeviceMonochrome monoDevice = null;

            _waitAre.WaitOne();

            do
            {
                if (_monoArrived)
                {
                    if (monoDevice == null)
                    {
                        monoDevice = (LcdDeviceMonochrome)applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                        monoDevice.SoftButtonsChanged += MonoDevice_SoftButtonsChanged;
                        CreateMonochromeGdiPages(monoDevice);
                    }
                    else
                    {
                        monoDevice.ReOpen();
                    }
                    _monoArrived = false;
                }
                if (_qvgaArrived)
                {
                    _qvgaArrived = false;
                }
                if (applet.IsEnabled && monoDevice != null && !monoDevice.IsDisposed)
                {
                    monoDevice.DoUpdateAndDraw();
                }

                Thread.Sleep(5);
            }while (!_mustExit);
        }
        static void Main()
        {
            Program program = new Program();

            program.StartTrayIcon();

            LcdApplet app = new LcdApplet("Test Logitech LCD Keyboard", LcdAppletCapabilities.Both);

            //set event handling
            app.Configure        += AppletConfigure;
            app.DeviceArrival    += program.DeviceArrival;
            app.DeviceRemoval    += program.DeviceRemoval;
            app.IsEnabledChanged += program.AppletIsEnabledChanged;
            app.Connect();

            // We are waiting for the handler thread to warn us for device arrival
            LcdDeviceMonochrome monoDevice = null;
            LcdDeviceQvga       qvgaDevice = null;

            program.waitAutoResetEvent.WaitOne();

            //enter main loop
            do
            {
                //Handle device arrival
                if (program.arrived && program.deviceType == LcdDeviceType.Monochrome)
                {
                    if (monoDevice == null)
                    {
                        monoDevice = (LcdDeviceMonochrome)app.OpenDeviceByType(program.deviceType);
                        monoDevice.SoftButtonsChanged   += program.MonoDeviceSoftButtonsChanged;
                        program.lcdGraphics              = new LcdGraphics(monoDevice);
                        monoDevice.SetAsForegroundApplet = true;
                    }
                    else
                    {
                        monoDevice.ReOpen();
                    }

                    //reset the arrival flag
                    program.arrived = false;
                }
                if (program.arrived && program.deviceType == LcdDeviceType.Qvga)
                {
                    if (qvgaDevice == null)
                    {
                        qvgaDevice = (LcdDeviceQvga)app.OpenDeviceByType(program.deviceType);
                        qvgaDevice.SoftButtonsChanged   += program.MonoDeviceSoftButtonsChanged;
                        program.lcdGraphics              = new LcdGraphics(qvgaDevice);
                        qvgaDevice.SetAsForegroundApplet = true;
                    }
                    else
                    {
                        qvgaDevice.ReOpen();
                    }

                    //reset the arrival flag
                    program.arrived = false;
                }

                //if there is no lcd keyboard, sleep for a while and look again
                if (monoDevice == null && qvgaDevice == null)
                {
                    Thread.Sleep(20000);
                    continue;
                }

                //Disposed, skip draw, next check loop exits
                if (monoDevice != null && monoDevice.IsDisposed ||
                    qvgaDevice != null && qvgaDevice.IsDisposed)
                {
                    continue;
                }

                //update and draw
                if (app.IsEnabled)
                {
                    if (program.button1Pressed)
                    {
                        //set warning page in object and redraw
                        program.lcdGraphics.SetWarning();
                        monoDevice.DoUpdateAndDraw();

                        //wait and reset
                        Thread.Sleep(2000);
                        program.lcdGraphics.SetMain();

                        //reset flag
                        program.button1Pressed = false;
                    }

                    monoDevice.DoUpdateAndDraw();

                    //let the user enjoy the magical LCD graphics
                    Thread.Sleep(30);
                }
            }while (program.stillAlive);
        }
Пример #6
0
        internal static void Main(string[] args)
        {
            bool showTitles = true;

            if (args != null && args.Length != 0)
            {
                if (args[0] == "notitles")
                {
                    showTitles = false;
                }
            }

            try
            {
                SpotifyStatusApplet ssa = new SpotifyStatusApplet(showTitles);
                ssa.setupSpotify();

                ssa.setupTrayIcon();

                LcdApplet applet = new LcdApplet("Spotify Status Applet", LcdAppletCapabilities.Both);

                // Register to events to know when a device arrives, then connects the applet to the LCD Manager
                applet.Configure        += appletConfigure;
                applet.DeviceArrival    += ssa.appletDeviceArrival;
                applet.DeviceRemoval    += ssa.appletDeviceRemoval;
                applet.IsEnabledChanged += ssa.appletIsEnabledChanged;
                applet.Connect();

                // We are waiting for the handler thread to warn us for device arrival
                LcdDeviceMonochrome monoDevice = null;
                ssa.m_waitAutoResetEvent.WaitOne();

                do
                {
                    // A monochrome device is connected: creates a monochrome device or reopens an old one
                    if (true == ssa.m_monoArrived)
                    {
                        if (null == monoDevice)
                        {
                            monoDevice = (LcdDeviceMonochrome)applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                            monoDevice.SoftButtonsChanged += ssa.monoDeviceSoftButtonsChanged;
                            ssa.m_lcdGraphics              = new LcdGraphics();
                            ssa.m_lcdGraphics.createMonochromeGdiPages(monoDevice);
                            monoDevice.SetAsForegroundApplet = true;
                        }
                        else
                        {
                            monoDevice.ReOpen();
                        }

                        // serviced the last device connection so reset the arrival flag
                        ssa.m_monoArrived = false;
                    }

                    if (ssa.m_qvgaArrived)
                    {
                        // TODO add the implementation as a future project
                        ssa.m_qvgaArrived = false;
                    }

                    // DoUpdateAndDraw only occurs at the framerate specified by LcdPage.DesiredFrameRate, which is 30 by default.
                    if (true == applet.IsEnabled &&
                        null != monoDevice &&
                        false == monoDevice.IsDisposed)
                    {
                        ssa.m_lcdGraphics.setMediaPlayerDetails(ssa.getCurrentSpotifyDetails());
                        ssa.m_lcdGraphics.setShowTitles(ssa.m_showTitles);
                        monoDevice.DoUpdateAndDraw();
                    }

                    Thread.Sleep(33);
                }while (true == ssa.m_keepRunning);
            }
            catch (Exception e)
            {
                Console.WriteLine("Caught exception, application exited " + e.ToString());
            }
        }
Пример #7
0
        internal static int Main(string[] args)
        {
            bool showTitles = true;

            if (args != null && args.Length != 0)
            {
                if (args[0] == "notitles")
                {
                    showTitles = false;
                }
            }

            try
            {
                SpotifyStatusApplet ssa = new SpotifyStatusApplet(showTitles);
                a_ConnectionStatus = ssa.SetupSpotify();
                if (a_ConnectionStatus != 0)
                {
                    Trace.TraceError("Critical Error: Spotify couldn't start.\n\tTerminating SpotifyStatusApplet.\t\nReturn Value of SetupSpotify(): " + a_ConnectionStatus);
                    //Applet cannot function if Spotify or SpotifyWebHelper is unable to open. Return from Main thread with error 1.
                    return(1);
                }

                StatusResponse spotify_Status = ssa.s_spotify.GetStatus();
                //The applet crashes when having to wait for the Spotify song information (When the app is completely exited).
                //This waits until it loads in and has a 2 second timeout.
                for (int i = 0; (spotify_Status.Track == null); i++)
                {
                    Thread.Sleep(1);
                    if (i > 2000)
                    {
                        break;
                    }
                    if (i > 1998)
                    {
                        a_SongLoadTimeoutExpired = true;
                    }
                }
                if (a_SongLoadTimeoutExpired == true)
                {
                    Trace.TraceWarning("Couldn't load track information. \n\tTerminating SpotifyStatusApplet.");
                    return(1);
                }

                ssa.setupTrayIcon();

                LcdApplet applet = new LcdApplet("Spotify Status Applet", LcdAppletCapabilities.Both);

                // Register to events to know when a device arrives, then connects the applet to the LCD Manager
                applet.Configure        += appletConfigure;
                applet.DeviceArrival    += ssa.appletDeviceArrival;
                applet.DeviceRemoval    += ssa.appletDeviceRemoval;
                applet.IsEnabledChanged += ssa.appletIsEnabledChanged;
                applet.Connect();

                // We are waiting for the handler thread to warn us for device arrival
                LcdDeviceMonochrome monoDevice = null;
                ssa.m_waitAutoResetEvent.WaitOne();

                do
                {
                    // A monochrome device is connected: creates a monochrome device or reopens an old one
                    if (true == ssa.m_monoArrived)
                    {
                        if (null == monoDevice)
                        {
                            monoDevice = (LcdDeviceMonochrome)applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                            monoDevice.SoftButtonsChanged += ssa.monoDeviceSoftButtonsChanged;
                            ssa.m_lcdGraphics              = new LcdGraphics();
                            ssa.m_lcdGraphics.createMonochromeGdiPages(monoDevice);
                            monoDevice.SetAsForegroundApplet = true;
                        }
                        else
                        {
                            monoDevice.ReOpen();
                        }

                        // serviced the last device connection so reset the arrival flag
                        ssa.m_monoArrived = false;
                    }

                    if (ssa.m_qvgaArrived)
                    {
                        // TODO add the implementation as a future project
                        ssa.m_qvgaArrived = false;
                    }

                    // DoUpdateAndDraw only occurs at the framerate specified by LcdPage.DesiredFrameRate, which is 30 by default.
                    if (true == applet.IsEnabled &&
                        null != monoDevice &&
                        false == monoDevice.IsDisposed)
                    {
                        ssa.m_lcdGraphics.setMediaPlayerDetails(ssa.getCurrentSpotifyDetails());
                        ssa.m_lcdGraphics.setShowTitles(ssa.m_showTitles);
                        monoDevice.DoUpdateAndDraw();
                    }

                    Thread.Sleep(33);
                }while (true == ssa.m_keepRunning);
            }
            catch (Exception e)
            {
                Trace.TraceError("Caught exception, application exited " + e.ToString());
            }
            return(0);
        }