public LCDForm() { InitializeComponent(); if (File.Exists("DMcLgLCD.dll")) { _LCDUpdateTimer = new Timer(); _LCDUpdateTimer.Interval = 34; _LCDUpdateTimer.Tick += _OnLCDUpdate; _LCDButtonPressTimer = new Timer(); _LCDButtonPressTimer.Interval = 100; _LCDButtonPressTimer.Tick += _OnLCDButtonPressTimer; DMcLgLCD.LcdInit(); var Connection = DMcLgLCD.LcdConnectEx(_appletname, 0, 0); if (Connection != DMcLgLCD.LGLCD_INVALID_CONNECTION) { _device = DMcLgLCD.LcdOpenByType(Connection, DMcLgLCD.LGLCD_DEVICE_QVGA); if (_device != DMcLgLCD.LGLCD_INVALID_DEVICE) { DMcLgLCD.LcdSetAsLCDForegroundApp(_device, DMcLgLCD.LGLCD_FORE_YES); _LCDUpdateTimer.Start(); _LCDButtonPressTimer.Start(); } } } }
private void Kodi_Applet_Load(object sender, EventArgs e) { if (DMcLgLCD.ERROR_SUCCESS == DMcLgLCD.LcdInit()) { connection = DMcLgLCD.LcdConnectEx("Kodi Media Keys", 0, 0); // Initializes the display with a useful name to identify the application if (DMcLgLCD.LGLCD_INVALID_CONNECTION != connection) { device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_QVGA); if (DMcLgLCD.LGLCD_INVALID_DEVICE == device) // Determines whether or not the keyboard is a G15 or G19 (currently the application is only tested on a G15) { device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_BW); if (DMcLgLCD.LGLCD_INVALID_DEVICE != device) { deviceType = DMcLgLCD.LGLCD_DEVICE_BW; } } else { deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA; } if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { LCD = new Bitmap(160, 43); // Sets the screen size of the keyboard display Graphics g = Graphics.FromImage(LCD); g.Clear(Color.White); g.Dispose(); DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW); DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES); pbLCD.Width = 160; // Sets the picture box display (that is shown when the user double clicks the icon). pbLCD.Height = 43; } if (deviceType > 0) // Only update the screen if there is a screen to update. { DMcLgLCD.LcdSetConfigCallback(cfgCallback); updateTimer = new System.Timers.Timer(100); updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent); updateTimer.Interval = 100; // Wil. update the display every 100ms. Likely only required to use a value of 1000. This is required to update the current song time. updateTimer.Enabled = true; } } } }
private void Main_Load(object sender, EventArgs e) { this.LoadConfig(); if (DMcLgLCD.LcdInit() == DMcLgLCD.ERROR_SUCCESS) { this.connection = DMcLgLCD.LcdConnectEx("League Of Legends Info", 0, 0); if (this.connection != DMcLgLCD.LGLCD_INVALID_CONNECTION) { this.device = DMcLgLCD.LcdOpenByType(this.connection, DMcLgLCD.LGLCD_DEVICE_QVGA); if (this.device == DMcLgLCD.LGLCD_INVALID_DEVICE) { this.device = DMcLgLCD.LcdOpenByType(this.connection, DMcLgLCD.LGLCD_DEVICE_BW); if (this.device != DMcLgLCD.LGLCD_INVALID_DEVICE) { this.deviceType = DMcLgLCD.LGLCD_DEVICE_BW; } } else { this.deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA; } if (this.deviceType == DMcLgLCD.LGLCD_DEVICE_QVGA) { this.Screens[LCD_SCREEN_LOADING] = getImage(@"images\splash.jpg"); Graphics g = Graphics.FromImage(this.Screens[LCD_SCREEN_LOADING]); g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.DrawString("Awaiting game launch...", new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, 92, 220); g.Dispose(); this.Render(); } if (this.deviceType > 0) { this.MainLoopTask(this.tokenSource1.Token); } } } }
protected void InitLCD() { connection = DMcLgLCD.LcdConnectEx("GHud", 0, 0); if (DMcLgLCD.LGLCD_INVALID_CONNECTION != connection) { device = DMcLgLCD.LcdOpenByType(connection, device_type); if (DMcLgLCD.LGLCD_INVALID_DEVICE == device) { return; } LCD = new Bitmap(width, height); graph = System.Drawing.Graphics.FromImage(LCD); graph.TextRenderingHint = render_hint; ClearLCD("Waiting for Flight..."); DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES); valid = true; } }
private void frmMain_Load(object sender, EventArgs e) { if (DMcLgLCD.ERROR_SUCCESS == DMcLgLCD.LcdInit()) { Instance = this; LetterMgr.Instance.Init(); SettingsMgr.Instance.Load(); if (SettingsMgr.Instance.IsFirstRun) { SettingsMgr.Instance.IsFirstRun = false; SettingsMgr.Instance.Save(); try { AutoStart.SetAutoStart(); } catch {} } LCDShotFolder = string.Format("{0}/LCD Shots/", Application.StartupPath); if (!Directory.Exists(LCDShotFolder)) { Directory.CreateDirectory(LCDShotFolder); } Visible = false; ShowInTaskbar = false; #region Tray if (SettingsMgr.Instance.UseTrayIcon) { TrayMenu = new ContextMenu(); TrayMenu.MenuItems.Add("Take LCD &Shot", OnLCDShot); TrayMenu.MenuItems.Add("&Config", OnConfig); TrayMenu.MenuItems.Add("-"); TrayMenu.MenuItems.Add("&Exit", OnExit); TrayIcon = new NotifyIcon(); TrayIcon.Text = "Learn Japanese"; TrayIcon.Icon = new Icon(Application.StartupPath + "/Icon.ico", 32, 32); // Add menu to tray icon and show it. TrayIcon.ContextMenu = TrayMenu; TrayIcon.Visible = true; } #endregion #region Font if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { GFont = new Font("Arial", 5, FontStyle.Regular); } else { GFont = new Font("Arial", 12, FontStyle.Regular); } #endregion connection = DMcLgLCD.LcdConnectEx("Learn Japanese", 0, 0); if (DMcLgLCD.LGLCD_INVALID_CONNECTION != connection) { device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_QVGA); if (DMcLgLCD.LGLCD_INVALID_DEVICE == device) { device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_BW); if (DMcLgLCD.LGLCD_INVALID_DEVICE != device) { deviceType = DMcLgLCD.LGLCD_DEVICE_BW; } } else { deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA; } if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { LCD = new Bitmap(160, 43); Graphics g = Graphics.FromImage(LCD); g.Clear(Color.White); g.Dispose(); DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW); DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES); } else { LCD = new Bitmap(320, 240); Graphics g = Graphics.FromImage(LCD); g.Clear(Color.White); g.Dispose(); DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_QVGA); DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES); } if (deviceType > 0) { //commented out in favor of polling routine. //DMcLgLCD.LcdSetButtonCallback(btnCallback); DMcLgLCD.LcdSetConfigCallback(cfgCallback); //The fastest you should send updates to the LCD is around 30fps or 34ms. 100ms is probably a good typical update speed. timInput.Enabled = true; } timWorkaround.Enabled = true; // sometimes the LCD just shows a white screen for some reason on startup. this 100ms delay fixes that. } } else { MessageBox.Show("Error: The G-keyboard was not detected. The application will not close.", "Hardware not found.", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } }