Example #1
0
        private void DiskViewForm_Activated(object sender, EventArgs e)
        {
            DiskViewForm form = (DiskViewForm)this.ActiveMdiChild;
            IDiskImage   di   = form.DiskFormat.DiskImage;

            this.UpdateMenu();
        }
Example #2
0
        private void mnuDiskChangeVolumename_Click(object sender, EventArgs e)
        {
            DiskViewForm form       = (DiskViewForm)this.ActiveMdiChild;
            string       volumename = form.DiskFormat.VolumeLabel;

            DialogResult dr = InputBox("Volume Rename", "Volume Name", 32, ref volumename);

            if (dr == DialogResult.OK)
            {
                if (volumename == "")
                {
                    volumename = null;
                }
                form.DiskFormat.VolumeLabel = volumename;

                form.Text = form.DiskFormat.DiskImage.Filename;
                if (!string.IsNullOrEmpty(form.DiskFormat.DiskImage.DiskLabel))
                {
                    form.Text += " {" + form.DiskFormat.DiskImage.DiskLabel + "}";
                }
                if (!string.IsNullOrEmpty(form.DiskFormat.VolumeLabel))
                {
                    form.Text += " [" + form.DiskFormat.VolumeLabel + "]";
                }
            }
        }
Example #3
0
 /// <summary>
 /// Update the menus
 /// </summary>
 private void UpdateMenu()
 {
     if (this.MdiChildren.Length == 0)
     {
         this.closeToolStripMenuItem.Enabled  = false;
         this.diskToolStripMenuItem.Enabled   = false;
         this.windowToolStripMenuItem.Enabled = false;
     }
     else
     {
         this.closeToolStripMenuItem.Enabled     = true;
         this.diskToolStripMenuItem.Enabled      = true;
         this.windowToolStripMenuItem.Enabled    = true;
         this.bootstrapToolStripMenuItem.Enabled = false;
         DiskViewForm form = (DiskViewForm)this.ActiveMdiChild;
         if (form.DiskFormat.DiskFormat == DiskFormatType.OS9Format)
         {
             OS9Format diskformat = (OS9Format)form.DiskFormat;
             if (diskformat.Lsn0.BootStrap != 0)
             {
                 this.bootstrapToolStripMenuItem.Enabled = true;
             }
         }
     }
 }
Example #4
0
        private void mnuDiskSectorEditor_Click(object sender, EventArgs e)
        {
            DiskViewForm dv = (DiskViewForm)this.ActiveMdiChild;
            SectorEditor sv = new SectorEditor(dv.DiskFormat.DiskImage);

            sv.ShowDialog();
            if (sv.SectorChanged)
            {
            }
        }
Example #5
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;
            }
        }
Example #6
0
        /// <summary>
        /// Update menu when a DiskViewForm is activated
        /// </summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Event Arguments</param>
        private void DiskViewForm_Activated(object sender, EventArgs e)
        {
            DiskViewForm form = (DiskViewForm)this.ActiveMdiChild;
            IDiskImage   di   = form.DiskFormat.DiskImage;

            if (di.IsPartitioned)
            {
                this.selectRGBDOSDriveToolStripMenuItem = form.PartitionItems;

                this.selectRGBDOSDriveToolStripMenuItem.Enabled = true;
                this.gotoRGBDOSDriveToolStripMenuItem.Enabled   = true;
            }
            else
            {
                this.selectRGBDOSDriveToolStripMenuItem.Enabled = false;
                this.gotoRGBDOSDriveToolStripMenuItem.Enabled   = false;
            }

            this.UpdateMenu();
        }
Example #7
0
        private void UpdateMenu()
        {
            if (this.MdiChildren.Length == 0)
            {
                this.mnuFileClose.Enabled = false;
                this.mnuDisk.Enabled      = false;
                this.mnuWindow.Enabled    = false;
            }
            else
            {
                this.mnuFileClose.Enabled            = true;
                this.mnuDisk.Enabled                 = true;
                this.mnuWindow.Enabled               = true;
                this.mnuDiskBootstrap.Enabled        = false;
                this.mnuDiskChangeDiskName.Enabled   = false;
                this.mnuDiskChangeVolumename.Enabled = false;

                DiskViewForm form = (DiskViewForm)this.ActiveMdiChild;
                if (form != null)
                {
                    if (form.DiskFormat.DiskFormat == DiskFormatTypes.OS9Format)
                    {
                        OS9Format diskformat = (OS9Format)form.DiskFormat;
                        if (diskformat.Lsn0.DD_BT != 0)
                        {
                            this.mnuDiskBootstrap.Enabled = true;
                        }
                    }

                    if (form.DiskFormat.DiskImage is VDKImage)
                    {
                        this.mnuDiskChangeDiskName.Enabled = true;
                    }

                    if (form.DiskFormat is OS9Format || form.DiskFormat is RSDosFormat)
                    {
                        this.mnuDiskChangeVolumename.Enabled = true;
                    }
                }
            }
        }
Example #8
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);
            }
        }
Example #9
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);
        }