1
1
using Microsoft . Win32 ;
2
2
using System ;
3
+ using System . Windows . Forms ;
3
4
4
5
namespace ParquetFileViewer
5
6
{
6
7
public static class AppSettings
7
8
{
9
+ private const string RegistrySubKey = "ParquetViewer" ;
8
10
private const string UseISODateFormatKey = "UseISODateFormat" ;
9
11
private const string AlwaysSelectAllFieldsKey = "AlwaysSelectAllFields" ;
10
12
private const string ParquetReadingEngineKey = "ParquetReadingEngine" ;
13
+ private const string AutoSizeColumnsModeKey = "AutoSizeColumnsMode" ;
14
+
11
15
public static bool UseISODateFormat
12
16
{
13
17
get
14
18
{
15
19
try
16
20
{
17
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
21
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
18
22
{
19
23
bool value = false ;
20
24
bool . TryParse ( registryKey . GetValue ( UseISODateFormatKey ) ? . ToString ( ) , out value ) ;
@@ -30,7 +34,7 @@ public static bool UseISODateFormat
30
34
{
31
35
try
32
36
{
33
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
37
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
34
38
{
35
39
registryKey . SetValue ( UseISODateFormatKey , value . ToString ( ) ) ;
36
40
}
@@ -45,7 +49,7 @@ public static bool AlwaysSelectAllFields
45
49
{
46
50
try
47
51
{
48
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
52
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
49
53
{
50
54
bool value = false ;
51
55
bool . TryParse ( registryKey . GetValue ( AlwaysSelectAllFieldsKey ) ? . ToString ( ) , out value ) ;
@@ -61,7 +65,7 @@ public static bool AlwaysSelectAllFields
61
65
{
62
66
try
63
67
{
64
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
68
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
65
69
{
66
70
registryKey . SetValue ( AlwaysSelectAllFieldsKey , value . ToString ( ) ) ;
67
71
}
@@ -76,7 +80,7 @@ public static ParquetEngine ReadingEngine
76
80
{
77
81
try
78
82
{
79
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
83
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
80
84
{
81
85
ParquetEngine value = default ;
82
86
if ( ! Enum . TryParse < ParquetEngine > ( registryKey . GetValue ( ParquetReadingEngineKey ) ? . ToString ( ) , out value ) )
@@ -94,13 +98,46 @@ public static ParquetEngine ReadingEngine
94
98
{
95
99
try
96
100
{
97
- using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( "ParquetViewer" ) )
101
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
98
102
{
99
103
registryKey . SetValue ( ParquetReadingEngineKey , value . ToString ( ) ) ;
100
104
}
101
105
}
102
106
catch { }
103
107
}
104
108
}
109
+
110
+ public static DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode
111
+ {
112
+ get
113
+ {
114
+ try
115
+ {
116
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
117
+ {
118
+ int ? value = registryKey . GetValue ( AutoSizeColumnsModeKey ) as int ? ;
119
+ if ( value != null && Enum . IsDefined ( typeof ( DataGridViewAutoSizeColumnsMode ) , value ) )
120
+ return ( DataGridViewAutoSizeColumnsMode ) value ;
121
+ else
122
+ return DataGridViewAutoSizeColumnsMode . Fill ;
123
+ }
124
+ }
125
+ catch
126
+ {
127
+ return DataGridViewAutoSizeColumnsMode . Fill ;
128
+ }
129
+ }
130
+ set
131
+ {
132
+ try
133
+ {
134
+ using ( RegistryKey registryKey = Registry . CurrentUser . CreateSubKey ( RegistrySubKey ) )
135
+ {
136
+ registryKey . SetValue ( AutoSizeColumnsModeKey , ( int ) value ) ;
137
+ }
138
+ }
139
+ catch { }
140
+ }
141
+ }
105
142
}
106
143
}
0 commit comments