internal void AddDisk(VirtualHardDisk vhd) { using (RotateWaitThreaded.Hold("Generating View for {0}", Path.GetFileNameWithoutExtension(vhd.Filename))) { if (vhd.vhdReadException != null) { // TODO: Handle virtualDIskException VhdPartitionView vhdview = new VhdPartitionView(); vhdview.Icon = Icon; vhdview.AddDisk(vhd); vhdview.remove += new VhdPartitionView.RemoveHandler(vhdview_remove); // When vhdview is added, it does a hell of a lot of drawing of greenpartitionlayout for no reason. flowLayoutPanel1.Controls.Add(vhdview); } else { VhdPartitionView vhdview = new VhdPartitionView(); vhdview.Icon = Icon; vhdview.AddDisk(vhd); vhdview.remove += new VhdPartitionView.RemoveHandler(vhdview_remove); // When vhdview is added, it does a hell of a lot of drawing of greenpartitionlayout for no reason. flowLayoutPanel1.Controls.Add(vhdview); } } }
public PartitionController(VirtualHardDisk vhd, int partition) { // TODO: Complete member initialization this.vhd = vhd; this.Partition = partition; try { if (GetClusterUsage() != null) { // Result is stored in ClusterBitArray as well as being returned } } catch (Exception ex) { vhd.vhdReadException = new VhdReadException("GetClusterUsage", ex); // throw new VhdReadException("GetClusterUsage", ex); } }
//internal void AddDisk(DiskUsageView duv) //{ // view = duv; // model = view.model; // MakeView(); //} internal void AddDisk(VirtualHardDisk vhd) { // TODO: Handle virtualDIskException //this.footer = vhd.footer; //this.dynamicHeader = vhd.dynamicHeader; //this.blockAllocationTable = vhd.blockAllocationTable; //this.masterBootRecord = vhd.masterBootRecord; this.vhd = vhd; if (vhd.vhdReadException == null) { if (CSharp.cc.Files.CheckIfFileIsBeingUsed(vhd.Filename)) { vhd.IOExceptionMessage = (string)CSharp.cc.Files.LastErrorMessage; } if (vhd.masterBootRecord != null) { this.model = new DiskUsageModel(vhd.masterBootRecord.getPartitionRecords()); } if (CSharp.cc.Files.CheckIfFileIsBeingUsed(vhd.Filename)) { vhd.IOExceptionMessage = (string)CSharp.cc.Files.LastErrorMessage; } } /* * this._disk = new Medo.IO.VirtualDisk(vhd.footer.FileName); * this._disk.Open(Medo.IO.VirtualDisk.NativeMethods.VIRTUAL_DISK_ACCESS_MASK.VIRTUAL_DISK_ACCESS_GET_INFO); * // this._disk.Attach(Medo.IO.VirtualDiskAttachOptions.None); * string _device = this._disk.GetPhysicalPath(); * if (!String.IsNullOrEmpty(_device)) * { * this.vhd.MountedAs = _device; * this.vhd.Partitions = DisksAndPartitions.GetPartitions(_device); * } * this._disk.Close(); * this._disk = null; */ MakeView(); }
public bool ReadVhd(string filename) { try { vhd = new VirtualHardDisk(filename); if (!vhd.DiskType.Equals("Fixed")) { ShowUsage(); } ShowDetailedUsage(); } catch (IOException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
public bool ReadVhd(string filename) { try { if (CSharp.cc.Files.DoubleCheckIfFileIsBeingUsed(filename)) { List <String> whoLockedIt = FileLockInfo.Handle(filename); string whoString = String.Empty; foreach (var who in whoLockedIt) { whoString += who.ToString() + ", "; } MessageBox.Show(filename + " Locked by " + whoString); return(false); } vhd = new VirtualHardDisk(filename); if (vhd.vhdReadException == null) { if (!vhd.DiskType.Equals("Fixed")) { ShowUsage(); } ShowDetailedUsage(); } } //catch (VhdReadException ex) //{ // vhd.vhdReadException = ex; //} catch (Exception ex) { MessageBox.Show(filename + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } finally { this.AddDisk(vhd); } return(true); }
public VhdProperties(VirtualHardDisk vhd) : this() { this.vhd = vhd; }