private void LoadRecords(string fileName, ListView listView) { CurveLibrary library = null; Cursor = Cursors.WaitCursor; listView.BeginUpdate(); listView.Items.Clear(); try { Exception exception; library = fileName == null ? new CurveLibrary() : new CurveLibrary(fileName); try { library.Load(false); } catch (Exception exception1) { exception = exception1; throw new Exception(Resources.ErrorLoadingCurveFile + exception.Message); } var num = 1; try { foreach (var record in library.Read()) { listView.Items.Add( new ListViewItem(new[] { record.Manufacturer, record.LightCount, record.Color.ToString(CultureInfo.InvariantCulture), record.Controller })).Tag = record; num++; } } catch (Exception exception2) { exception = exception2; throw new Exception(string.Format(Resources.ErrorInCurveFile, num, exception.Message)); } } finally { listView.EndUpdate(); Cursor = Cursors.Default; if (library != null) { library.Dispose(); } } }
private void LoadRecords() { if (_isInternal) { return; } Cursor = Cursors.WaitCursor; try { SetFilters(); listViewRecords.BeginUpdate(); listViewRecords.Items.Clear(); btnOkay.Enabled = false; try { foreach (var record in _curveLibrary.Read()) { listViewRecords.Items.Add( new ListViewItem(new[] { record.Manufacturer, record.LightCount, record.Color.ToString(CultureInfo.InvariantCulture), record.Controller })).Tag = record; } } catch (Exception exception) { MessageBox.Show(exception.Message, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { listViewRecords.EndUpdate(); } if (_curveLibrary.IsFiltered) { return; } PopulateFilter(comboBoxManufacturer, _curveLibrary.GetAllManufacturers()); PopulateFilter(comboBoxCount, _curveLibrary.GetAllLightCounts()); PopulateFilter(comboBoxColor, _curveLibrary.GetAllLightColors()); PopulateFilter(comboBoxController, _curveLibrary.GetAllControllers()); } finally { Cursor = Cursors.Default; } }