public void Render() { #region Clear and draw background Graphics g = Graphics.FromImage(LCD); g.Clear(Color.Black); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; #endregion #region Draw to the screen LetterMgr.Instance.Render(g); g.DrawString(string.Format("{0}/{1}/{2}", LetterMgr.Instance.CorrectAnswersGiven, LetterMgr.Instance.LettersDone, LetterMgr.Instance.TotalLetters), GFont, Brushes.White, 0, 0); if (LetterMgr.Instance.State == eState.WrongChoice) { g.DrawImage(ErrorImg, ScreenRect); } else if (LetterMgr.Instance.State == eState.GoodChoice) { g.DrawImage(CorrectImg, new Rectangle(40, 0, 240, 240)); } #endregion #region Send to LCD if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW); } else { DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_QVGA); } #endregion #region Clean up g.Dispose(); #endregion }
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_FormClosing(object sender, FormClosingEventArgs e) { if (LCD != null) { GFont.Dispose(); LoadingImg.Dispose(); LCD.Dispose(); DMcLgLCD.LcdClose(device); DMcLgLCD.LcdDisconnect(connection); DMcLgLCD.LcdDeInit(); } // Release the icon resource. if (SettingsMgr.Instance.UseTrayIcon) { if (TrayIcon != null) { TrayIcon.Dispose(); } } }
public void DoButtons() { uint buttons = DMcLgLCD.LcdReadSoftButtons(device); if (buttons != last_buttons) { if ((buttons & (DMcLgLCD.LGLCD_BUTTON_1 | DMcLgLCD.LGLCD_BUTTON_LEFT)) != 0) { ButtonLEFT(this); } if ((buttons & (DMcLgLCD.LGLCD_BUTTON_2 | DMcLgLCD.LGLCD_BUTTON_RIGHT)) != 0) { ButtonRIGHT(this); } if ((buttons & (DMcLgLCD.LGLCD_BUTTON_3 | DMcLgLCD.LGLCD_BUTTON_OK)) != 0) { ButtonOK(this); } if ((buttons & (DMcLgLCD.LGLCD_BUTTON_4 | DMcLgLCD.LGLCD_BUTTON_MENU)) != 0) { ButtonMENU(this); } if ((buttons & DMcLgLCD.LGLCD_BUTTON_UP) != 0) { ButtonUP(this); } if ((buttons & DMcLgLCD.LGLCD_BUTTON_DOWN) != 0) { ButtonDOWN(this); } if ((buttons & DMcLgLCD.LGLCD_BUTTON_CANCEL) != 0) { ButtonCANCEL(this); } last_buttons = buttons; } }
public void RenderLoadingScreen(string loadText) { Graphics g = Graphics.FromImage(LCD); g.DrawImage(LoadingImg, ScreenRect); SizeF measure = g.MeasureString(loadText, GFont); g.DrawString(loadText, GFont, Brushes.White, 160 - measure.Width / 2, 185); g.Dispose(); #region Send to LCD if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW); } else { DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_QVGA); } #endregion }
private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e) { Font sFont; Graphics g = Graphics.FromImage(LCD); // Creates a graphics for the display g.Clear(Color.White); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; sFont = new Font("Arial", 7, FontStyle.Regular); // Creates a font that is used to write to the display. Should be able to change this to whatever you want to use. if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType) { RectangleF rtTitle = new RectangleF(0, 20, 24, 10); // Writes all the information that the RPC has returned to the display using the font specified above. g.DrawString("Album: " + album, sFont, Brushes.Black, 0, 0); g.DrawString("Artist: " + artist, sFont, Brushes.Black, 0, 10); g.DrawString(title, sFont, Brushes.Black, rTitle); g.FillRectangle(Brushes.White, rtTitle); g.DrawString("Title: ", sFont, Brushes.Black, rtTitle); g.DrawString("Duration: " + cTime + " / " + tTime, sFont, Brushes.Black, 0, 30); DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW); #region int charsTitle = 0; SizeF stringSize; if (title != null) { charsTitle = title.Length; stringSize = g.MeasureString(title, sFont); rTitle.Width = stringSize.Width; } if (charsTitle > maxCharsTitle) { if (!reverseTitle) { if (tmpLocationX >= -rTitle.Width + 150) { tmpLocationX = (int)rTitle.X - 1; if (tmpLocationX <= -rTitle.Width + 150) { reverseTitle = true; } } } else { tmpLocationX = (int)rTitle.X + 1; if (tmpLocationX >= 30) { reverseTitle = false; } } rTitle.X = tmpLocationX; } else { //Console.WriteLine(rtTitle.Width); rTitle.X = rtTitle.Width; } #endregion } pbLCD.Image = LCD; sFont.Dispose(); // Disposes the fonts and graphics after the values were displayed on the screen. g.Dispose(); bool audioPlaying = checkAudio(); // Checks to determine whether the audio is currently playing or not, which is then used to update the balloon. if (audioPlaying) { if (artist != "") { if (title != previousSong) // Only display the balloon popup on a new song. { ResetTitleBox(); BalloonTimer(); } } btnRequest_Click(this, null); // Requests the song information. Required because the song updates the time every second. } }
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(); } }
public void Awake() { if (GHudmain != null) { return; } GHudmain = this; UnityEngine.Object.DontDestroyOnLoad(GHudmain); if (!lcd_initialized) { DMcLgLCD.LcdInit(); lcd_initialized = true; } Device bw_dev = new DeviceBW(); Device color_dev = new DeviceQVGA(); if (bw_dev != null && bw_dev.isValid()) { devices.Add(bw_dev); OrbitInfo initialbw = new OrbitInfo(bw_dev, "✈", System.Drawing.Color.Black, System.Drawing.Color.Black); initialbw.Activate(); bw_dev.modules.Add(initialbw); OrbitInfo targetinfo = new OrbitInfo(bw_dev, "+", System.Drawing.Color.Black, System.Drawing.Color.Black); targetinfo.is_target_type_module = true; bw_dev.modules.Add(targetinfo); bw_dev.modules.Add(new OrbitGraph(bw_dev, System.Drawing.Color.Yellow, "✈")); OrbitGraph tgt_orbitgraph = new OrbitGraph(bw_dev, System.Drawing.Color.Yellow, "+"); tgt_orbitgraph.is_target_type_module = true; bw_dev.modules.Add(tgt_orbitgraph); } if (color_dev != null && color_dev.isValid()) { devices.Add(color_dev); VesselInfo initialcolor = new VesselInfo(color_dev); initialcolor.Activate(); color_dev.modules.Add(initialcolor); //color_dev.modules.Add(new OrbitInfo(color_dev, "✈", System.Drawing.Color.FromArgb(0xee, 0xee, 0x00), System.Drawing.Color.FromArgb(0xaa, 0xaa, 0x44))); /* * OrbitInfo col_targetinfo = new OrbitInfo(color_dev, "⊹", System.Drawing.Color.LightBlue, System.Drawing.Color.MediumPurple); * col_targetinfo.is_target_type_module = true; * color_dev.modules.Add(col_targetinfo); */ color_dev.modules.Add(new OrbitGraph(color_dev, System.Drawing.Color.Yellow, "✈")); OrbitGraph tgt_orbitgraph = new OrbitGraph(color_dev, System.Drawing.Color.LightBlue, "+"); tgt_orbitgraph.is_target_type_module = true; color_dev.modules.Add(tgt_orbitgraph); } foreach (Device dev in devices) { dev.ButtonUP += new Device.ButtonHandler(ButtonUp); dev.ButtonDOWN += new Device.ButtonHandler(ButtonDown); dev.ButtonLEFT += new Device.ButtonHandler(ButtonLeft); dev.ButtonRIGHT += new Device.ButtonHandler(ButtonRight); dev.ButtonOK += new Device.ButtonHandler(ButtonOk); dev.ButtonCANCEL += new Device.ButtonHandler(ButtonCancel); dev.ButtonMENU += new Device.ButtonHandler(ButtonMenu); dev.DisplayFrame(); } }