Example #1
0
        internal void OpenDiskView(string filename)
        {
            IDiskImage  diskimage  = null;
            IDiskFormat diskformat = null;

            if (!File.Exists(filename))
            {
                this.mruManager.Remove(filename);
                return;
            }

            switch (Path.GetExtension(filename).ToUpper())
            {
            case ".OS9":
                diskimage = new RAWImage(filename);
                break;

            case ".JVC":
                diskimage = new JVCImage(filename);
                break;

            case ".VDK":
                diskimage = new VDKImage(filename);
                break;

            case ".DMK":
                diskimage = new DMKImage(filename);
                break;

            case ".VHD":
                diskimage = new VHDImage(filename);
                break;

            case ".DSK":
                diskimage = new JVCImage(filename);
                if (!diskimage.IsValidImage)
                {
                    diskimage.Close();
                    diskimage = new DMKImage(filename);
                }

                break;
            }

            if (diskimage == null || !diskimage.IsValidImage)
            {
                diskimage.Close();
                this.mruManager.Remove(filename);
                MessageBox.Show(string.Format(resourceManager.GetString("MainForm_NotValidDiskImage", cultureInfo), filename), resourceManager.GetString("MainForm_NotValidDiskImageCaption", cultureInfo), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            diskimage.SetPartition(0);

            diskformat = new OS9Format(diskimage);
            if (diskformat == null || !diskformat.IsValidFormat)
            {
                diskformat = new DragonDosFormat(diskimage);
                if (diskformat == null || !diskformat.IsValidFormat)
                {
                    diskformat = new RSDosFormat(diskimage);
                }
            }

            if (!diskformat.IsValidFormat || !diskimage.IsValidImage)
            {
                diskformat = null;
                diskimage.Close();
            }
            else
            {
                DiskViewForm diskviewform = new DiskViewForm(diskformat);
                diskviewform.Text       = string.Format("EMUDisk - {0}", diskimage.Filename);
                diskviewform.MdiParent  = this;
                diskviewform.Activated += new EventHandler(this.DiskViewForm_Activated);
                diskviewform.Disposed  += new EventHandler(this.DiskViewForm_Disposed);
                diskviewform.Show();

                this.mruManager.Add(filename);
            }
        }