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); }
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(); }
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); }
static void Main(string[] args) { if (args.Length >= 1) { _logEnabled = (args[0] == "-debug"); ConsoleReporter.Report(String.Format("Log {0}", (_logEnabled) ? "enabled" : "disabled"), ConsoleReporter.ReportStatus.Info, _logEnabled); } Console.WriteLine("{0}\nVersion {1}\n{2}\n", Constants.APP_NAME.ToUpper(), Constants.APP_VERSION, Constants.APP_COPYRIGHT); InitDB(); InitApp(); InitSettings(); _device = null; _waitAre.WaitOne(); ConsoleReporter.Report("WaitOne done", ConsoleReporter.ReportStatus.None, _logEnabled); do { if (_monoArrived) { ConsoleReporter.Report("Mono Device arrived", ConsoleReporter.ReportStatus.Info, _logEnabled); if (_device == null) { _device = (LcdDeviceMonochrome)_applet.OpenDeviceByType(LcdDeviceType.Monochrome); _device.SoftButtonsChanged += _device_SoftButtonsChanged; InitGraphics(_device); } else { _device.ReOpen(); } _monoArrived = false; } if (_applet.IsEnabled && _device != null && !_device.IsDisposed) { _device.DoUpdateAndDraw(); } } while (!_mustExit); if (_applet.IsEnabled && _device != null && !_device.IsDisposed) { _device.DoUpdateAndDraw(); } ConsoleReporter.Report("Applet done! Quitting...", ConsoleReporter.ReportStatus.Process, _logEnabled); Thread.Sleep(10); }
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); } }
void _Applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e) { if (_Device == null) { Console.WriteLine("Device Arrived!"); _Device = _Applet.OpenDeviceByType(e.DeviceType); _Device.SoftButtonsChanged += new EventHandler <LcdSoftButtonsEventArgs>(_Device_SoftButtonsChanged); Pages.Add("NewMessage", new MyLcdGdiPage(_Device, this)); Pages["NewMessage"].SoftButtonsChanged += new EventHandler <LcdSoftButtonsEventArgs>(NewMessage_SoftButtonsChanged); Pages["NewMessage"].Updated += new EventHandler <UpdateEventArgs>(LCDHandler_Updated); Pages["NewMessage"].Add("BG", new LcdGdiRectangle()); Pages["NewMessage"].Get <LcdGdiRectangle>("BG").Size = new System.Drawing.SizeF(_Device.PixelWidth, _Device.PixelHeight); Pages["NewMessage"].Get <LcdGdiRectangle>("BG").Brush = System.Drawing.Brushes.Black; Pages["NewMessage"].Add("Time", new LcdGdiText()); Pages["NewMessage"].Get <LcdGdiText>("Time").Text = ""; Pages["NewMessage"].Get <LcdGdiText>("Time").VerticalAlignment = LcdGdiVerticalAlignment.Top; Pages["NewMessage"].Get <LcdGdiText>("Time").HorizontalAlignment = LcdGdiHorizontalAlignment.Left; textFont = new System.Drawing.Font(Pages["NewMessage"].Get <LcdGdiText>("Time").Font, System.Drawing.FontStyle.Bold); Pages["NewMessage"].Get <LcdGdiText>("Time").Font = textFont; Pages["NewMessage"].Get <LcdGdiText>("Time").Brush = System.Drawing.Brushes.White; Pages["NewMessage"].Add("Author", new LcdGdiText()); Pages["NewMessage"].Get <LcdGdiText>("Author").Text = ""; Pages["NewMessage"].Get <LcdGdiText>("Author").VerticalAlignment = LcdGdiVerticalAlignment.Top; Pages["NewMessage"].Get <LcdGdiText>("Author").HorizontalAlignment = LcdGdiHorizontalAlignment.Right; Pages["NewMessage"].Get <LcdGdiText>("Author").Font = textFont; Pages["NewMessage"].Get <LcdGdiText>("Author").Brush = System.Drawing.Brushes.White; System.Drawing.StringFormat MessageFormat = new System.Drawing.StringFormat(); MessageFormat.Alignment = System.Drawing.StringAlignment.Center; MessageFormat.LineAlignment = System.Drawing.StringAlignment.Center; Pages["NewMessage"].Add("Message", new LcdGdiText()); Pages["NewMessage"].Get <LcdGdiText>("Message").Text = ""; Pages["NewMessage"].Get <LcdGdiText>("Message").Margin = new MarginF(0, 0, 0, 0); Pages["NewMessage"].Get <LcdGdiText>("Message").StringFormat = MessageFormat; Pages["NewMessage"].Get <LcdGdiText>("Message").VerticalAlignment = LcdGdiVerticalAlignment.Stretch; Pages["NewMessage"].Get <LcdGdiText>("Message").HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch; Pages["NewMessage"].Get <LcdGdiText>("Message").Font = textFont; Pages["NewMessage"].Get <LcdGdiText>("Message").Brush = System.Drawing.Brushes.White; Pages["NewMessage"].SetAsCurrentDevicePage(); } }
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); }
private void applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e) { device_ = applet_.OpenDeviceByType(e.DeviceType); device_.SoftButtonsChanged += new EventHandler <LcdSoftButtonsEventArgs>(buttonPressed); settings_.setDevice(device_); device_.SetAsForegroundApplet = settings_.alwaysOnTop_; Screen startupScreen = new StartupScreen(device_, device_.DeviceType, null, this, 0); lcdScreenList_.Add(startupScreen); device_.CurrentPage = startupScreen; device_.DoUpdateAndDraw(); if (mbApiInterface_.Player_GetPlayState() == PlayState.Playing) { openScreens(); } }
private void OnQvgaDeviceArrived() { // First device arrival, creates the device if (_qvgaDevice == null) { _qvgaDevice = (LcdDeviceQvga)_applet.OpenDeviceByType(LcdDeviceType.Qvga); _sampleControl = new SampleControl(); _qvgaDevice.CurrentPage = new LcdWpfPage(_qvgaDevice) { Element = _sampleControl }; _qvgaDevice.SoftButtonsChanged += QvgaDevice_SoftButtonsChanged; // Starts a timer to update the screen _timer = new DispatcherTimer(TimeSpan.FromMilliseconds(5.0), DispatcherPriority.Render, Timer_Tick, Dispatcher.CurrentDispatcher); } // Subsequent device arrival means the device was removed and replugged, simply reopens it else { _qvgaDevice.ReOpen(); } _qvgaDevice.DoUpdateAndDraw(); }
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); }
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); }
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()); } }
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); }
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()); } }
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); }