/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InsertEjectOnClick(Object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;

            if (item != null)
            {
                EmulatorRemovableBlockStorageDevice removableBSD =
                    removableBSDs[item.Name];

                try
                {
                    if (removableBSD.Inserted)
                    {
                        removableBSD.Eject();
                    }
                    else
                    {
                        InsertMediaDialogBox insertMediaDialogBox =
                            new InsertMediaDialogBox();
                        if (insertMediaDialogBox.ShowDialog() ==
                            DialogResult.OK)
                        {
                            if (insertMediaDialogBox.CreateNewMedia)
                            {
                                removableBSD.Insert(
                                    insertMediaDialogBox.FilePath,
                                    insertMediaDialogBox.SectorsPerBlock,
                                    insertMediaDialogBox.BytesPerSector,
                                    insertMediaDialogBox.NumBlocks,
                                    insertMediaDialogBox.SerialNumber);
                            }
                            else
                            {
                                removableBSD.Insert(
                                    insertMediaDialogBox.FilePath);
                            }
                        }
                    }

                    item.Text = GetItemText(removableBSD);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                    return;
                }
            }
        }
Exemplo n.º 2
0
        private void btnSDInsertRemove_Click(object sender, EventArgs e)
        {
            ListViewItem lvi = lvSD.SelectedItems.Count != 0 ? lvSD.SelectedItems[0] : null;

            if (lvi != null)
            {
                EmulatorRemovableBlockStorageDevice rbsd = lvi.Tag as EmulatorRemovableBlockStorageDevice;
                try
                {
                    if (rbsd.Inserted)
                    {
                        rbsd.Eject();
                    }
                    else
                    {
                        DialogInsertMedia dlg = new DialogInsertMedia();
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.CreateNewMedia)
                            {
                                rbsd.Insert(dlg.FilePath, dlg.SectorsPerBlock, dlg.BytesPerSector, dlg.NumBlocks, dlg.SerialNumber);
                            }
                            else
                            {
                                rbsd.Insert(dlg.FilePath);
                            }
                        }
                    }
                    PopulateSDInfo(lvi);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }