Example #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            if (!Properties.Settings.Default.minimizeToTray)                            // if trayicon deactivated
            {
                nfTray.Visible = false;                                                 // hide it
            }
            scnTimer.Enabled  = false;                                                  // disable timer
            scnTimer.Interval = Properties.Settings.Default.timer;                      // set interval
            scnTimer.Tick    += new EventHandler(this.scan);                            // when Timer ticks call scan()
            ThreadPool.SetMaxThreads(Environment.ProcessorCount, Environment.ProcessorCount);

            if (Properties.Settings.Default.firstStart)
            {
                FirstStart tFirstStart = new FirstStart();                              // if first start, show first start message
                tFirstStart.ShowDialog();
                Properties.Settings.Default.firstStart = false;
                Properties.Settings.Default.Save();
            }

            if (Properties.Settings.Default.saveOnClose)                                // if enabled load URLs from file
            {
                string boards  = General.LoadURLs(true);
                string threads = General.LoadURLs(false);                               // load threads

                if (!String.IsNullOrWhiteSpace(boards))
                {
                    lock (boardLock)
                    {
                        string[] URLs = boards.Split('\n');
                        for (int i = 0; i < URLs.Length - 1; i++)
                        {
                            Imageboard newImageboard = General.CreateNewImageboard(URLs[i]); // and add them
                            AddURLToList(newImageboard);
                        }
                    }
                }

                if (!String.IsNullOrWhiteSpace(threads))
                {
                    lock (threadLock)
                    {
                        string[] URLs = threads.Split('\n');
                        for (int i = 0; i < URLs.Length - 1; i++)
                        {
                            Imageboard newImageboard = General.CreateNewImageboard(URLs[i]);
                            AddURLToList(newImageboard);
                        }
                    }
                }

                lbBoards.DataSource  = ListBoards;
                lbThreads.DataSource = ListThreads;

                AddUrlFromArgs(startupArgs);                                    // Load urls sent via arguments

                scnTimer.Enabled = true;                                        // activate the timer
                scan(this, new EventArgs());                                    // and start scanning
            }
        }