//public bool firstTime = false;

        #endregion

        #region Periodic Functions and Timers

        public d_form()
        {
            InitializeComponent();
            InitializeTimer();
            if (!File.Exists(JSONpath))
            {
                Directory.CreateDirectory(MyPath);
                //firstTime = true;
                //firstTime = true;
                SilverPreferences myPreference = new SilverPreferences();

                myPreference.pr_highDollars     = Int16.Parse(d_highPriceDollar.Text);
                myPreference.pr_highCents       = Int16.Parse(d_highPriceCent.Text);
                myPreference.pr_lowDollars      = Int16.Parse(d_lowPriceDollar.Text);
                myPreference.pr_lowCents        = Int16.Parse(d_lowPriceCent.Text);
                myPreference.pr_intervalMins    = Int16.Parse(d_updateTimeInput.Text);
                myPreference.pr_showUpdates     = d_periodicNotificationBox.Checked;
                myPreference.pr_showHigh        = d_highPriceBox.Checked;
                myPreference.pr_showLow         = d_lowPriceBox.Checked;
                myPreference.pr_launchOnStartup = d_runOnStartupBox.Checked;

                string JSONresult = JsonConvert.SerializeObject(myPreference);

                Thread.Sleep(5000);
                using (var JSONwriter = new StreamWriter(JSONpath, true))
                {
                    JSONwriter.WriteLine(JSONresult);
                    JSONwriter.Close();
                }
            }
            UpdatePriceText();
            InitJSONSettings();
            OverwritePreferencesWithJSON();
            d_notificationTimer.Interval = TimeInterval * 60000;
            d_notificationTimer.Enabled  = true;
        }
        private void d_buttonSaveNotifications_Click(object sender, EventArgs e)
        {
            if (ErrorMessages() == "")
            {
                SilverPreferences myPreference = new SilverPreferences();

                myPreference.pr_highDollars     = Int16.Parse(d_highPriceDollar.Text);
                myPreference.pr_highCents       = Int16.Parse(d_highPriceCent.Text);
                myPreference.pr_lowDollars      = Int16.Parse(d_lowPriceDollar.Text);
                myPreference.pr_lowCents        = Int16.Parse(d_lowPriceCent.Text);
                myPreference.pr_intervalMins    = Int16.Parse(d_updateTimeInput.Text);
                myPreference.pr_showUpdates     = d_periodicNotificationBox.Checked;
                myPreference.pr_showHigh        = d_highPriceBox.Checked;
                myPreference.pr_showLow         = d_lowPriceBox.Checked;
                myPreference.pr_launchOnStartup = d_runOnStartupBox.Checked;

                string JSONresult = JsonConvert.SerializeObject(myPreference);

                if (File.Exists(JSONpath))
                {
                    Thread.Sleep(1000);

                    /*
                     * if (firstTime)
                     * {
                     *  Thread.Sleep(1000);
                     *  firstTime = false;
                     * }
                     */
                    MessageBox.Show("Thank you for downloading Jake_Guy_11's Silver Assistant! Please have a look at the Info/Instructions tab before attempting to use the many functions of the app.",
                                    "Welcome to Jake_Guy_11's Silver Assistant",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    File.Delete(JSONpath);
                    using (var JSONwriter = new StreamWriter(JSONpath, true))
                    {
                        JSONwriter.WriteLine(JSONresult);
                        JSONwriter.Close();
                    }
                }
                else if (!File.Exists(JSONpath))
                {
                    Thread.Sleep(1000);
                    using (var JSONwriter = new StreamWriter(JSONpath, true))
                    {
                        JSONwriter.WriteLine(JSONresult);
                        JSONwriter.Close();
                    }
                }
                if (d_runOnStartupBox.Checked)
                {
                    try
                    {
                        RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                        reg.SetValue("JG11s Silver Price Checker", Application.ExecutablePath.ToString());
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    try
                    {
                        RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                        reg.DeleteValue("JG11s Silver Price Checker");
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else
            {
                ShowNotification("Could Not Complete Operation", "Please fix the printed errors and try again");
            }

            Application.Restart();
        }