Beispiel #1
0
        /// <summary>
        /// Go to selected partition menu handler
        /// </summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Event Arguments</param>
        private void SelectRGBDOSDrive_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsi = (ToolStripMenuItem)sender;

            foreach (ToolStripMenuItem item in this.selectRGBDOSDriveToolStripMenuItem.DropDownItems)
            {
                if (item.Name != tsi.Name)
                {
                    if (item.Checked)
                    {
                        item.Checked = false;
                    }
                }
            }

            DiskViewForm        form      = (DiskViewForm)this.ActiveMdiChild;
            int                 partition = int.Parse(tsi.Name);
            PartitionedVHDImage diskimage = (PartitionedVHDImage)form.DiskFormat.DiskImage;

            diskimage.CurrentPartition = partition;

            IDiskFormat diskformat = new OS9Format(diskimage);

            if (diskformat != null && !diskformat.IsValidFormat)
            {
                diskformat = new DragonDosFormat(diskimage);
                if (diskformat != null && !diskformat.IsValidFormat)
                {
                    diskformat = new RSDOSFormat(diskimage);
                }
            }

            if (diskformat == null || !diskformat.IsValidFormat)
            {
                // Disk is blank, format?
            }

            if (diskformat != null && diskformat.IsValidFormat)
            {
                form.DiskFormat = diskformat;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Open virtual disk and display it in a DiskViewForm instance
        /// </summary>
        /// <param name="filename">Filename to open</param>
        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 OS9Image(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);
                if (!diskimage.IsValidImage)
                {
                    diskimage = new PartitionedVHDImage(filename);
                }

                break;

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

                break;
            }

            if (diskimage == null || !diskimage.IsValidImage)
            {
                this.mruManager.Remove(filename);
                MessageBox.Show(string.Format(resourceManager.GetString("MainForm_NotValidDiskImage", cultureInfo), filename), resourceManager.GetString("MainForm_NotValidDiskImageCaption", cultureInfo), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (diskimage.IsPartitioned)
                {
                    ComponentResourceManager resources = new ComponentResourceManager(typeof(MainForm));
                    PartitionedVHDImage      pi        = (PartitionedVHDImage)diskimage;

                    Cursor cursor = this.Cursor;
                    this.Cursor = Cursors.WaitCursor;
                    this.selectRGBDOSDriveToolStripMenuItem.DropDownItems.Clear();
                    ToolStripMenuItem tsi;

                    int i = 0;
                    if (diskimage.ImagePartitionOffset != 0)
                    {
                        tsi              = new ToolStripMenuItem();
                        tsi.Name         = "0";
                        tsi.Text         = "OS9 Drive";
                        tsi.Size         = new System.Drawing.Size(152, 22);
                        tsi.CheckOnClick = true;
                        tsi.Click       += new EventHandler(this.SelectRGBDOSDrive_Click);
                        tsi.Image        = (System.Drawing.Image)resources.GetObject("OS9.image");
                        diskformat       = new OS9Format(diskimage);
                        if (diskformat != null && diskformat.IsValidFormat && !string.IsNullOrEmpty(diskformat.DiskLabel))
                        {
                            tsi.Text = diskformat.DiskLabel;
                        }

                        this.selectRGBDOSDriveToolStripMenuItem.DropDownItems.Add(tsi);
                        i++;
                    }

                    for (int j = 0; i < diskimage.Partitions; j++, i++)
                    {
                        tsi              = new ToolStripMenuItem();
                        tsi.Name         = i.ToString();
                        tsi.Text         = string.Format("RGBDOS Drive {0}", j);
                        tsi.Size         = new System.Drawing.Size(152, 22);
                        tsi.CheckOnClick = true;
                        tsi.Click       += new EventHandler(this.SelectRGBDOSDrive_Click);
                        if (i == 0)
                        {
                            tsi.Checked = true;
                        }

                        pi.CurrentPartition = i;

                        diskformat = new OS9Format(pi);
                        tsi.Image  = (System.Drawing.Image)resources.GetObject("OS9.image");

                        if (!diskformat.IsValidFormat)
                        {
                            diskformat = new DragonDosFormat(pi);
                            tsi.Image  = (System.Drawing.Image)resources.GetObject("DragonDos.image");
                            if (!diskformat.IsValidFormat)
                            {
                                diskformat = new RSDOSFormat(pi);
                                tsi.Image  = (System.Drawing.Image)resources.GetObject("RSDOS.image");
                            }
                        }

                        if (diskformat != null && diskformat.IsValidFormat && !string.IsNullOrEmpty(diskformat.DiskLabel))
                        {
                            tsi.Text = diskformat.DiskLabel;
                        }

                        this.selectRGBDOSDriveToolStripMenuItem.DropDownItems.Add(tsi);
                    }

                    pi.CurrentPartition = 0;
                    ((ToolStripMenuItem)this.selectRGBDOSDriveToolStripMenuItem.DropDownItems[0]).Checked = true;

                    this.selectRGBDOSDriveToolStripMenuItem.Enabled = true;
                    this.gotoRGBDOSDriveToolStripMenuItem.Enabled   = true;

                    this.Cursor = cursor;
                }
                else
                {
                    this.selectRGBDOSDriveToolStripMenuItem.Enabled = false;
                    this.gotoRGBDOSDriveToolStripMenuItem.Enabled   = false;
                }
            }

            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.IsPartitioned)
            {
                DialogResult dr = MessageBox.Show(resourceManager.GetString("MainForm_disknotformatted", cultureInfo), resourceManager.GetString("MainForm_formatnotrecognized", cultureInfo), MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dr == System.Windows.Forms.DialogResult.Yes)
                {
                    // FormatWizardForm form = new FormatWizardForm(false, true);
                    // form.Filename = diskimage.Filename;
                    // form.Tracks = diskimage.PhysicalTracks;
                    // form.Heads = diskimage.PhysicalHeads;
                    // form.Sectors = diskimage.PhysicalSectors;
                    // form.SectorSize = diskimage.PhysicalSectorSize;
                    // form.Partitions = diskimage.Partitions;
                    // form.RootPartitionSize = diskimage.ImagePartitionOffset;
                    // form.DiskImageType = diskimage.ImageType;
                    // dr = form.ShowDialog();
                    FormatForm form = new FormatForm();
                    form.Label1 = resourceManager.GetString("FormatForm_formatdisk", cultureInfo);
                    dr          = form.ShowDialog();
                    if (dr == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                    else
                    {
                        if (form.OS9)
                        {
                            diskformat = new OS9Format(diskimage);
                            diskformat.FormatDisk();
                        }
                        else if (form.RSDOS)
                        {
                            diskformat = new RSDOSFormat(diskimage);
                            diskformat.FormatDisk();
                        }
                        else if (form.DragonDos)
                        {
                            diskformat = new DragonDosFormat(diskimage);
                            diskformat.FormatDisk();
                        }
                    }
                }
            }
            else if (!diskformat.IsValidFormat && diskimage.IsPartitioned)
            {
                DialogResult dr = MessageBox.Show(resourceManager.GetString("MainForm_partitionnotformatted", cultureInfo), resourceManager.GetString("MainForm_formatnotrecognized", cultureInfo), MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dr == System.Windows.Forms.DialogResult.Yes)
                {
                    FormatForm form = new FormatForm();
                    form.Label1 = resourceManager.GetString("FormatForm_formatpartition", cultureInfo);
                    dr          = form.ShowDialog();
                    if (dr == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                    else
                    {
                        if (form.OS9)
                        {
                            diskformat = new OS9Format(diskimage);
                            diskformat.FormatDisk();
                        }
                        else if (form.RSDOS)
                        {
                            diskformat = new RSDOSFormat(diskimage);
                            diskformat.FormatDisk();
                        }
                        else if (form.DragonDos)
                        {
                            diskformat = new DragonDosFormat(diskimage);
                            diskformat.FormatDisk();
                        }
                    }
                }
            }

            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.PartitionItems = this.selectRGBDOSDriveToolStripMenuItem;
            diskviewform.Show();

            this.mruManager.Add(filename);
        }