internal FilesystemVolumeInfo(FileSystemVolume v) : base(v) { this.files = v.Files; this.directories = v.Directories; this.size = v.Size; }
private void ImportMedia(XmlNode node, string borrow, string comment, long volumeID) { FileSystemVolume v = new FileSystemVolume(targetDb); VolumeDriveType driveType = driveTypeMapping[node.Attributes["type"].Value]; DateTime added; if (!DateTime.TryParseExact(node.Attributes["time"].Value, DATETIME_FORMAT, ci.DateTimeFormat, DateTimeStyles.None, out added)) { added = DateTime.MinValue; } v.SetVolumeFields(volumeID, node.Attributes["name"].Value, added, false, node.Attributes["number"].Value, driveType, borrow, DateTime.MinValue, DateTime.MinValue, null, comment, null); v.SetFileSystemVolumeFields(counters[TOTAL_FILES], counters[TOTAL_DIRS], counters[TOTAL_SIZE]); v.InsertIntoDB(); // insert root item DirectoryVolumeItem item = new DirectoryVolumeItem(targetDb); item.SetFileSystemVolumeItemFields(null, DateTime.MinValue, VolumeDatabase.ID_NONE); item.SetVolumeItemFields(volumeID, 1L, 0L, "/", VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY, MetadataStore.Empty, null, null); item.InsertIntoDB(); }
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); }
private static void ImportDisk(IDataReader reader, long volumeID, VolumeDatabase db, long[] counters) { FileSystemVolume v = new FileSystemVolume(db); // try to guess the drivetype VolumeDriveType driveType; string root = (string)reader["root"]; if (root.ToUpper().Contains("CDROM") || root.ToUpper().Contains("DVD")) driveType = VolumeDriveType.CDRom; else if (root.StartsWith("/media")) driveType = VolumeDriveType.Removable; else driveType = VolumeDriveType.Harddisk; v.SetVolumeFields(volumeID, Util.ReplaceDBNull<string>(reader["name"], null), DateTime.Now, false, null, driveType, Util.ReplaceDBNull<string>(reader["borrow"], null), DateTime.MinValue, DateTime.MinValue, null, Util.ReplaceDBNull<string>(reader["comment"], null), null); v.SetFileSystemVolumeFields(counters[TOTAL_FILES], counters[TOTAL_DIRS], counters[TOTAL_SIZE]); v.InsertIntoDB(); // insert root item DirectoryVolumeItem item = new DirectoryVolumeItem(db); item.SetFileSystemVolumeItemFields(null, DateTime.MinValue, VolumeDatabase.ID_NONE); item.SetVolumeItemFields(volumeID, 1L, 0L, "/", VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY, MetadataStore.Empty, null, null); item.InsertIntoDB(); }
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); }
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 static void ImportDisk(IDataReader reader, long volumeID, VolumeDatabase db, long[] counters) { FileSystemVolume v = new FileSystemVolume(db); // try to guess the drivetype VolumeDriveType driveType; string root = (string)reader["root"]; if (root.ToUpper().Contains("CDROM") || root.ToUpper().Contains("DVD")) { driveType = VolumeDriveType.CDRom; } else if (root.StartsWith("/media")) { driveType = VolumeDriveType.Removable; } else { driveType = VolumeDriveType.Harddisk; } v.SetVolumeFields(volumeID, Util.ReplaceDBNull <string>(reader["name"], null), DateTime.Now, false, null, driveType, Util.ReplaceDBNull <string>(reader["borrow"], null), DateTime.MinValue, DateTime.MinValue, null, Util.ReplaceDBNull <string>(reader["comment"], null), null); v.SetFileSystemVolumeFields(counters[TOTAL_FILES], counters[TOTAL_DIRS], counters[TOTAL_SIZE]); v.InsertIntoDB(); // insert root item DirectoryVolumeItem item = new DirectoryVolumeItem(db); item.SetFileSystemVolumeItemFields(null, DateTime.MinValue, VolumeDatabase.ID_NONE); item.SetVolumeItemFields(volumeID, 1L, 0L, "/", VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY, MetadataStore.Empty, null, null); item.InsertIntoDB(); }
internal FilesystemVolumeInfo(FileSystemVolume v) : base(v) { this.files = v.Files; this.directories = v.Directories; this.size = v.Size; }