public void FillRoot(Volume volume, VolumeDatabase db) { if (volume == null) throw new ArgumentNullException("volume"); if (db == null) throw new ArgumentNullException("db"); this.database = db; TreeModel model; VolumeType volType = volume.GetVolumeType(); ResetView(); switch (volType) { case VolumeType.FileSystemVolume: InitView(volType, out model); // load volume root FileSystemVolume fsv = (FileSystemVolume)volume; DirectoryVolumeItem item = fsv.GetRoot(); AppendDirRows((TreeStore)model, TreeIter.Zero, item); Model = model; /*ColumnsAutosize();*/ break; case VolumeType.AudioCdVolume: InitView(volType, out model); // load volume root AudioCdVolume avol = (AudioCdVolume)volume; AudioCdRootVolumeItem root = avol.GetRoot(); AudioTrackVolumeItem[] tracks = root.GetTracks(); ListStore store = (ListStore)model; if (tracks.Length == 0) { store.AppendValues(null, STR_EMPTY, STR_EMPTY, STR_EMPTY); } else { foreach (AudioTrackVolumeItem track in tracks) { store.AppendValues(GetImage(track), track.Name, (track.Artist.Length == 0 ? S._("Unknown") : track.Artist), string.Format("{0:D2}:{1:D2}", track.Duration.Minutes, track.Duration.Seconds), track); } } Model = model; /*ColumnsAutosize();*/ break; default: throw new NotImplementedException("Items view has not been implemented for this volumetype"); } }
private string GetVolumeDescription(Volume v) { // common volume info string title; string category; if (string.IsNullOrEmpty(v.Title)) { Gdk.Color a = Parent.Style.Base(Gtk.StateType.Normal); Gdk.Color b = Parent.Style.Text(Gtk.StateType.Normal); Gdk.Color c = Util.ColorBlend(a, b); double gdk_max = (double)ushort.MaxValue; string col = string.Format("#{0:X2}{1:X2}{2:X2}", (int)(255 * (c.Red / gdk_max)), (int)(255 * (c.Green / gdk_max)), (int)(255 * (c.Blue / gdk_max))); title = string.Format("<span foreground=\"{0}\">{1}</span>", col, Util.Escape(STR_UNNAMED)); } else if (!string.IsNullOrEmpty(v.LoanedTo)) { title = string.Format("<span foreground=\"red\">{0}</span>", Util.Escape(v.Title)); } else { title = Util.Escape(v.Title); } if (string.IsNullOrEmpty(v.ArchiveNo)) { title = string.Format("<b>{0}</b>", title); } else { title = string.Format("<b>{0}</b> <small>({1})</small>", title, Util.Escape(v.ArchiveNo)); } if (string.IsNullOrEmpty(v.Category)) category = "-"; else if (!VolumeEditor.categories.TryGetTranslatedString(v.Category, out category)) category = v.Category; // specific volume info // only show important info, otherwise its too cluttered, too high! string strFormat = "{0}\n<span size=\"medium\"><i>{1}</i> {2}\n{3} / {4} {5}</span>"; string desc; switch (v.GetVolumeType()) { case VolumeType.FileSystemVolume: FileSystemVolume fsv = (FileSystemVolume)v; desc = string.Format(strFormat, title, Util.Escape(STR_CATEGORY), Util.Escape(category), Util.GetSizeStr(fsv.Size), fsv.Files.ToString(), Util.Escape(STR_FILES)); break; case VolumeType.AudioCdVolume: AudioCdVolume avol = (AudioCdVolume)v; desc = string.Format(strFormat, title, Util.Escape(STR_CATEGORY), Util.Escape(category), avol.Duration, avol.Tracks.ToString(), Util.Escape(STR_TRACKS)); break; default: throw new NotImplementedException("Description not implemented for this VolumeType"); } return desc; }