Beispiel #1
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);
         }
     }
 }
Beispiel #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);
                }
            }
        }