예제 #1
0
        public void Run()
        {
            if (_applet == null)
            {
                return;
            }

            _applet.Connect();

            _device = null;
            _waitAre.WaitOne();

            do
            {
                if (_monoArrived)
                {
                    _device = (LcdDeviceMonochrome)_applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                    _device.SoftButtonsChanged += _device_SoftButtonsChanged;
                    Draw();
                }

                if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
                {
                    _device.DoUpdateAndDraw();
                }
            } while (!_mustExit);

            if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
            {
                _device.DoUpdateAndDraw();
            }

            Thread.Sleep(5);
        }
예제 #2
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();
        }
예제 #3
0
        /// <summary>
        /// On startup, we are creation a new Applet.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            _applet = new LcdApplet("GammaJul LgLcd WPF Sample", LcdAppletCapabilities.Qvga);

            // Register to events to know when a device arrives, then connects the applet to the LCD Manager
            _applet.DeviceArrival += Applet_DeviceArrival;
            _applet.Connect();
        }
예제 #4
0
        public LCDHandler()
        {
            UpdatedTimer.AutoReset = true;
            UpdatedTimer.Elapsed  += new ElapsedEventHandler(UpdatedTimer_Elapsed);
            UpdatedTimer.Start();

            _Applet = new LcdApplet("Skype LCD", LcdAppletCapabilities.Both, true);


            _Applet.DeviceArrival += new EventHandler <LcdDeviceTypeEventArgs>(_Applet_DeviceArrival);
            _Applet.Configure     += new EventHandler(_Applet_Configure);
            _Applet.Connect();
        }
예제 #5
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);
            }
        }
예제 #7
0
        static void InitApp()
        {
            ConsoleReporter.Report("Initializing applet...", ConsoleReporter.ReportStatus.Process, _logEnabled);
            _applet = new LcdApplet(Constants.APP_NAME, LcdAppletCapabilities.Monochrome);

            _applet.Configure        += _applet_Configure;
            _applet.DeviceArrival    += _applet_DeviceArrival;
            _applet.DeviceRemoval    += _applet_DeviceRemoval;
            _applet.IsEnabledChanged += _applet_IsEnabledChanged;

            ConsoleReporter.Report("Applet initialized", ConsoleReporter.ReportStatus.Info, _logEnabled);
            ConsoleReporter.Report("Connecting applet...", ConsoleReporter.ReportStatus.Process, _logEnabled);
            _applet.Connect();
            ConsoleReporter.Report("Connection completed", ConsoleReporter.ReportStatus.Info, _logEnabled);
        }
예제 #8
0
        public MainWindow()
        {
            InitializeComponent();

            _Applet = new LcdApplet("zTWArena", LcdAppletCapabilities.Monochrome, false);
            _Applet.DeviceArrival += _Applet_DeviceArrival;

            _Applet.Connect();

            ah.OnLine += Ah_OnLine;

            runningTimer.AutoReset = true;
            runningTimer.Elapsed += RunningTimer_Elapsed;

            this.Loaded += MainWindow_Loaded;
        }
예제 #9
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);
        }
예제 #10
0
        internal static void Main()
        {
            SoundPlayer = new SoundPlayer();
            // Create a new applet for the monochrome LCD Screen and set it to auto-start.
            LcdApplet applet = new LcdApplet("League Of Legends Timer G15", LcdAppletCapabilities.Monochrome, true);

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

            // We are waiting for the handler thread to warn us for device arrival
            _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;
                }

                // 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);
        }
        public void connectDevice()
        {
            LcdAppletCapabilities appletCapabilities = LcdAppletCapabilities.Both;

            applet_ = new LcdApplet("MusicBee V2", appletCapabilities, false);

            try
            {
                if (!applet_.IsConnected)
                {
                    applet_.DeviceArrival += new EventHandler <LcdDeviceTypeEventArgs>(applet_DeviceArrival);
                    applet_.DeviceRemoval += new EventHandler <LcdDeviceTypeEventArgs>(applet_DeviceRemoval);

                    applet_.ConnectionDisrupted += new EventHandler(errorHappend);

                    applet_.Connect();
                }
            }
            catch (Exception)
            {
                Thread.Sleep(5000);
                connectDevice();
            }
        }
        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);
        }
예제 #13
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());
            }
        }
예제 #14
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);
        }
예제 #15
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());
            }
        }
예제 #16
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);
        }