private void btnTest_Click(object sender, EventArgs e) { StoreSettingsInAppStrings(); CloseForms(); _oFrmQuote = new frmQuote(); _oFrmQuoteBackground = new frmQuoteBackground(_oFrmQuote); _oFrmQuote.ofrmQuoteBackground = _oFrmQuoteBackground; _oFrmQuoteBackground.Show(); _oFrmQuote.Show(); _oFrmQuoteBackground.Hide(); _oFrmQuote.Hide(); Task.Delay((int)100).ContinueWith(t => new Qotd().DisplayQuote(_oFrmQuote, _oFrmQuoteBackground, _pas)); }
public void OnEventRaised(string eventType) { if (_pas.GetBoolean("AutomaticUpdates") && (eventType == SystemEventTypes.BigBoxStartupCompleted || eventType == SystemEventTypes.LaunchBoxStartupCompleted)) { using (new Update(_pas)); } if (eventType == SystemEventTypes.BigBoxStartupCompleted && _pas.GetBoolean("ShowInBigBox") || eventType == SystemEventTypes.LaunchBoxStartupCompleted && _pas.GetBoolean("ShowInLaunchBox")) { frmQuote oFrmQuote = new frmQuote(); frmQuoteBackground oFrmQuoteBackground = new frmQuoteBackground(oFrmQuote); oFrmQuote.ofrmQuoteBackground = oFrmQuoteBackground; oFrmQuoteBackground.Show(); oFrmQuote.Show(); oFrmQuoteBackground.Hide(); oFrmQuote.Hide(); Task.Delay((int)1000).ContinueWith(t => new Qotd().DisplayQuote(oFrmQuote, oFrmQuoteBackground, _pas)); } }
private void ShowQuote(string sQuote) { // Just return if nothing to show if (string.IsNullOrWhiteSpace(sQuote)) { return; } Color oBackgroundColor = Color.Black; var oColor = new ColorConverter().ConvertFromInvariantString(_pas.GetString("BackgroundColor")); if (oColor != null) { oBackgroundColor = (Color)oColor; } _oFrmQuote.TransparencyKey = oBackgroundColor; _oFrmQuote.BackColor = oBackgroundColor; var oLaunchboxWindow = FindWindow(); if (oLaunchboxWindow != IntPtr.Zero) { Qotd.user32Rect oLaunchBigBoxRectangle; GetWindowRect(oLaunchboxWindow, out oLaunchBigBoxRectangle); int iBoxWidth = oLaunchBigBoxRectangle.Right - oLaunchBigBoxRectangle.Left; int iBoxHeight = oLaunchBigBoxRectangle.Bottom - oLaunchBigBoxRectangle.Top; _oFrmQuote.Width = Convert.ToInt32(iBoxWidth * _pas.GetInt("QuoteWidthPercentage") * .01); _oFrmQuote.Height = Convert.ToInt32(iBoxHeight * _pas.GetInt("QuoteHeightPercentage") * .01); _oFrmQuote.Location = new Point(((iBoxWidth - _oFrmQuote.Width) / 2) + oLaunchBigBoxRectangle.Left, ((iBoxHeight - _oFrmQuote.Height) / 2) + oLaunchBigBoxRectangle.Top); } else { _oFrmQuote.Width = Convert.ToInt32(Screen.PrimaryScreen.Bounds.Width * _pas.GetInt("QuoteWidthPercentage") * .01); _oFrmQuote.Height = Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height * _pas.GetInt("QuoteHeightPercentage") * .01); _oFrmQuote.Location = new Point((Screen.PrimaryScreen.Bounds.Width - _oFrmQuote.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - _oFrmQuote.Height) / 2); } Graphics oGraphics = _oFrmQuote.CreateGraphics(); float emSize = ((float)_oFrmQuote.Width / _pas.GetInt("MinimumCharactersPerLine")); int iFontHeight; Font oFont = new FontConverter().ConvertFromInvariantString(_pas.GetString("FontStyle")) as Font; if (oFont != null) { oFont = new Font(oFont.Name, (float)emSize, oFont.Style); } else { oFont = new Font(FontFamily.GenericSerif, emSize, FontStyle.Italic); } FindBestFitFont(oGraphics, sQuote, _oFrmQuote.ClientRectangle.Size, ref oFont, out iFontHeight); // Resize and reposition the form to accomodate the Font height and number of lines _oFrmQuote.Top += (_oFrmQuote.Height - iFontHeight) / 2; _oFrmQuote.Height = iFontHeight; oGraphics.Dispose(); _oFrmQuoteBackground.BackColor = oBackgroundColor; _oFrmQuoteBackground.Location = _oFrmQuote.Location; _oFrmQuoteBackground.Width = _oFrmQuote.Width; _oFrmQuoteBackground.Height = _oFrmQuote.Height; _oFrmQuoteBackground.Opacity = _pas.GetInt("BackgroundOpacityPercentage") * .01; _oFrmQuoteBackground.Show(); Color oFontColor = Color.White; oColor = new ColorConverter().ConvertFromInvariantString(_pas.GetString("FontColor")); if (oColor != null) { oFontColor = (Color)oColor; } int iSecondsToDisplay = (int)(_pas.GetDecimal("SecondsToDisplayQuotePerWord") * 1000 * WordCount(ref sQuote)); _oFrmQuote.Show(); oGraphics = _oFrmQuote.CreateGraphics(); oGraphics.DrawString(sQuote, oFont, new SolidBrush(Color.FromArgb(_pas.GetInt("TransparancyAlphaValue"), oFontColor)), _oFrmQuote.ClientRectangle); Task.Delay(iSecondsToDisplay).ContinueWith(t => CloseForms()); _oFrmQuote.ShowAndClose(iSecondsToDisplay); Application.OpenForms[_oFrmQuote.Name].Focus(); }