예제 #1
0
        private void OKButton_Click(object sender, System.EventArgs e)
        {
            if (!TVSettings.OKExtensionsString(this.txtVideoExtensions.Text))
            {
                MessageBox.Show("Extensions list must be separated by semicolons, and each extension must start with a dot.", "Preferences", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedIndex = 1;
                this.txtVideoExtensions.Focus();
                return;
            }
            if (!TVSettings.OKExtensionsString(this.txtOtherExtensions.Text))
            {
                MessageBox.Show("Extensions list must be separated by semicolons, and each extension must start with a dot.", "Preferences", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedIndex = 1;
                this.txtOtherExtensions.Focus();
                return;
            }
            TVSettings S = this.mDoc.Settings;

            S.Replacements.Clear();
            for (int i = 1; i < this.ReplacementsGrid.RowsCount; i++)
            {
                string from = (string)(this.ReplacementsGrid[i, 0].Value);
                string to   = (string)(this.ReplacementsGrid[i, 1].Value);
                bool   ins  = (bool)(this.ReplacementsGrid[i, 2].Value);
                if (!string.IsNullOrEmpty(from))
                {
                    S.Replacements.Add(new Replacement(from, to, ins));
                }
            }

            S.ExportWTWRSS        = this.cbWTWRSS.Checked;
            S.ExportWTWRSSTo      = this.txtWTWRSS.Text;
            S.ExportWTWXML        = this.cbWTWXML.Checked;
            S.ExportWTWXMLTo      = this.txtWTWXML.Text;
            S.ExportMissingXML    = this.cbMissingXML.Checked;
            S.ExportMissingXMLTo  = this.txtMissingXML.Text;
            S.ExportMissingCSV    = this.cbMissingCSV.Checked;
            S.ExportMissingCSVTo  = this.txtMissingCSV.Text;
            S.ExportRenamingXML   = this.cbRenamingXML.Checked;
            S.ExportRenamingXMLTo = this.txtRenamingXML.Text;
            S.ExportFOXML         = this.cbFOXML.Checked;
            S.ExportFOXMLTo       = this.txtFOXML.Text;

            S.WTWRecentDays           = Convert.ToInt32(this.txtWTWDays.Text);
            S.StartupTab              = this.cbStartupTab.SelectedIndex;
            S.NotificationAreaIcon    = this.cbNotificationIcon.Checked;
            S.VideoExtensionsString   = this.txtVideoExtensions.Text;
            S.OtherExtensionsString   = this.txtOtherExtensions.Text;
            S.ExportRSSMaxDays        = Convert.ToInt32(this.txtExportRSSMaxDays.Text);
            S.ExportRSSMaxShows       = Convert.ToInt32(this.txtExportRSSMaxShows.Text);
            S.ExportRSSDaysPast       = Convert.ToInt32(this.txtExportRSSDaysPast.Text);
            S.KeepTogether            = this.cbKeepTogether.Checked;
            S.LeadingZeroOnSeason     = this.cbLeadingZero.Checked;
            S.ShowInTaskbar           = this.chkShowInTaskbar.Checked;
            S.RenameTxtToSub          = this.cbTxtToSub.Checked;
            S.ShowEpisodePictures     = this.cbShowEpisodePictures.Checked;
            S.AutoSelectShowInMyShows = this.cbAutoSelInMyShows.Checked;
            S.SpecialsFolderName      = this.txtSpecialsFolderName.Text;

            S.ForceLowercaseFilenames = this.cbForceLower.Checked;
            S.IgnoreSamples           = this.cbIgnoreSamples.Checked;

            S.uTorrentPath  = this.txtRSSuTorrentPath.Text;
            S.ResumeDatPath = this.txtUTResumeDatPath.Text;
            S.SABHostPort   = this.txtSABHostPort.Text;
            S.SABAPIKey     = this.txtSABAPIKey.Text;
            S.CheckSABnzbd  = this.cbCheckSABnzbd.Checked;

            S.SearchRSS             = this.cbSearchRSS.Checked;
            S.EpImgs                = this.cbEpImgs.Checked;
            S.NFOs                  = this.cbNFOs.Checked;
            S.pyTivoMeta            = this.cbMeta.Checked;
            S.pyTivoMetaSubFolder   = this.cbMetaSubfolder.Checked;
            S.FolderJpg             = this.cbFolderJpg.Checked;
            S.RenameCheck           = this.cbRenameCheck.Checked;
            S.MissingCheck          = this.cbMissing.Checked;
            S.SearchLocally         = this.cbSearchLocally.Checked;
            S.LeaveOriginals        = this.cbLeaveOriginals.Checked;
            S.CheckuTorrent         = this.cbCheckuTorrent.Checked;
            S.LookForDateInFilename = this.cbLookForAirdate.Checked;
            S.MonitorFolders        = this.cbMonitorFolder.Checked;

            if (this.rbFolderFanArt.Checked)
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.FanArt;
            }
            else if (this.rbFolderBanner.Checked)
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.Banner;
            }
            else
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.Poster;
            }


            TheTVDB db = this.mDoc.GetTVDB(true, "Preferences-OK");

            foreach (var kvp in db.LanguageList)
            {
                if (kvp.Value == cbLanguages.Text)
                {
                    S.PreferredLanguage = kvp.Key;
                    break;
                }
            }
            if (rbWTWScan.Checked)
            {
                S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Scan;
            }
            else
            {
                S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Search;
            }

            db.SaveCache();
            db.Unlock("Preferences-OK");

            try
            {
                S.SampleFileMaxSizeMB = int.Parse(this.txtMaxSampleSize.Text);
            }
            catch
            {
                S.SampleFileMaxSizeMB = 50;
            }

            try
            {
                S.ParallelDownloads = int.Parse(this.txtParallelDownloads.Text);
            }
            catch
            {
                S.ParallelDownloads = 4;
            }

            if (S.ParallelDownloads < 1)
            {
                S.ParallelDownloads = 1;
            }
            else if (S.ParallelDownloads > 8)
            {
                S.ParallelDownloads = 8;
            }

            // RSS URLs
            S.RSSURLs.Clear();
            for (int i = 1; i < this.RSSGrid.RowsCount; i++)
            {
                string url = (string)(this.RSSGrid[i, 0].Value);
                if (!string.IsNullOrEmpty(url))
                {
                    S.RSSURLs.Add(url);
                }
            }

            S.ShowStatusColors = new ShowStatusColoringTypeList();
            foreach (ListViewItem item in lvwDefinedColors.Items)
            {
                if (item.SubItems.Count > 1 && !string.IsNullOrEmpty(item.SubItems[1].Text) && item.Tag != null && item.Tag is ShowStatusColoringType)
                {
                    S.ShowStatusColors.Add(item.Tag as ShowStatusColoringType, System.Drawing.ColorTranslator.FromHtml(item.SubItems[1].Text));
                }
            }

            this.mDoc.SetDirty();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }