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
            }
        }
Example #2
0
        private void ScanThread()
        {
            lock (threadLock)
            {
                //Removes 404'd threads
                foreach (Imageboard imB in ListThreads.ToArray())
                {
                    if (imB.isGone())
                    {
                        ListThreads.Remove(imB);
                        updateDataSource(typeURL.thread);

                        if (Properties.Settings.Default.saveOnClose)
                        {
                            General.WriteURLs(ListBoards, ListThreads);
                        }
                    }
                }
            }

            lock (boardLock)
            {
                //Searches for new threads on the watched boards
                foreach (Imageboard imB in ListBoards)
                {
                    string[] Threads = { };
                    try
                    {
                        Threads = imB.getThreads();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        foreach (string thread in Threads)
                        {
                            Imageboard newImageboard = General.CreateNewImageboard(thread);
                            if (newImageboard != null && isUnique(newImageboard.getURL(), ListThreads))
                            {
                                AddURLToList(newImageboard);
                            }
                        }
                    }
                }
            }

            lock (threadLock)
            {
                //Download threads
                foreach (Imageboard imB in ListThreads)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(imB.download));
                }
            }
        }
Example #3
0
        private void AddUrl(string url)
        {
            if (string.IsNullOrWhiteSpace(url) && Clipboard.ContainsText())
            {
                url = Clipboard.GetText();
            }

            Imageboard newImageboard = General.CreateNewImageboard(url);

            if (newImageboard != null)
            {
                if (isUnique(newImageboard.getURL(), newImageboard.isBoard() ? ListBoards : ListThreads))
                {
                    AddURLToList(newImageboard);

                    if (!scnTimer.Enabled)
                    {
                        scnTimer.Enabled = true;
                    }
                    if (Properties.Settings.Default.saveOnClose)
                    {
                        General.WriteURLs(ListBoards, ListThreads);
                    }

                    scan(this, new EventArgs());
                }
                else
                {
                    DialogResult result = MessageBox.Show("URL is already in queue!\nOpen corresponding folder?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.Yes)
                    {
                        string spath = newImageboard.getPath();
                        if (!Directory.Exists(spath))
                        {
                            Directory.CreateDirectory(spath);
                        }
                        Process.Start(spath);
                    }
                }
            }
            else
            {
                MessageBox.Show("Corrupt URL, unsupported website or not a board/thread!");
                edtURL.Text = "";
            }
        }