Esempio n. 1
0
        void HandleButtonOkClicked(object sender, EventArgs e)
        {
            // check resolutions
            System.Text.RegularExpressions.Regex rgxDimensions = new System.Text.RegularExpressions.Regex(@"^[\d]+x[\d]+$");
            if (!rgxDimensions.IsMatch(txtFanArtResolution.Text))
            {
                MessageBox.Show("Invalid Fan Art Resolution");
                return;
            }
            if (!rgxDimensions.IsMatch(txtPosterResolution.Text))
            {
                MessageBox.Show("Invalid Poster Resolution");
                return;
            }
            if (!rgxDimensions.IsMatch(txtBannerResolution.Text))
            {
                MessageBox.Show("Invalid Banner Resolution");
                return;
            }
            iMetaLibrary.Settings.FanArtWidth            = int.Parse(txtFanArtResolution.Text.Split('x') [0]);
            iMetaLibrary.Settings.FanArtHeight           = int.Parse(txtFanArtResolution.Text.Split('x') [1]);
            iMetaLibrary.Settings.PosterWidth            = int.Parse(txtPosterResolution.Text.Split('x') [0]);
            iMetaLibrary.Settings.PosterHeight           = int.Parse(txtPosterResolution.Text.Split('x') [1]);
            iMetaLibrary.Settings.BannerWidth            = int.Parse(txtBannerResolution.Text.Split('x') [0]);
            iMetaLibrary.Settings.BannerHeight           = int.Parse(txtBannerResolution.Text.Split('x') [1]);
            iMetaLibrary.Settings.ImageQuality           = int.Parse(txtImageQuality.Text);
            iMetaLibrary.Settings.UseBannersForTvFolders = chkUseBannersForFolderImage.Active;

            // save cache path
            iMetaLibrary.Settings.CachePath = fcbCachePath.Filename;

            // video file extensions
            var           enumerator = storeVideoExtensions.GetEnumerator();
            List <string> extensions = new List <string>();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current == null)
                {
                    continue;
                }
                string @value = enumerator.Current as string;
                if (@value == null && enumerator.Current is object[] && ((object[])enumerator.Current).Length > 0)
                {
                    @value = ((object[])enumerator.Current)[0] as string;
                }
                string extension = (@value ?? "").ToLower().Trim();
                if (extension.StartsWith("."))
                {
                    extension = extension.Substring(1);
                }
                if (!extensions.Contains(extension) && !String.IsNullOrWhiteSpace(extension))
                {
                    extensions.Add(extension);
                }
            }
            iMetaLibrary.Settings.VideoExtensions = extensions.ToArray();

            // movie settings
            iMetaLibrary.Settings.UseFolderNameForMovieLookup           = chkUseFolderNameForMovieLookup.Active;
            iMetaLibrary.Settings.AddYearToMovieFolders                 = chkAddYearToMovieFolders.Active;
            iMetaLibrary.Settings.AttemptTrailerDownloadMissingTrailers = chkAttemptToDownloadMissingTrailers.Active;
            iMetaLibrary.Settings.AttemptTrailerDownload                = chkAttempToDownloadTrailers.Active;
            iMetaLibrary.Settings.MaxFanArt    = (int)numMaxFanArt.Value;
            iMetaLibrary.Settings.MovieFolders = GetStoreDirectories(storeMovieFolders);

            // tv settings
            iMetaLibrary.Settings.AutoRenameEpisodes = chkAutoRenameEpisodes.Active;
            iMetaLibrary.Settings.TvFolders          = GetStoreDirectories(storeTvFolders);

            // advanced settings
            iMetaLibrary.Settings.TvRegularExpression   = txtTvRegex.Text;
            iMetaLibrary.Settings.TvEpisodeExpression   = txtTvEpisodeNumbersRegex.Text;
            iMetaLibrary.Settings.TvSeasonExpression    = txtTvSeasonRegex.Text;
            iMetaLibrary.Settings.TvShowTitleExpression = txtTvShowTitleRegex.Text;

            iMetaLibrary.Settings.SaveSettings();


            this.Destroy();
        }