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 CurveLibraryRecordEditDialog_FormClosing(object sender, FormClosingEventArgs e) { _curveLibrary.Dispose(); }