Пример #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.FillRectangle(backgroundBrush, this.ClientRectangle);

            if (temporaryMessage.Length > 0)
            {
                TextRenderer.DrawText(e.Graphics, temporaryMessage, Styles.FontLarge, this.ClientRectangle, Styles.LightText, tff);
            }
            else if (currentTrack != null)
            {
                TextRenderer.DrawText(e.Graphics, currentTrack.ToString(), Styles.FontLarge, this.ClientRectangle, Styles.VeryLight, tff);
            }

            e.Graphics.DrawLine(Pens.Black, 0, this.ClientRectangle.Height - 1, this.ClientRectangle.Width, this.ClientRectangle.Height - 1);
        }
Пример #2
0
        public static void AddTracksToList(DirectoryInfo DI, List <Track> Tracks, MessageDelegate ShowMessage)
        {
            string adding = Localization.Get(UI_Key.Lib_Adding) + " ";

            foreach (FileInfo fi in DI.GetFiles())
            {
                Track t = Track.Load(fi.FullName);
                if (t != null)
                {
                    Tracks.Add(t);
                    ShowMessage(adding + Tracks.Count.ToString() + ": " + t.ToString());
                    Lib.DoEvents();
                }
            }
            foreach (DirectoryInfo di in DI.GetDirectories())
            {
                AddTracksToList(di, Tracks, ShowMessage);
            }
        }
Пример #3
0
 public void TempDisplayTrackInfo(Track t)
 {
     if (t != null)
     {
         if (Setting.ShowAlbumArtOnMainScreen)
         {
             if (controller.Playing)
             {
                 artwork.TemporaryTrack = t;
             }
             else
             {
                 artwork.CurrentTrack = t;
             }
         }
         updateFilterHint(t);
         Controller.ShowMessage(t.ToString());
     }
 }
Пример #4
0
        private static void addItems()
        {
            try
            {
                running = true;
                cancel  = false;
                int itemsLeft;
                lock (addItemLock)
                {
                    itemsLeft = itemsToAdd.Count;
                }

                while (!cancel && itemsLeft > 0)
                {
                    ItemToAdd ita;
                    lock (addItemLock)
                    {
                        ita = itemsToAdd[0];
                        itemsToAdd.RemoveAt(0);
                    }
                    if (Directory.Exists(ita.FilePath))
                    {
                        List <ItemToAdd> newItems = new List <ItemToAdd>();
                        DirectoryInfo    di       = new DirectoryInfo(ita.FilePath);
                        foreach (FileInfo fi in di.GetFiles())
                        {
                            newItems.Add(new ItemToAdd(fi.FullName, ita.PlaylistTarget, ita.AllowDuplicates));
                        }
                        foreach (DirectoryInfo ddi in di.GetDirectories())
                        {
                            newItems.Add(new ItemToAdd(ddi.FullName, ita.PlaylistTarget, ita.AllowDuplicates));
                        }

                        lock (addItemLock)
                        {
                            itemsToAdd = itemsToAdd.Union(newItems).ToList();
                        }
                    }
                    else
                    {
                        if (Track.IsValidExtension(Path.GetExtension(ita.FilePath)))
                        {
                            Track tt = Track.Load(ita.FilePath);
                            if (tt != null)
                            {
                                Database.AddLibraryResult alr = Database.AddToLibrary(tt, ita.AllowDuplicates, true);

                                TrackWriter.AddToUnsavedTracks(tt);

                                if (ita.PlaylistTarget.Length > 0)
                                {
                                    Database.AddToPlaylist(ita.PlaylistTarget, tt);
                                }

                                switch (alr)
                                {
                                case Database.AddLibraryResult.OK:
                                    Controller.ShowMessage("Loading: " + (++addCount).ToString() + " - " + tt.ToString());
                                    break;

                                case Database.AddLibraryResult.UpdateOnly:
                                    Controller.ShowMessage("Updating: " + (++addCount).ToString() + " - " + tt.ToString());
                                    break;
                                }
                                if (((addCount < 200) && ((addCount % 10) == 0)) || (addCount % 200 == 0))
                                {
                                    tryCallback();
                                }
                            }
                        }
                    }

                    lock (addItemLock)
                    {
                        itemsLeft = itemsToAdd.Count;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            running = false;
            lock (addItemLock)
            {
                if (cancel)
                {
                    itemsToAdd.Clear();
                }
            }
            tryCallback();
            TrackWriter.Start();
        }