Пример #1
0
        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);
            }
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
        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;
        }