Exemple #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            if (General.Default.SaveQueueOnExit)
            {
                if (File.Exists(Program.ApplicationFilesLocation + "\\threads.dat"))
                {
                    string[] ThreadArray = ProgramSettings.LoadThreadsAsString().Split('\n');
                    if (ThreadArray != null && ThreadArray.Length > 0)
                    {
                        for (int ThreadArrayIndex = 0; ThreadArrayIndex < ThreadArray.Length; ThreadArrayIndex++)
                        {
                            // assume the thread is alive unless it's confirmed false in the threads.dat file
                            SavedThreadInfo newInfo       = new SavedThreadInfo();
                            string          ThreadAtIndex = ThreadArray[ThreadArrayIndex];
                            newInfo.ThreadURL = ThreadAtIndex.Split('=')[0].Trim(' ');

                            // if the thread.dat contains an equal sign, try to parse it.
                            if (ThreadAtIndex.Contains("="))
                            {
                                string IsAliveString = ThreadAtIndex.Split('=')[1].ToLower().Trim(' ');
                                switch (IsAliveString.ToLower())
                                {
                                case "101":
                                    newInfo.Status = ThreadStatus.ThreadIs404;
                                    break;

                                case "102":
                                    newInfo.Status = ThreadStatus.ThreadIsAborted;
                                    break;

                                default:
                                    newInfo.Status = ThreadStatus.ThreadIsAlive;
                                    break;
                                }
                            }
                            else
                            {
                                newInfo.Status = ThreadStatus.ThreadIsAlive;
                            }

                            newInfo.ThreadName = null;

                            AddNewThread(newInfo);
                        }
                    }

                    File.Delete(Program.ApplicationFilesLocation + "\\threads.dat");
                }

                if (File.Exists(Program.ApplicationFilesLocation + "\\threads.xml"))
                {
                    List <SavedThreadInfo> Threads = ProgramSettings.LoadThreads();
                    for (int i = 0; i < Threads.Count; i++)
                    {
                        AddNewThread(Threads[i]);
                    }
                }
            }
            if (General.Default.ShowTrayIcon)
            {
                niTray.Visible = true;
            }
            niTray.ContextMenu = cmTray;

            if (Saved.Default.MainFormLocation != default(System.Drawing.Point))
            {
                this.Location = Saved.Default.MainFormLocation;
            }
            if (Saved.Default.MainFormSize != default(System.Drawing.Size))
            {
                this.Size = Saved.Default.MainFormSize;
            }
            if (!string.IsNullOrEmpty(Saved.Default.MainFormColumnSizes))
            {
                List <int> Sizes = ProgramSettings.GetColumnSizes(Saved.Default.MainFormColumnSizes.Split('|'));
                clIcon.Width   = Sizes[0];
                clStatus.Width = Sizes[1];
                clThread.Width = Sizes[2];
                clName.Width   = Sizes[3];
            }

            chkCreateThreadInTheBackground.Checked = Saved.Default.SaveThreadInTheBackground;

            UpdateChecker.CheckForUpdate();
        }
Exemple #2
0
        /// <summary>
        /// Adds a new thread to the queue via saved threads.
        /// </summary>
        /// <param name="Info"></param>
        /// <returns></returns>
        public bool AddNewThread(SavedThreadInfo Info)
        {
            if (Chans.SupportedChan(Info.ThreadURL) && !ThreadURLs.Contains(Info.ThreadURL))
            {
                frmDownloader newThread = new frmDownloader();
                ThreadInfo    NewInfo   = new ThreadInfo();
                NewInfo.Chan = Chans.GetChanType(Info.ThreadURL);
                switch (NewInfo.Chan)
                {
                case ChanType.None:
                    newThread.Dispose();
                    return(false);
                }
                newThread.Name              = Info.ThreadURL;
                NewInfo.ThreadURL           = Info.ThreadURL;
                NewInfo.RetrievedThreadName = Info.RetrievedThreadName;
                NewInfo.ThreadName          = Info.ThreadName;
                NewInfo.SetCustomName       = Info.SetCustomName;
                NewInfo.CustomName          = Info.CustomName;
                newThread.CurrentThread     = NewInfo;
                newThread.ManageThread(ThreadEvent.ParseForInfo);
                newThread.Show();
                newThread.Hide();

                ListViewItem lvi = new ListViewItem();
                lvi.Name = Info.ThreadURL;
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem());

                lvi.ImageIndex = (int)NewInfo.Chan;
                lvi.SubItems[clStatus.Index].Text = "Creating";
                lvi.SubItems[clThread.Index].Text = "/" + NewInfo.ThreadBoard + "/ - " + NewInfo.ThreadID;

                lvThreads.Items.Add(lvi);

                newThread.Opacity       = 100;
                newThread.ShowInTaskbar = true;

                ThreadURLs.Add(Info.ThreadURL);
                NewInfo.OverallStatus = ThreadStatus.ThreadIsAlive;
                Threads.Add(newThread);
                if (Info.SetCustomName)
                {
                    lvi.SubItems[clName.Index].Text       = Info.CustomName;
                    newThread.CurrentThread.SetCustomName = true;
                }
                else
                {
                    if (Info.RetrievedThreadName)
                    {
                        lvi.SubItems[clName.Index].Text = Info.ThreadName;
                    }
                    else
                    {
                        lvi.SubItems[clName.Index].Text = Info.ThreadURL;
                    }
                }
                newThread.ManageThread(ThreadEvent.StartDownload);
                return(true);
            }

            return(false);
        }