private void btnImport_Click(object sender, EventArgs e) { if (this.dgvSelectorVFComponents.SelectedRows.Count == 0) { var msgBoxResponse = MessageBox.Show( "No Components have been selected for Import. VehicleForge Component Exchange Dialog will close.", "Nothing Happened", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (msgBoxResponse == System.Windows.Forms.DialogResult.OK) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); } else { return; } } List <string> componentZipPaths = new List <string>(); using (VFDownloadProgressDialog downloadProgressDialog = new VFDownloadProgressDialog()) { // set the size of the download progess bar, and print how many components will be downloaded downloadProgressDialog.pbDownloadProgress.Maximum = this.dgvSelectorVFComponents.SelectedRows.Count; downloadProgressDialog.lblNumberComponents.Text = string.Format("{0} Components", this.dgvSelectorVFComponents.SelectedRows.Count); downloadProgressDialog.Show(); foreach (var row in this.dgvSelectorVFComponents.SelectedRows) { var dgvr = row as System.Windows.Forms.DataGridViewRow; var vfcli = dgvr.DataBoundItem as VFComponentListItem; try { string newZipPath = exchange.DownloadComponent(vfcli.Component, this.zipDownloadDir); if (newZipPath != null) { componentZipPaths.Add(newZipPath); } downloadProgressDialog.pbDownloadProgress.PerformStep(); downloadProgressDialog.pbDownloadProgress.Refresh(); } catch (ISIS.VehicleForge.VFDownloadFailedException ex) { var msgBoxResponse = MessageBox.Show( "Unable to download component.", "Component download failed.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } this.DownloadedComponentZips.AddRange(componentZipPaths); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private void btnImport_Click(object sender, EventArgs e) { if (this.dgvSelectorVFComponents.SelectedRows.Count == 0) { var msgBoxResponse = MessageBox.Show( "No Components have been selected for Import. VehicleForge Component Exchange Dialog will close.", "Nothing Happened", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (msgBoxResponse == System.Windows.Forms.DialogResult.OK) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); } else { return; } } List<string> componentZipPaths = new List<string>(); using (VFDownloadProgressDialog downloadProgressDialog = new VFDownloadProgressDialog()) { // set the size of the download progess bar, and print how many components will be downloaded downloadProgressDialog.pbDownloadProgress.Maximum = this.dgvSelectorVFComponents.SelectedRows.Count; downloadProgressDialog.lblNumberComponents.Text = string.Format("{0} Components", this.dgvSelectorVFComponents.SelectedRows.Count); downloadProgressDialog.Show(); foreach (var row in this.dgvSelectorVFComponents.SelectedRows) { var dgvr = row as System.Windows.Forms.DataGridViewRow; var vfcli = dgvr.DataBoundItem as VFComponentListItem; try { string newZipPath = exchange.DownloadComponent(vfcli.Component, this.zipDownloadDir); if (newZipPath != null) { componentZipPaths.Add(newZipPath); } downloadProgressDialog.pbDownloadProgress.PerformStep(); downloadProgressDialog.pbDownloadProgress.Refresh(); } catch (ISIS.VehicleForge.VFDownloadFailedException ex) { var msgBoxResponse = MessageBox.Show( "Unable to download component.", "Component download failed.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } this.DownloadedComponentZips.AddRange(componentZipPaths); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }