|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTunesLib;
namespace ItnuesPlayListManager
{
public class FolderElement
{
/// <summary>
/// Creates a new folder object with specifed itnues folder in specifed parent folder.
/// </summary>
/// <param name="parent">Parent folder which the folder need to be created.</param>
/// <param name="itnuesfolder">Itnues folder object</param>
public FolderElement(FolderElement parent,IITUserPlaylist itnuesfolder)
{
CreateNew(parent, itnuesfolder);
}
/// <summary>
/// Creates a new folder object with specifed foldername in specifed parent folder.
/// </summary>
/// <param name="parent">Parent folder which the folder need to be created.</param>
/// <param name="newfoldername">Name of new folder</param>
public FolderElement(FolderElement parent,string newfoldername)
{
IITUserPlaylist itnuesFolderSource = (IITUserPlaylist)parent.ItnuesFolderSource.CreateFolder(newfoldername);
CreateNew(parent, itnuesFolderSource);
}
private bool CreateNew(FolderElement parent,IITUserPlaylist itnuesfolder)
{
ItnuesFolderSource = itnuesfolder;
this.Parent = parent;
SubFolders = new SortedDictionary<string, FolderElement>();
PlayLists = new SortedDictionary<string, PlayListElement>();
return true;
}
/// <summary>
/// Returns the parent of the current Itunes folder source.
/// </summary>
public FolderElement Parent
{
get;
private set;
}
/// <summary>
/// Gets Itnues backreference object
/// </summary>
public IITUserPlaylist ItnuesFolderSource
{
get;
private set;
}
/// <summary>
/// Gets a collection of subfolder in this folder
/// </summary>
public SortedDictionary<string, FolderElement> SubFolders
{
get;
private set;
}
/// <summary>
/// Gets a collection of playlists in this folder
/// </summary>
public SortedDictionary<string, PlayListElement> PlayLists
{
get;
private set;
}
/// <summary>
/// Moves a specific folder to another location.
/// </summary>
/// <param name="destination">destination folder to which the folder need to be moved.</param>
/// <returns>Returns status</returns>
public bool MoveFolder(FolderElement destination)
{
if(destination.SubFolders.ContainsKey(this.ItnuesFolderSource.Name))
return false;
Parent = destination;
Parent.SubFolders.Remove(this.ItnuesFolderSource.Name);
destination.SubFolders.Add(this.ItnuesFolderSource.Name, this);
object val = destination.ItnuesFolderSource;
this.ItnuesFolderSource.set_Parent(ref val);
return true;
}
/// <summary>
/// Deletes the specifed subfolder and its all subfolders and playlists in the current folder
/// </summary>
/// <param name="folder">folder object to delete</param>
/// <returns>Returns status</returns>
public bool DeleteSubFolder(FolderElement folder)
{
if (!this.SubFolders.ContainsKey(folder.ItnuesFolderSource.Name))
return false;
this.SubFolders.Remove(folder.ItnuesFolderSource.Name);
folder.ItnuesFolderSource.Delete();
return true;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Started Programming career with VB 6 and VC++ and now Into .Net Development. Working with .Net since its first release (Version 1.0 Beta). Lucky enough to continue always with most updated versions of .Net and as of now; May 2007, fighting with .Net 3.0 (WPF,WCF...etc) and it's next most anticipated version LINQ.
Got familiarity up on the .Net Technologies and Guidelines like CAB, and Patterns and Practices, Enterprise Library and now with it's WPF version etc.
Specialized in Windows and Distributed and Service oriented applications.