Example #1
0
        /// <summary>
        /// Initialises a new instance of the RootFolderDialog class
        /// </summary>
        /// <param name="tags">Tags available to the root folder</param>
        /// <param name="type">Type of media item the new root folder will be associated with</param>
        public RootFolderDialog(IntelligentString[] tags, MediaItemTypeEnum type)
            : this(tags)
        {
            SelectedRootFolder = new RootFolder(type);

            Title = "New Root Folder";
        }
        /// <summary>
        /// Creates a new MediaItem object using the data in a data row
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="row">DataRow containing the data for the media item</param>
        /// <returns>MediaItem object with properties loaded from the database</returns>
        internal static MediaItem FromDataRow(SqlConnection conn, sp.DataRow row)
        {
            MediaItemTypeEnum type = (MediaItemTypeEnum)Convert.ToInt16(row["Type"]);
            MediaItem         mediaItem;

            switch (type)
            {
            case MediaItemTypeEnum.Video:
                mediaItem = Video.FromDataRow(row);
                break;

            case MediaItemTypeEnum.Song:
                mediaItem = Song.FromDataRow(row);
                break;

            default:
                throw new UnknownEnumValueException(type);
            }

            mediaItem.id           = (Int64)row["Id"];
            mediaItem.Genre        = (String)row["Genre"];
            mediaItem.name         = (String)row["Name"];
            mediaItem.isHidden     = (Boolean)row["IsHidden"];
            mediaItem.dateCreated  = (DateTime)row["DateCreated"];
            mediaItem.dateModified = (DateTime)row["DateModified"];
            mediaItem.UserName     = (String)row["UserName"];

            mediaItem.playHistory = Data.MediaItem.GetMediaItemPlayHistoryById(conn, mediaItem.id, mediaItem.Type);
            mediaItem.parts       = MediaItemPart.GetMediaItemPartsById(conn, mediaItem.Id, mediaItem.Type);
            mediaItem.tags        = new ObservableCollection <IntelligentString>(Data.MediaItem.GetMediaItemTagsById(conn, mediaItem.id, mediaItem.Type));

            mediaItem.IsInDatabase = true;

            return(mediaItem);
        }
        /// <summary>
        /// Initialises a new instance of the FileTypeDialog class
        /// </summary>
        /// <param name="type">Type of media item the new file type will be associated with</param>
        public FileTypeDialog(MediaItemTypeEnum type)
        {
            InitializeComponent();

            SelectedFileType = new FileType();
            SelectedFileType.MediaItemType = type;

            Title = "New File Type";
        }
 /// <summary>
 /// Gets all root folders in the system that are associated with the specified type
 /// </summary>
 /// <param name="mediaItemType">Type associated with the desired root folders</param>
 /// <returns>All root folders in the system that are associated with the specified type</returns>
 public static RootFolder[] GetRootFoldersByType(MediaItemTypeEnum mediaItemType)
 {
     using (SqlConnection conn = GetConnection())
     {
         try
         {
             conn.Open();
             return(Data.RootFolder.GetRootFoldersByType(conn, mediaItemType));
         }
         finally
         {
             conn.Close();
         }
     }
 }
 /// <summary>
 /// Determines whether a root folder already exists with specified type and path
 /// </summary>
 /// <param name="mediaItemType">Type associated with the desired root folders</param>
 /// <param name="path">Path to the desired root folder</param>
 /// <returns>True if a root folder already exists with specified type and path, false if not</returns>
 public static Boolean RootFolderPathExists(MediaItemTypeEnum mediaItemType, IntelligentString path)
 {
     using (SqlConnection conn = GetConnection())
     {
         try
         {
             conn.Open();
             return(Data.RootFolder.RootFolderPathExists(conn, mediaItemType, path.Value));
         }
         finally
         {
             conn.Close();
         }
     }
 }
        /// <summary>
        /// Initialises a new instance of the RootFolder class
        /// </summary>
        /// <param name="mediaItemType">Type of media item the root folder is associated with</param>
        /// <param name="priority">Priority of the root folder</param>
        public RootFolder(MediaItemTypeEnum mediaItemType, Int16 priority)
            : this(mediaItemType)
        {
            using (SqlConnection conn = GetConnection())
            {
                try
                {
                    conn.Open();

                    RootFolder clone = Data.RootFolder.GetRootFolderByPriority(conn, mediaItemType, priority);

                    MediaItemType = clone.MediaItemType;
                    Priority      = clone.Priority;
                    Path          = clone.Path;
                    Tags          = clone.Tags;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Example #7
0
        /// <summary>
        /// Gets the file type the extension is to be added to
        /// </summary>
        /// <param name="fileTypes">Current set of file types</param>
        /// <param name="extension">Extensino to check</param>
        /// <param name="associatedType">Type the extension should be associated with</param>
        /// <returns>File type the extension is to be added to</returns>
        public static FileType GetFileTypeForExtension(FileType[] fileTypes, String extension, MediaItemTypeEnum associatedType)
        {
            if (GeneralMethods.MessageBox("There is currently no file type associated with " + associatedType.ToString().ToLower() + "s containing the extension \"" + extension + "\". Would you like to add one?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                GetTextValueDialog gtvd = new GetTextValueDialog(TextValueDialogInputType.ComboBox);
                gtvd.Style             = (Style)App.Current.FindResource("dialogWindow");
                gtvd.Owner             = Application.Current.MainWindow;
                gtvd.Title             = "File Type";
                gtvd.Header            = "Enter the name for the file type:";
                gtvd.ItemsSource       = fileTypes;
                gtvd.DisplayMemberPath = "Name";
                gtvd.Width             = 500;

                FileType fileType = null;

                if (GeneralMethods.GetNullableBoolValue(gtvd.ShowDialog()))
                {
                    if (fileTypes.Any(p => p.Name.ToLower() == gtvd.Value.ToLower()))
                    {
                        fileType = fileTypes.First(p => p.Name.ToLower() == gtvd.Value.ToLower());
                    }
                    else
                    {
                        fileType               = new FileType();
                        fileType.Name          = gtvd.Value;
                        fileType.MediaItemType = associatedType;
                    }

                    fileType.Extensions.Add(extension);
                }

                return(fileType);
            }

            return(null);
        }
 /// <summary>
 /// Initialises a new instance of the RootFolder class
 /// </summary>
 /// <param name="mediaItemType">Type of media item the root folder is associated with</param>
 public RootFolder(MediaItemTypeEnum mediaItemType)
     : this()
 {
     MediaItemType = mediaItemType;
 }