Пример #1
0
        /// <summary>
        /// Initialize a new instance of this scanner.
        /// </summary>
        /// <param name="itunes"></param>
        public EmptyScanner(Controller controller, ICatalog catalog)
            : base(Resx.I_ScanEmptyDirectories, controller, catalog)
        {
            base.description = Resx.ScanEmpty;

            this.count = 0;
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="trackPIDs"></param>
        public ExportDialog(Controller controller, PersistentIDCollection trackPIDs)
            : this()
        {
            this.controller = controller;
            this.trackPIDs = trackPIDs;

            this.percentageCompleted = 0;

            this.Encoders = controller.Encoders;

            if (!String.IsNullOrEmpty(trackPIDs.Album))
            {
                detailBlock.Text = String.Format(
                    Resx.ExportingAlbum, trackPIDs.Count, trackPIDs.Album, trackPIDs.Artist);
            }
            else if (!String.IsNullOrEmpty(trackPIDs.Artist))
            {
                detailBlock.Text = String.Format(
                    Resx.ExportingArtist, trackPIDs.Count, trackPIDs.Artist);
            }
            else
            {
                detailBlock.Text = String.Format(
                    Resx.ExportingPlaylist, trackPIDs.Count, trackPIDs.Name);
            }
        }
Пример #3
0
        //========================================================================================
        // Constructor
        //========================================================================================
        /// <summary>
        /// Initialize a new instance of this scaner with the specified iTunes interface.
        /// </summary>
        /// <param name="itunes"></param>
        /// <param name="catalog"></param>
        public FileWatchScanner(Controller controller, ICatalog catalog, FileWatchAction action)
            : base(Resx.I_ScanFileWatch, controller, catalog)
        {
            base.description = Resx.ScanFileWatch;

            this.action = action;
        }
Пример #4
0
        private IPlaylistWriter writer; // playlist writer

        #endregion Fields

        #region Constructors

        //========================================================================================
        // Constructor
        //========================================================================================
        /// <summary>
        /// Initialize a new instance of this scanner.
        /// </summary>
        /// <param name="itunes">The iTunesAppClass to use.</param>
        /// <param name="exportPIDs">
        /// The list of persistent track IDs.  When exporting multiple playlists, this list
        /// should include all tracks from all playlists where each track indicates its own
        /// source playlist.  This allows comprehensive/overall feedback for UI progress bars.
        /// </param>
        /// <param name="encoder">The encoder to use to convert tracks.</param>
        /// <param name="playlistFormat">
        /// The playlist output format or PlaylistFactory.NoFormat for no playlist file.
        /// </param>
        /// <param name="location">
        /// The target root directory path to which all entries will be copied or converted.
        /// </param>
        /// <param name="pathFormat">
        /// The path format string as specified in FolderFormts.xml or null for title only.
        /// </param>
        /// <param name="isSynchronized">
        /// True if target location should be synchronized, removing entries in the target
        /// location that are not included in the exportPIDs collection.
        /// </param>
        public ExportScanner(
            Controller controller, PersistentIDCollection exportPIDs,
            Encoder encoder, string playlistFormat, string location, string pathFormat,
            bool isSynchronized)
        {
            base.name = Resx.I_ScanExport;
            base.description = isSynchronized ? Resx.ScanSynchronize : Resx.ScanExport;
            base.controller = controller;

            this.exportPIDs = exportPIDs;
            this.encoder = encoder;
            this.expectedType = encoder.ExpectedType;
            this.playlistFormat = playlistFormat;
            this.playlistName = exportPIDs.Name;
            this.location = location;
            this.createSubdirectories = (pathFormat != null);
            this.pathFormat = pathFormat ?? PathHelper.GetPathFormat(FlatPathFormat);
            this.isSynchronized = isSynchronized;

            this.exports = null;
            this.writer = null;

            this.slim = new ReaderWriterLockSlim();
            this.waitSyncRoot = null;
        }
Пример #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="catalog"></param>
 public ScannerBase(string name, Controller controller, ICatalog catalog)
 {
     this.name = name;
     this.controller = controller;
     this.catalog = catalog;
     this.progressPercentage = 0;
     this.completedAction = null;
 }
Пример #6
0
        //========================================================================================
        // Constructor
        //========================================================================================
        /// <summary>
        /// Initialize a new instance of this scaner with the specified iTunes interface.
        /// </summary>
        /// <param name="itunes"></param>
        /// <param name="catalog"></param>
        public MaintenanceScanner(
            Controller controller, ICatalog catalog, MaintenanceAction action)
            : base(Resx.I_ScanMaintenance, controller, catalog)
        {
            base.description = Resx.ScanMaintenance;

            this.action = action;
        }
Пример #7
0
        //========================================================================================
        // Constructor
        //========================================================================================
        /// <summary>
        /// Initialize a new instance of this scanner with the specified iTunes interface.
        /// </summary>
        /// <param name="itunes"></param>
        /// <param name="catalog"></param>
        public PhantomScanner(Controller controller, ICatalog catalog)
            : base(Resx.I_ScanPhantoms, controller, catalog)
        {
            base.description = Resx.ScanPhantoms;

            this.albumFilter = null;
            this.artistFilter = null;
            this.playlistFilter = PersistentID.Empty;
        }
Пример #8
0
        /// <summary>
        /// Initialize a new instance of the dialog using the given Controller.
        /// </summary>
        /// <param name="controller"></param>
        public SynchronizeDialog(Controller controller)
            : this()
        {
            this.controller = controller;

            this.manager = new UsbManager();
            this.disks = manager.GetAvailableDisks();
            this.playlists = null;
            this.percentageCompleted = 0;

            this.selector.Loaded += new RoutedEventHandler(DoLoaded);
        }
Пример #9
0
        static void Main(string[] args)
        {
            controller = new Controller();

            Thread thread = new Thread(new ThreadStart(delegate
            {
                while (controller.IsConnected)
                {
                    using (Track track = controller.CurrentTrack)
                    {
                        if (track != null)
                        {
                            Console.WriteLine(String.Format("CurrenTrack.Name = '{0}'", track.Name));
                        }
                    }

                    using (PlaylistCollection collection = controller.Playlists)
                    {
                        int sum = 0;
                        if (collection != null)
                        {
                            foreach (Playlist playlist in collection.Values)
                            {
                                if (playlist != null)
                                {
                                    sum += playlist.PlaylistID;
                                }
                            }
                        }

                        Console.WriteLine(String.Format("Playlist sum [{0}]", sum));
                    }

                    Thread.Sleep(1000);
                }
            }));

            thread.Start();

            Console.WriteLine("... Press Enter to quit");
            Console.ReadLine();

            controller.Dispose();

            thread.Abort();
            thread = null;

            controller = null;

            Console.WriteLine("... Done");
        }
Пример #10
0
        public static void MyClassCleanup()
        {
            Console.WriteLine("**** Unit test shutdown");

            if (itunes != null)
            {
                itunes = null;
            }

            if (controller != null)
            {
                controller.Dispose();
                controller = null;
            }
        }
Пример #11
0
        private BackgroundWorker worker; // the library background worker

        #endregion Fields

        #region Constructors

        //========================================================================================
        // Constructors
        //========================================================================================
        /// <summary>
        /// Private singleton constructor.
        /// </summary>
        private Librarian(Controller controller)
        {
            this.controller = controller;
            this.queue = new BlockingQueue<IScanner>();
            this.actives = new SafeCollection<IScanner>();
            this.cleansed = new StringCollection();
            this.disabled = new StringCollection();
            this.scanner = null;
            this.sync = new Object();

            // temporarily reference an empty catalog
            this.catalog = new TerseCatalog();

            this.worker = new BackgroundWorker();
            this.worker.DoWork += new DoWorkEventHandler(DoWork);
            this.worker.ProgressChanged += new ProgressChangedEventHandler(DoProgressChanged);
            this.worker.WorkerReportsProgress = true;
            this.worker.WorkerSupportsCancellation = true;
            this.worker.RunWorkerAsync();

            AddScanner(new InitializingScanner(controller, this));
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instances with the given iTunes controller.
        /// </summary>
        /// <param name="controller">The controller to monitor.</param>

        public TrackerWindow(iTunes.Controller controller)
            : this()
        {
            this.DataContext = controller;
        }
Пример #13
0
        /// <summary>
        /// Factory method returning the singleton instance.
        /// </summary>
        /// <returns></returns>
        public static Librarian Create(Controller controller)
        {
            if (librarian == null)
            {
                librarian = new Librarian(controller);
            }

            return librarian;
        }
Пример #14
0
        /// <summary>
        /// Ensures the queued workers are stopped and disposed.
        /// </summary>
        public void Dispose()
        {
            if (!isDisposed)
            {
                if (watcher != null)
                {
                    watcher.EnableRaisingEvents = false;
                    watcher.Dispose();
                    watcher = null;
                }

                if (queue != null)
                {
                    queue.Dispose();
                    queue = null;
                }

                if (worker != null)
                {
                    if (worker.IsBusy)
                    {
                        worker.CancelAsync();
                    }

                    worker.Dispose();
                    worker = null;
                }

                if (catalog != null)
                {
                    catalog.Dispose();
                    catalog = null;
                }

                if (actives != null)
                {
                    actives.Clear();
                    actives = null;
                }

                if (disabled != null)
                {
                    disabled.Clear();
                    disabled = null;
                }

                if (cleansed != null)
                {
                    cleansed.Clear();
                    cleansed = null;
                }

                controller = null;

                isDisposed = true;
            }
        }
Пример #15
0
 public void CreateLibrary()
 {
     Controller controller = new Controller();
     Librarian librarian = Librarian.Create(controller);
 }
Пример #16
0
        /// <summary>
        /// Release manages resources.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DoClosed(object sender, EventArgs e)
        {
            if (percentageCompleted > 0)
            {
                controller.Librarian.ProgressChanged -= new ProgressChangedEventHandler(DoProgressChanged);
            }

            // must detach collection from WPF control otherwise will not dispose
            selector.DataContext = null;
            disks.Clear();
            disks = null;

            playlistBox.ItemsSource = null;

            playlists.Dispose();
            playlists = null;

            manager.Dispose();
            manager = null;

            controller = null;
        }
Пример #17
0
        /// <summary>
        /// Grab a reference to the Controller.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DoDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            controller = e.NewValue as Controller;

            controller.Librarian.CollectionChanged +=
                new NotifyCollectionChangedEventHandler(DoTaskCollectionChanged);
        }
Пример #18
0
 public static void MyClassInitialize(TestContext testContext)
 {
     controller = new Controller();
     catalog = new FlatCatalog();
     catalog.Initialize(controller.LibraryXMLPath);
 }
Пример #19
0
 /// <summary>
 /// Initialize a new instance of this scanner.
 /// </summary>
 /// <param name="itunes"></param>
 public InitializingScanner(Controller controller, Librarian librarian)
     : base(Resx.I_ScanInitialize, controller, librarian.Catalog)
 {
     base.description = Resx.ScanInitialize;
     this.librarian = librarian;
 }
Пример #20
0
        /// <summary>
        /// Release managed resources
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DoClosed(object sender, EventArgs e)
        {
            if (percentageCompleted > 0)
            {
                controller.Librarian.ProgressChanged -= new ProgressChangedEventHandler(DoProgressChanged);
            }

            this.Closed -= new EventHandler(DoClosed);
            this.Closing -= new CancelEventHandler(DoClosing);

            if (percentageCompleted == 100)
            {
                string location = PathHelper.CleanDirectoryPath(locationBox.Text.Trim());

                if (!String.IsNullOrEmpty(location))
                {
                    Settings.Default.ExportPlaylistFormat = ((ComboBoxItem)playlistBox.SelectedItem).Tag as string;
                    Settings.Default.ExportSubdirectories = (bool)treeCheck.IsChecked;
                    Settings.Default.ExportLocation = location;
                    Settings.Default.Save();
                }
            }

            controller = null;
            trackPIDs = null;

            // clear the encoderBox UI control
            encoderBox.SelectedItem = null;

            foreach (ComboBoxItem item in encoderBox.Items)
            {
                item.Content = null;
            }

            encoderBox.Items.Clear();

            // dispose the encoders collection
            encoders.Dispose();
            encoders = null;
        }
Пример #21
0
 public static void MyClassInitialize(TestContext testContext)
 {
     itunes = new iTunesAppClass();
     controller = new Controller();
     libraryXMLPath = controller.LibraryXMLPath;
 }
Пример #22
0
        public void LibraryTracks()
        {
            Controller controller = new Controller();
            TrackCollection tracks = controller.LibraryPlaylist.Tracks;

            PersistentIDCollection pids = new PersistentIDCollection();
            //List<int> tids = new List<int>();

            watch.Start();

            foreach (Track track in tracks.Values)
            {
                if (track != null)
                {
                    pids.Add(track.PersistentID);
                    //tids.Add(track.trackID);
                    track.Dispose();
                }
            }

            watch.Stop();
            Console.WriteLine(String.Format("Found {0} tracks", pids.Count));
            Console.WriteLine(String.Format("Completed in {0} ms", watch.GetElapsedMilliseconds()));

            tracks.Dispose();
            tracks = null;

            controller.Dispose();
            controller = null;
        }
Пример #23
0
 public static Librarian Create(Controller controller)
 {
     return new Librarian();
 }