Skip to content

Commit

Permalink
add ability to set default column sizes #49
Browse files Browse the repository at this point in the history
also upgrade to .net 4.7.2
  • Loading branch information
mukunku committed Feb 19, 2022
1 parent abc1933 commit f444293
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 138 deletions.
16 changes: 8 additions & 8 deletions src/ParquetFileViewer/App.config
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IronSnappy" publicKeyToken="b1d4b1dc83bdcf31" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
<assemblyIdentity name="IronSnappy" publicKeyToken="b1d4b1dc83bdcf31" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
49 changes: 43 additions & 6 deletions src/ParquetFileViewer/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
using Microsoft.Win32;
using System;
using System.Windows.Forms;

namespace ParquetFileViewer
{
public static class AppSettings
{
private const string RegistrySubKey = "ParquetViewer";
private const string UseISODateFormatKey = "UseISODateFormat";
private const string AlwaysSelectAllFieldsKey = "AlwaysSelectAllFields";
private const string ParquetReadingEngineKey = "ParquetReadingEngine";
private const string AutoSizeColumnsModeKey = "AutoSizeColumnsMode";

public static bool UseISODateFormat
{
get
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
bool value = false;
bool.TryParse(registryKey.GetValue(UseISODateFormatKey)?.ToString(), out value);
Expand All @@ -30,7 +34,7 @@ public static bool UseISODateFormat
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
registryKey.SetValue(UseISODateFormatKey, value.ToString());
}
Expand All @@ -45,7 +49,7 @@ public static bool AlwaysSelectAllFields
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
bool value = false;
bool.TryParse(registryKey.GetValue(AlwaysSelectAllFieldsKey)?.ToString(), out value);
Expand All @@ -61,7 +65,7 @@ public static bool AlwaysSelectAllFields
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
registryKey.SetValue(AlwaysSelectAllFieldsKey, value.ToString());
}
Expand All @@ -76,7 +80,7 @@ public static ParquetEngine ReadingEngine
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
ParquetEngine value = default;
if (!Enum.TryParse<ParquetEngine>(registryKey.GetValue(ParquetReadingEngineKey)?.ToString(), out value))
Expand All @@ -94,13 +98,46 @@ public static ParquetEngine ReadingEngine
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("ParquetViewer"))
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
registryKey.SetValue(ParquetReadingEngineKey, value.ToString());
}
}
catch { }
}
}

public static DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode
{
get
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
int? value = registryKey.GetValue(AutoSizeColumnsModeKey) as int?;
if (value != null && Enum.IsDefined(typeof(DataGridViewAutoSizeColumnsMode), value))
return (DataGridViewAutoSizeColumnsMode)value;
else
return DataGridViewAutoSizeColumnsMode.Fill;
}
}
catch
{
return DataGridViewAutoSizeColumnsMode.Fill;
}
}
set
{
try
{
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistrySubKey))
{
registryKey.SetValue(AutoSizeColumnsModeKey, (int)value);
}
}
catch { }
}
}
}
}
Loading

0 comments on commit f444293

Please sign in to comment.