void AddStorage(StorageEnum kind) { IStorageConfigurationForm configForm; switch (kind) { case StorageEnum.Hdd: configForm = new HddStorageForm(null); break; case StorageEnum.Ftp: configForm = new FtpStorageForm(null); break; case StorageEnum.Network: configForm = new NetworkStorageForm(null); break; default: throw new NotImplementedException(kind.ToString()); } if (configForm.ShowDialog() == DialogResult.OK) { StorageBase storage = configForm.Storage; AddStorageToListView(storage, kind); } configForm.Dispose(); }
void ModifyStorage() { ListViewItem storageToChangeListViewItem = storagesListView.SelectedItems[0]; var storageToChange = (StorageBase)storageToChangeListViewItem.Tag; IStorageConfigurationForm configForm; if (storageToChange is HddStorage) { configForm = new HddStorageForm((HddStorage)storageToChange); } else if (storageToChange is FtpStorage) { configForm = new FtpStorageForm((FtpStorage)storageToChange); } else if (storageToChange is NetworkStorage) { configForm = new NetworkStorageForm((NetworkStorage)storageToChange); } else { throw new NotImplementedException(storageToChange.GetType().Name); } if (configForm.ShowDialog() == DialogResult.OK) { StorageBase storage = configForm.Storage; storageToChangeListViewItem.Text = storage.StorageName; storageToChangeListViewItem.ToolTipText = storage.Hint; storageToChangeListViewItem.Tag = storage; } }