/// <summary>
        /// This is where the app starts executing.
        /// To start, update the current positions in the PositionsTable if the last update
        /// was made earlier than today
        /// Displays the icon in the system tray.
        /// </summary>
        public void Display()
        {
            DateTime lastWeek = DateTime.Now;
            lastWeek.AddDays(-7);

            string dbFile = Program.settings.GetStringValue("Database Filename");
            if (string.IsNullOrEmpty(dbFile))
            {
                dbFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "StockStopAlerts.db";
            }

            if (!File.Exists(dbFile))
            {
                SettingsDialog dlg = new SettingsDialog(dbFile);
                DialogResult rtn = dlg.ShowDialog();
                if (rtn == DialogResult.OK && !String.IsNullOrEmpty(dlg.DatabaseLocation))
                {
                    Program.settings.SetStringValue("Database Filename", dlg.DatabaseLocation);
                    Program.positionsTable.SetDatabaseLocation(dlg.DatabaseLocation);
                    if (dlg.CreateNew || !File.Exists(dlg.DatabaseLocation))
                    {
                        newDatabase = true;
                        Program.positionsTable.CreateDatabase();
                    }
                }
            }
            else
            {
                Program.positionsTable.SetDatabaseLocation(dbFile);
            }

            DateTime previousUpdate = Program.settings.GetDateTimeValue("Last Update");
            if (previousUpdate.Year == 1970)
            {
                Program.settings.SetDateTimeValue("Last Update", lastWeek);
            }
            DateTime now = DateTime.UtcNow;
            if (now.Date > previousUpdate.Date)
            {
                Logger.Log("Display() calling CheckClosingPrices()");
                DateTime lastUpdate;
                if (CheckClosingPrices(out lastUpdate))
                {
                    Logger.Log("Display:CheckClosingPrices() returned true, updating settings.LastUpdate");
                    Program.settings.SetDateTimeValue("Last Update", lastUpdate);
                }

            }

            // Put the icon in the system tray and allow it react to mouse clicks.
            notifyIcon.MouseClick += new MouseEventHandler(Icon_MouseClick);
            notifyIcon.Icon = Resources.AppIcon;
            notifyIcon.Text = "Stock Stop Alerts";
            notifyIcon.Visible = true;

            // Attach a context menu.
            notifyIcon.ContextMenuStrip = new ContextMenus().Create(newDatabase);

            // Create a timer
            timer = new Timer();
            timer.Interval = 1000 * 60 * 30;
            timer.Tick += new EventHandler(TimerEventProcessor);
            timer.Start();
        }
 /// <summary>
 /// Handles the Click event of the Settings control.
 /// </summary>
 void Settings_Click(object sender, EventArgs e)
 {
     string dbfile = Program.settings.GetStringValue("Database Filename");
     if (string.IsNullOrEmpty(dbfile))
     {
         dbfile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "StockStopAlerts.db";
     }
     SettingsDialog dlg = new SettingsDialog(dbfile);
     DialogResult rtn = dlg.ShowDialog();
     if (rtn == DialogResult.OK && !String.IsNullOrEmpty(dlg.DatabaseLocation))
     {
         Program.settings.SetStringValue("Database Filename", dlg.DatabaseLocation);
         Program.positionsTable.SetDatabaseLocation(dlg.DatabaseLocation);
         if (dlg.CreateNew || !File.Exists(dlg.DatabaseLocation))
         {
             Program.positionsTable.CreateDatabase();
         }
     }
 }