Example #1
0
        private void AddUrl(string url)
        {
            Tracker newTracker = Utils.CreateNewTracker(url);

            if (newTracker != null)
            {
                List <Tracker> trackerList = ((newTracker.Type == Type.Board) ? BoardList.Cast <Tracker>() : ThreadListBindingSource.Cast <Tracker>()).ToList();
                if (IsUnique(newTracker.URL, trackerList))
                {
                    AddURLToList(newTracker);

                    if (!scanTimer.Enabled)
                    {
                        scanTimer.Enabled = true;
                    }
                    if (Properties.Settings.Default.saveOnClose)
                    {
                        Utils.SaveURLs(BoardList, ThreadListBindingSource.ToList());
                    }

                    Scan(this, new EventArgs());
                }
                else
                {
                    DialogResult result = MessageBox.Show(
                        "URL is already being tracked!\nOpen corresponding folder?",
                        "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.Yes)
                    {
                        string spath = newTracker.SaveTo;
                        if (!Directory.Exists(spath))
                        {
                            Directory.CreateDirectory(spath);
                        }
                        Process.Start(spath);
                    }
                }
            }
            else
            {
                MessageBox.Show("Corrupt URL, unsupported website or not a board/thread!");
                URLTextBox.Text = "";
            }
        }