コード例 #1
0
ファイル: OptionsWindow.cs プロジェクト: cyrosy/DTWrapper
        private bool loadDrives()
        {
            InfoWindow info = new InfoWindow(Localization.Strings.VirtualDriveSearching);
            info.Show(this);
            driveField.Items.Clear();
            List<VirtualDrive> drives = new List<VirtualDrive>();

            for (int i = 0; i < DT.CountDrv(VirtualDriveType.DT); i++)
            {
                drives.Add(new VirtualDrive(VirtualDriveType.DT, i));
            }

            for (int i = 0; i < DT.CountDrv(VirtualDriveType.SCSI); i++)
            {
                drives.Add(new VirtualDrive(VirtualDriveType.SCSI, i));
            }

            if (DT.Type == DTType.Pro)
            {
                for (int i = 0; i < DT.CountDrv(VirtualDriveType.IDE); i++)
                {
                    drives.Add(new VirtualDrive(VirtualDriveType.IDE, i));
                }
            }

            drives.Sort((x,y) => string.Compare(x.Letter.ToString(), y.Letter.ToString()));

            if (drives.Count < 1)
            {
                return false;
            }

            foreach (VirtualDrive drive in drives)
            {
                driveField.Items.Add(drive);

                if (drive.Type == _options.VirtualDrive.Type
                && drive.Num == _options.VirtualDrive.Num)
                {
                    driveField.SelectedIndex = driveField.Items.Count - 1;
                }
            }
            info.Close();

            return true;
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: cyrosy/DTWrapper
 public bool findDT()
 {
     InfoWindow info = new InfoWindow(Localization.Strings.DTSearching);
     info.Show(this);
     if (DT.Type == DTType.None)
     {
         LogHelper.RaiseError(this, Localization.Strings.DTNotFound);
         this.DTVersion.Text = Localization.Strings.DTNotFound;
         info.Close();
         return false;
     }
     else
     {
         this.DTVersion.Text = "DT " + DT.Type.ToString() + " " + DT.Version;
         LogHelper.WriteLine(this.DTVersion.Text, LogHelper.MessageType.INFO);
         if (!_options.Reload() || !_options.VirtualDrive.IsValid)
         {
             info.Close();
             editOptions();
         }
         else
         {
             virtualDrive = _options.VirtualDrive;
             selectedDrive.Text = virtualDrive.ToString();
             info.Close();
         }
         return true;
     }
 }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: cyrosy/DTWrapper
        private bool startSelectedProg()
        {
            refreshButtonsState();
            if (!this.startButton.Enabled) return false;

            InfoWindow info = new InfoWindow(Localization.Strings.Preparing);
            info.Show(this);

            Prog prog = progList.Get(Int32.Parse(progsListView.SelectedItems[0].Name));
            if (prog.DiskImage.Length > 0 && !virtualDrive.IsValid)
            {
                info.Close();
                return false;
            }

            this.Hide();
            this.trayIcon.Text = String.Format(Localization.Strings.ProgWaitingEnd, prog.Name);
            this.trayIcon.Visible = true;
            info.Close();

            info = new InfoWindow(String.Format(Localization.Strings.DiskImageMounting, prog.DiskImage, prog.Name));
            info.Show(this);
            if (!prog.MountDiskImage(virtualDrive)) info.Close();
            else
            {
                info.Close();
                info = new InfoWindow(String.Format(Localization.Strings.ProgStarting, prog.Name));
                Process proc = prog.Start();
                info.Close();
                proc.WaitForExit();

                if (prog.DiskImage.Length > 0)
                {
                    info = new InfoWindow(String.Format(Localization.Strings.DiskImageUnmounting, prog.DiskImage));
                    info.Show(this);
                    virtualDrive.Umount();
                    info.Close();
                }
            }

            this.trayIcon.Visible = false;
            refreshWindow();
            this.Show();
            return true;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: cyrosy/DTWrapper
        private static int Start(string progName)
        {
            var trayIcon = new NotifyIcon {Icon = GUI.Properties.Resources.icon};
            var progs = new ProgList();
            Prog prog;

            try
            {
                int progId = Int32.Parse(progName);
                prog = progs.Get(progId);
            }
            catch (FormatException)
            {
                prog = progs.Get(progName);
            }

            if (prog == null || !prog.IsOK() || (prog.DiskImage.Length > 0 && !prog.DiskImageOK()))
            {
                ShowError(String.Format(Localization.Strings.ProgNotFound, progName));
                return -1;
            }

            var info = new InfoWindow(String.Format(Localization.Strings.ProgPreparing, prog.Name));
            info.Show();

            trayIcon.Text = String.Format(Localization.Strings.ProgWaitingEnd, prog.Name);

            VirtualDrive virtualDrive = null;
            if(prog.DiskImage.Length > 0)
            {
                if (!new MainWindow().findDT())
                {
                    return -1;
                }

                var opts = new Options();
                if (!opts.Reload())
                {
                    ShowError(Localization.Strings.OptionsError);
                    return -1;
                }
                virtualDrive = opts.VirtualDrive;

                if (!virtualDrive.IsValid)
                {
                    info.Close();
                    ShowError(Localization.Strings.InvalidDrive + " : " + virtualDrive);
                    return -1;
                }

                info.Close();
                info = new InfoWindow(String.Format(Localization.Strings.DiskImageMounting, prog.DiskImage, prog.Name));
                info.Show();
                if (!prog.MountDiskImage(virtualDrive))
                {
                    ShowError(Localization.Strings.ErrorMounting);
                    return -1;
                }
            }

            info.Close();
            info = new InfoWindow(String.Format(Localization.Strings.ProgStarting, prog.Name));
            info.Show();

            Process proc = prog.Start();
            trayIcon.Visible = true;
            info.Close();
            proc.WaitForExit();
            trayIcon.Visible = false;

            if (virtualDrive != null && virtualDrive.IsValid)
            {
                info = new InfoWindow(Localization.Strings.DiskImageUnmounting);
                info.Show();
                virtualDrive.Umount();
                info.Close();
            }
            return 0;
        }