From e0fc7c3693c46c84c833cf88942cbb82ff6a8540 Mon Sep 17 00:00:00 2001 From: Sal Date: Fri, 10 Sep 2021 17:57:41 -0400 Subject: [PATCH] some light maintenance --- src/ParquetFileViewer/AppSettings.cs | 39 ++++++++++++----- src/ParquetFileViewer/FieldSelectionDialog.cs | 12 ++---- src/ParquetFileViewer/MainForm.cs | 43 +++++++------------ 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/ParquetFileViewer/AppSettings.cs b/src/ParquetFileViewer/AppSettings.cs index d33b2bc..741182e 100644 --- a/src/ParquetFileViewer/AppSettings.cs +++ b/src/ParquetFileViewer/AppSettings.cs @@ -12,19 +12,30 @@ public static bool UseISODateFormat { get { - using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + try { - bool value = false; - bool.TryParse(registryKey.GetValue(UseISODateFormatKey)?.ToString(), out value); - return value; + using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + { + bool value = false; + bool.TryParse(registryKey.GetValue(UseISODateFormatKey)?.ToString(), out value); + return value; + } + } + catch + { + return false; } } set { - using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + try { - registryKey.SetValue(UseISODateFormatKey, value.ToString()); + using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + { + registryKey.SetValue(UseISODateFormatKey, value.ToString()); + } } + catch { } } } @@ -48,10 +59,14 @@ public static bool AlwaysSelectAllFields } set { - using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + try { - registryKey.SetValue(AlwaysSelectAllFieldsKey, value.ToString()); + using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + { + registryKey.SetValue(AlwaysSelectAllFieldsKey, value.ToString()); + } } + catch { } } } @@ -77,10 +92,14 @@ public static ParquetEngine ReadingEngine } set { - using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + try { - registryKey.SetValue(ParquetReadingEngineKey, value.ToString()); + using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer")) + { + registryKey.SetValue(ParquetReadingEngineKey, value.ToString()); + } } + catch { } } } } diff --git a/src/ParquetFileViewer/FieldSelectionDialog.cs b/src/ParquetFileViewer/FieldSelectionDialog.cs index 580e268..4c6d879 100644 --- a/src/ParquetFileViewer/FieldSelectionDialog.cs +++ b/src/ParquetFileViewer/FieldSelectionDialog.cs @@ -210,14 +210,10 @@ private void doneButton_Click(object sender, EventArgs e) { try { - try - { - if (this.allFieldsRememberRadioButton.Checked) - AppSettings.AlwaysSelectAllFields = true; - else - AppSettings.AlwaysSelectAllFields = false; - } - catch { /* just in case */ } + if (this.allFieldsRememberRadioButton.Checked) + AppSettings.AlwaysSelectAllFields = true; + else + AppSettings.AlwaysSelectAllFields = false; this.NewSelectedFields.Clear(); if (this.allFieldsRadioButton.Checked || this.allFieldsRememberRadioButton.Checked || ((CheckBox)(this.fieldsPanel.Controls.Find(SelectAllCheckboxName, true)[0])).Checked) diff --git a/src/ParquetFileViewer/MainForm.cs b/src/ParquetFileViewer/MainForm.cs index f9b80de..d380bf7 100644 --- a/src/ParquetFileViewer/MainForm.cs +++ b/src/ParquetFileViewer/MainForm.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; -using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -33,10 +32,7 @@ public partial class MainForm : Form private string openFilePath; private string OpenFilePath { - get - { - return this.openFilePath; - } + get => this.openFilePath; set { this.openFileSchema = null; @@ -69,10 +65,7 @@ private string OpenFilePath private List selectedFields = null; private List SelectedFields { - get - { - return this.selectedFields; - } + get => this.selectedFields; set { this.selectedFields = value; @@ -86,7 +79,7 @@ private List SelectedFields private int currentOffset = DefaultOffset; private int CurrentOffset { - get { return this.currentOffset; } + get => this.currentOffset; set { this.currentOffset = value; @@ -98,7 +91,7 @@ private int CurrentOffset private int currentMaxRowCount = DefaultRowCount; private int CurrentMaxRowCount { - get { return this.currentMaxRowCount; } + get => this.currentMaxRowCount; set { this.currentMaxRowCount = value; @@ -118,7 +111,7 @@ private bool IsAnyFileOpen private DataTable mainDataSource; private DataTable MainDataSource { - get { return this.mainDataSource; } + get => this.mainDataSource; set { this.mainDataSource = value; @@ -173,20 +166,16 @@ private void MainForm_Load(object sender, EventArgs e) this.OpenNewFile(this.fileToLoadOnLaunch); } - try - { - //Setup date format checkboxes - if (AppSettings.UseISODateFormat) - this.iSO8601ToolStripMenuItem.Checked = true; - else - this.defaultToolStripMenuItem.Checked = true; + //Setup date format checkboxes + if (AppSettings.UseISODateFormat) + this.iSO8601ToolStripMenuItem.Checked = true; + else + this.defaultToolStripMenuItem.Checked = true; - if (AppSettings.ReadingEngine == ParquetEngine.Default) - this.defaultParquetEngineToolStripMenuItem.Checked = true; - else if (AppSettings.ReadingEngine == ParquetEngine.Default_Multithreaded) - this.multithreadedParquetEngineToolStripMenuItem.Checked = true; - } - catch { /* just in case */ } + if (AppSettings.ReadingEngine == ParquetEngine.Default) + this.defaultParquetEngineToolStripMenuItem.Checked = true; + else if (AppSettings.ReadingEngine == ParquetEngine.Default_Multithreaded) + this.multithreadedParquetEngineToolStripMenuItem.Checked = true; } #region Event Handlers @@ -694,7 +683,7 @@ private void mainGridView_DataBindingComplete(object sender, DataGridViewBinding { this.actualShownRecordCountLabel.Text = this.mainGridView.RowCount.ToString(); - foreach(DataGridViewColumn column in ((DataGridView)sender).Columns) + foreach (DataGridViewColumn column in ((DataGridView)sender).Columns) { if (column is DataGridViewCheckBoxColumn checkboxColumn) { @@ -969,7 +958,7 @@ private void MetadataViewerToolStripMenuItem_Click(object sender, EventArgs e) metadataViewer.ShowDialog(this); } } - catch(Exception ex) + catch (Exception ex) { this.ShowError(ex); }