示例#1
0
        protected override IntelligentString GetDescription(IntelligentString seperator)
        {
            IntelligentString description = IntelligentString.Empty;

            if (!IntelligentString.IsNullOrEmpty(Genre))
            {
                description += Genre.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Program))
            {
                description += Program.Trim() + seperator;
            }

            if (Series != 0)
            {
                description += "Series " + Series.ToString() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(EpisodeOfString))
            {
                description += "Episode " + EpisodeOfString + seperator;
            }

            if (description.EndsWith(seperator))
            {
                description = description.Substring(0, description.Length - seperator.Length);
            }

            return(description.Trim());
        }
示例#2
0
        public object Apply(Type propertyType, object value)
        {
            IntelligentString originalValue = value.ToString();

            switch (Position)
            {
            case TrimRulePositionEnum.Start:
                return(originalValue.Substring(CharactersToTrim));

            case TrimRulePositionEnum.End:
                return(originalValue.Substring(0, originalValue.Length - CharactersToTrim));

            default:
                throw new UnknownEnumValueException(Position);
            }
        }
        /// <summary>
        /// Adds the extension entered by the user to the file type
        /// </summary>
        private void AddExtension()
        {
            try
            {
                if (String.IsNullOrEmpty(txtExtension.Text))
                {
                    GeneralMethods.MessageBoxApplicationError("Please enter a value for the extension");
                    return;
                }

                IntelligentString extension = txtExtension.Text;

                if (!extension.StartsWith("."))
                {
                    extension = "." + extension;
                }

                if (extension.Substring(1).Contains("."))
                {
                    GeneralMethods.MessageBoxApplicationError("Extension contains multiple full stops");
                    return;
                }

                if (SelectedFileType.Extensions.Contains(extension))
                {
                    GeneralMethods.MessageBoxApplicationError("File type already contains extension \"" + extension + "\"");
                    return;
                }

                SelectedFileType.Extensions.Add(extension);
                SelectedFileType.Extensions.Sort();

                txtExtension.Text = String.Empty;
                txtExtension.Focus();
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not add extension: ");
            }
        }
        /// <summary>
        /// Converts a filename to a NonLibraryFile object
        /// </summary>
        /// <param name="rootFolder">Root folder the non-library file was found in</param>
        /// <param name="filename">Full filename of the non-library file</param>
        /// <returns>NonLibraryFile object derived from the specified file name</returns>
        public static NonLibraryFile FromFilename(RootFolder rootFolder, IntelligentString filename)
        {
            IntelligentString rootFolderPath = AppendTrailingSlash(rootFolder.Path);

            filename = filename.Substring(rootFolderPath.Length);

            IntelligentString[] subFolders = filename.Split("\\");
            IntelligentString   subFolder  = IntelligentString.Empty;

            for (int i = 0; i < subFolders.Length; i++)
            {
                if (i == (subFolders.Length - 1))
                {
                    filename = subFolders[i];
                }
                else
                {
                    subFolder += subFolders[i] + "\\";
                }
            }

            return(new NonLibraryFile(rootFolder, subFolder, filename));
        }
示例#5
0
        protected override IntelligentString GetDescription(IntelligentString seperator)
        {
            IntelligentString description = IntelligentString.Empty;

            if (!IntelligentString.IsNullOrEmpty(Genre))
            {
                description += Genre.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Artist))
            {
                description += Artist.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(Album))
            {
                description += Album.Trim() + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(DiskNumberOfString))
            {
                description += "Disk " + DiskNumberOfString + seperator;
            }

            if (!IntelligentString.IsNullOrEmpty(TrackNumberOfString))
            {
                description += "Track " + TrackNumberOfString + seperator;
            }

            if (description.EndsWith(seperator))
            {
                description = description.Substring(0, description.Length - seperator.Length);
            }

            return(description.Trim());
        }