protected override void LoadFromObject(VolumeDB.Volume volume) { // // form // ArchiveNo = volume.ArchiveNo; Category = volume.Category; Title = volume.Title; Description = volume.Description; Keywords = volume.Keywords; LoanedTo = volume.LoanedTo; if (volume.LoanedDate != DateTime.MinValue) { dcLoanedDate.Date = volume.LoanedDate; } else { dcLoanedDate.Clear(); } if (volume.ReturnDate != DateTime.MinValue) { dcReturnDate.Date = volume.ReturnDate; } else { dcReturnDate.Clear(); } // // info labels // UpdateInfoLabels(volume.IsHashed, volume.Added); }
protected override void LoadFromObject(VolumeDB.Volume volume) { if (!(volume is AudioCdVolume)) { throw new ArgumentException(string.Format("must be of type {0}", typeof(AudioCdVolume)), "volume"); } base.LoadFromObject(volume); AudioCdVolume avol = (AudioCdVolume)volume; UpdateInfoLabels(avol.Tracks, avol.Duration); }
protected override void LoadFromObject(VolumeDB.Volume volume) { if (!(volume is FileSystemVolume)) { throw new ArgumentException(string.Format("must be of type {0}", typeof(FileSystemVolume)), "volume"); } base.LoadFromObject(volume); FileSystemVolume fsvol = (FileSystemVolume)volume; UpdateInfoLabels(fsvol.Files, fsvol.Directories, fsvol.Size); }
protected override void SaveToObject(VolumeDB.Volume volume) { // save form volume.ArchiveNo = ArchiveNo.Trim(); volume.Category = Category; volume.Title = Title.Trim(); volume.Description = Description; volume.Keywords = Keywords.Trim(); volume.LoanedTo = LoanedTo.Trim(); volume.LoanedDate = LoanedDate; volume.ReturnDate = ReturnDate; volume.UpdateChanges(); }
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"); } }
public NewVolumeAddedEventArgs(Volume volume) : base() { this.volume = volume; }
private Gdk.Pixbuf GetVolumeIcon(Volume v) { Gdk.Pixbuf icon; switch (v.DriveType) { case VolumeDriveType.CDRom: icon = iconCache.GetIcon(Icons.Icon.Stock_Cdrom, ICON_SIZE); break; case VolumeDriveType.Harddisk: icon = iconCache.GetIcon(Icons.Icon.Stock_Harddisk, ICON_SIZE); break; case VolumeDriveType.Ram: icon = iconCache.GetIcon(Icons.Icon.Stock_Harddisk, ICON_SIZE); // FIXME : is there a more suitable icon? break; case VolumeDriveType.Network: icon = iconCache.GetIcon(Icons.Icon.Stock_Network, ICON_SIZE); break; case VolumeDriveType.Removable: icon = iconCache.GetIcon(Icons.Icon.DriveRemovableMedia, ICON_SIZE); break; case VolumeDriveType.Unknown: icon = iconCache.GetIcon(Icons.Icon.Stock_Harddisk, ICON_SIZE); // FIXME : is there a more suitable icon? break; default: throw new Exception("Invalid VolumeDriveType"); } return icon; }
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; }
private void AddVolume(ListStore store, Volume v) { store.AppendValues(GetVolumeIcon(v), GetVolumeDescription(v), v); }
public void UpdateVolume(TreeIter iter, Volume volume) { //Model.SetValue(iter, 0, GetVolumeIcon(volume); Model.SetValue(iter, 1, GetVolumeDescription(volume)); }
public void Fill(Volume[] volumes) { if (volumes == null) throw new ArgumentNullException("volumes"); Clear(); ListStore store = (ListStore)Model; foreach (Volume v in volumes) AddVolume(store, v); // cluumns may still have the old width after clear() // so reset it ColumnsAutosize(); }
public void AddVolume(Volume v) { AddVolume((ListStore)this.Model, v); }
public VolumeScanner(VolumeDatabase db, DriveInfo drive) { this.scanCompleted = false; this.database = db; this.newVolume = null; infoIcon = RenderIcon(Icons.Icon.Stock_DialogInfo, ICON_SIZE); warningIcon = RenderIcon(Icons.Icon.Stock_DialogWarning, ICON_SIZE); errorIcon = RenderIcon(Icons.Icon.Stock_DialogError, ICON_SIZE); mdps = null; if (App.Settings.ScannerExtractMetaData && (VolumeProber.ProbeVolume(drive) == VolumeProber.VolumeProbeResult.Filesystem)) { mdps = new MetadataProvider[] { new TagLibMetadataProvider(), new ArchiveMetadataProvider() }; } // setup scanner options ScannerOptions[] opts = new ScannerOptions[2] { new FilesystemScannerOptions() { BufferSize = App.Settings.ScannerBufferSize, ComputeHashs = App.Settings.ScannerComputeHashs, DiscardSymLinks = App.Settings.ScannerDiscardSymLinks, GenerateThumbnails = App.Settings.ScannerGenerateThumbnails, MetadataProviders = mdps, DbDataPath = PathUtil.GetDbDataPath(database) }, new AudioCdScannerOptions() { EnableMusicBrainz = App.Settings.ScannerEnableMusicBrainz } }; scanner = VolumeProber.GetScannerForVolume(drive, database, opts); // scanner eventhandlers scanner.BeforeScanItem += scanner_BeforeScanItem; scanner.ScannerWarning += scanner_ScannerWarning; scanner.Error += scanner_Error; scanner.ScanCompleted += scanner_ScanCompleted; /* volumedatabase event handlers */ database.BeginWriteAccess += database_BeginWriteAccess; database.EndWriteAccess += database_EndWriteAccess; // must be called _after_ scanner instanciation // (requires scanner.VolumeInfo.GetVolumeType()) BuildGui(); InitTreeView(); scannerLog = new StringBuilder(); timer = new StatusUpdateTimer(this); try { /* NOTE: make sure the timer will be removed properly later, * or it keeps running, even if this window has been closed. */ timer.Install(); string tmp; // e.g. GIO network 'drives' do not have a devicefile if (string.IsNullOrEmpty(drive.Device)) tmp = S._("Scanning started."); else tmp = string.Format(S._("Scanning of drive '{0}' started."), drive.Device); UpdateLog(LogIcon.Info, tmp); switch (scanner.VolumeInfo.GetVolumeType()) { case VolumeType.FileSystemVolume: UpdateLog(LogIcon.Info, string.Format(S._("Options: generate thumbs: {0}, extract metadata: {1}, discard symlinks: {2}, hashing: {3}."), BoolToStr(App.Settings.ScannerGenerateThumbnails), BoolToStr(App.Settings.ScannerExtractMetaData), BoolToStr(App.Settings.ScannerDiscardSymLinks), BoolToStr(App.Settings.ScannerComputeHashs))); break; case VolumeType.AudioCdVolume: UpdateLog(LogIcon.Info, string.Format(S._("Options: MusicBrainz enabled: {0}"), BoolToStr(App.Settings.ScannerEnableMusicBrainz))); break; default: throw new NotImplementedException(string.Format("Missing options output for scannertyp {0}", scanner.GetType())); } if (scanner.VolumeInfo.GetVolumeType() == VolumeType.FileSystemVolume) { // copy already known volume data into the editor volEditor.ArchiveNo = scanner.VolumeInfo.ArchiveNo; volEditor.Title = scanner.VolumeInfo.Title; } else { // other volumetypes have no useful data yet (e.g. AudioCD data may be queried from musicbrainz.org), // so disable the editor and re-enable it and fill in the data when scanning has been completed. volEditor.Sensitive = false; } // start scanning on a new thread and return immediately scanner.RunAsync(); } catch { timer.Remove(); throw; } }
private void scanner_ScanCompleted(object sender, ScanCompletedEventArgs e) { Application.Invoke(delegate { if (e.Error != null) { UpdateLog(LogIcon.Error, string.Format(S._("Scanning failed. Reason: an unhandled exception occured ({0})."), e.Error.Message)); } else if (e.Cancelled) { UpdateLog(LogIcon.Error, S._("Scanning aborted.")); } else { UpdateLog(LogIcon.Info, S._("Scanning completed successfully.")); newVolume = e.Volume; // the volume editor may have been disabled in the ctor // for some volume types (e.g. AudioCD volumes) if (!volEditor.Sensitive) { volEditor.Load(newVolume); volEditor.Sensitive = true; } } if (!btnAbort.Sensitive) /* possibly disabled in AbortScan() */ btnAbort.Sensitive = true; btnAbort.Label = Stock.Close; scanCompleted = true; }); /* remove timeout handler (installed in ctor) */ timer.Remove(); }
protected virtual void OnNewVolumeAdded(Volume volume) { if (NewVolumeAdded != null) NewVolumeAdded(this, new NewVolumeAddedEventArgs(volume)); }