Skip to content

Commit

Permalink
some light maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
mukunku committed Sep 10, 2021
1 parent d510c90 commit e0fc7c3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 45 deletions.
39 changes: 29 additions & 10 deletions src/ParquetFileViewer/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}
}

Expand All @@ -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 { }
}
}

Expand All @@ -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 { }
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/ParquetFileViewer/FieldSelectionDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 16 additions & 27 deletions src/ParquetFileViewer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -69,10 +65,7 @@ private string OpenFilePath
private List<string> selectedFields = null;
private List<string> SelectedFields
{
get
{
return this.selectedFields;
}
get => this.selectedFields;
set
{
this.selectedFields = value;
Expand All @@ -86,7 +79,7 @@ private List<string> SelectedFields
private int currentOffset = DefaultOffset;
private int CurrentOffset
{
get { return this.currentOffset; }
get => this.currentOffset;
set
{
this.currentOffset = value;
Expand All @@ -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;
Expand All @@ -118,7 +111,7 @@ private bool IsAnyFileOpen
private DataTable mainDataSource;
private DataTable MainDataSource
{
get { return this.mainDataSource; }
get => this.mainDataSource;
set
{
this.mainDataSource = value;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -969,7 +958,7 @@ private void MetadataViewerToolStripMenuItem_Click(object sender, EventArgs e)
metadataViewer.ShowDialog(this);
}
}
catch(Exception ex)
catch (Exception ex)
{
this.ShowError(ex);
}
Expand Down

0 comments on commit e0fc7c3

Please sign in to comment.