private void BeginCheck() { string sMyVersionDate = _pas.GetString("VersionDate"); string sCurrentVersionDate = GetCurrentVersionDate(); if (!string.IsNullOrWhiteSpace(sCurrentVersionDate) && sMyVersionDate != sCurrentVersionDate) { if (_pas.GetBoolean("AutomaticUpdates") || MessageBox.Show("A newer version of Quote of the Day is available. Would you like to update?", "Update Available", MessageBoxButtons.YesNo) == DialogResult.Yes) { string sSaveLocation = this.GetType().Assembly.Location; if (GetCurrentVersion(sSaveLocation + ".newversion")) { try { File.Delete(sSaveLocation + ".previousversion"); File.Move(sSaveLocation, sSaveLocation + ".previousversion"); File.Move(sSaveLocation + ".newversion", sSaveLocation); if (!_pas.GetBoolean("AutomaticUpdates")) { MessageBox.Show( "Quote of the Day has been updated. Update will be applied on next restart of LaunchBox/BigBox", "Update Successful", MessageBoxButtons.OK); } _pas.SetString("VersionDate", sCurrentVersionDate); _pas.Save(); } catch (Exception exception) { if (!_pas.GetBoolean("AutomaticUpdates")) { MessageBox.Show( "Quote of the Day could not be updated. Exception: " + exception.Message, "Update Unsuccessful", MessageBoxButtons.OK); } } } } } else if (!_pas.GetBoolean("AutomaticUpdates") && string.IsNullOrWhiteSpace(sCurrentVersionDate)) { MessageBox.Show( "A version number could not be found. This may indicate a network issue or a configuration issue. Check VersionUrl in QuoteOfTheDay.dll.config.", "Version not fond", MessageBoxButtons.OK); } else if (!_pas.GetBoolean("AutomaticUpdates")) { MessageBox.Show("You are up to date.", "No Update Available", MessageBoxButtons.OK); } }
/* * Display Bible Gateway Verse of the Day from rss * https://www.biblegateway.com/usage/votd/docs/ * * BibleVersion is the version to display. 31 is NIV. * A complete listing of versions can be found here: * http://www.biblegateway.com/usage/linking/versionslist/ */ private string GetBibleGatewayQuote() { string sQuote = string.Empty; string sURL = "https://www.biblegateway.com/usage/votd/rss/votd.rdf?" + _pas.GetString("BibleVersion"); XmlDocument doc1 = new XmlDocument(); doc1.Load(sURL); XmlElement root = doc1.DocumentElement; XmlNodeList nodes = root.SelectNodes("/rss/channel/item"); if (nodes != null && nodes.Count >= 0) { XmlNode node = nodes[0]; string sTitle = node["title"].InnerText; sQuote = node["content:encoded"].InnerText; sQuote = sQuote.Replace("“", "\""); sQuote = sQuote.Replace("”", "\""); sQuote = sQuote.Replace("<br/><br/>", ""); sQuote = sQuote.Replace("Brought to you by ", " - " + sTitle + " provided by "); sQuote = sQuote.Replace("<a href=\"https://www.biblegateway.com\">", ""); sQuote = sQuote.Replace("</a>", ""); sQuote = sQuote.Replace("All Rights Reserved.", ""); } return(sQuote); }
private void frmSettings_Load(object sender, EventArgs e) { chkLaunchBox.Checked = _pas.GetBoolean("ShowInLaunchBox"); chkBigBox.Checked = _pas.GetBoolean("ShowInBigBox"); cmbQOTD_Type.SelectedItem = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_pas.GetString("QOTD_Type")); if (!string.IsNullOrWhiteSpace(_pas.GetString("LocalFileLocation")) && File.Exists(_pas.GetString("LocalFileLocation"))) { txtLocalFileLocation.Text = _pas.GetString("LocalFileLocation"); } else { var assemblyLocation = this.GetType().Assembly.Location; if (assemblyLocation != null) { txtLocalFileLocation.Text = assemblyLocation.Replace(this.GetType().Assembly.GetName().Name + ".dll", "") + "Quotes.xml"; } } openFileDialog1.InitialDirectory = Path.GetDirectoryName(txtLocalFileLocation.Text); openFileDialog1.FileName = txtLocalFileLocation.Text; fontDialog1.Font = new FontConverter().ConvertFromInvariantString(_pas.GetString("FontStyle")) as Font; if (fontDialog1.Font != null) { txtFontStyle.Text = fontDialog1.Font.Name; txtFontStyle.Font = fontDialog1.Font; } var oColor = new ColorConverter().ConvertFromInvariantString(_pas.GetString("FontColor")); if (oColor != null) { fontDialog1.Color = (Color)oColor; txtFontStyle.ForeColor = fontDialog1.Color; } oColor = new ColorConverter().ConvertFromInvariantString(_pas.GetString("BackgroundColor")); if (oColor != null) { colorDialog1.Color = (Color)oColor; txtBackgroundColor.Text = colorDialog1.Color.Name; txtBackgroundColor.BackColor = colorDialog1.Color; txtFontStyle.BackColor = colorDialog1.Color; if (txtBackgroundColor.ForeColor == txtBackgroundColor.BackColor) { txtBackgroundColor.ForeColor = fontDialog1.Color; } } nudSecondsToDisplayQuotePerWord.Text = _pas.GetString("SecondsToDisplayQuotePerWord"); nudBackgroundOpacityPercentage.Text = _pas.GetString("BackgroundOpacityPercentage"); nudTransparancyAlphaValue.Text = _pas.GetString("TransparancyAlphaValue"); nudMaxNumberOfLines.Text = _pas.GetString("MaxNumberOfLines"); cmbAutomaticUpdates.SelectedItem = _pas.GetBoolean("AutomaticUpdates") ? "On" : "Off"; btnSave.Enabled = false; btnTest.Enabled = true; btnCheckForUpdates.Enabled = true; }