diff --git a/src/ParquetFileViewer/Controls/DelayedOnChangedTextBox.cs b/src/ParquetFileViewer/Controls/DelayedOnChangedTextBox.cs
index 814a1b8..44d58b8 100644
--- a/src/ParquetFileViewer/Controls/DelayedOnChangedTextBox.cs
+++ b/src/ParquetFileViewer/Controls/DelayedOnChangedTextBox.cs
@@ -5,7 +5,8 @@ namespace ParquetFileViewer.Controls
{
public class DelayedOnChangedTextBox : TextBox
{
- private Timer m_delayedTextChangedTimer;
+ private bool _skipNextTextChange = false;
+ private Timer _delayedTextChangedTimer;
public event EventHandler DelayedTextChanged;
@@ -23,11 +24,11 @@ public DelayedOnChangedTextBox(int secondsDelay)
protected override void Dispose(bool disposing)
{
- if (m_delayedTextChangedTimer != null)
+ if (_delayedTextChangedTimer != null)
{
- m_delayedTextChangedTimer.Stop();
+ _delayedTextChangedTimer.Stop();
if (disposing)
- m_delayedTextChangedTimer.Dispose();
+ _delayedTextChangedTimer.Dispose();
}
base.Dispose(disposing);
@@ -42,23 +43,41 @@ protected virtual void OnDelayedTextChanged(EventArgs e)
protected override void OnTextChanged(EventArgs e)
{
- this.InitializeDelayedTextChangedEvent();
+ if (this._skipNextTextChange)
+ {
+ _skipNextTextChange = false;
+ }
+ else
+ {
+ this.InitializeDelayedTextChangedEvent();
+ }
+
base.OnTextChanged(e);
}
+ ///
+ /// Sets the Text value of the textbox without triggering the text changed event
+ ///
+ /// New value to set as the textbox's text
+ public void SetTextQuiet(string text)
+ {
+ this._skipNextTextChange = true;
+ this.Text = text;
+ }
+
private void InitializeDelayedTextChangedEvent()
{
- if (m_delayedTextChangedTimer != null)
- m_delayedTextChangedTimer.Stop();
+ if (_delayedTextChangedTimer != null)
+ _delayedTextChangedTimer.Stop();
- if (m_delayedTextChangedTimer == null || m_delayedTextChangedTimer.Interval != this.DelayedTextChangedTimeout)
+ if (_delayedTextChangedTimer == null || _delayedTextChangedTimer.Interval != this.DelayedTextChangedTimeout)
{
- m_delayedTextChangedTimer = new Timer();
- m_delayedTextChangedTimer.Tick += new EventHandler(HandleDelayedTextChangedTimerTick);
- m_delayedTextChangedTimer.Interval = this.DelayedTextChangedTimeout;
+ _delayedTextChangedTimer = new Timer();
+ _delayedTextChangedTimer.Tick += new EventHandler(HandleDelayedTextChangedTimerTick);
+ _delayedTextChangedTimer.Interval = this.DelayedTextChangedTimeout;
}
- m_delayedTextChangedTimer.Start();
+ _delayedTextChangedTimer.Start();
}
private void HandleDelayedTextChangedTimerTick(object sender, EventArgs e)
diff --git a/src/ParquetFileViewer/Helpers/CustomScriptBasedSchemaAdapter.cs b/src/ParquetFileViewer/Helpers/CustomScriptBasedSchemaAdapter.cs
index 98a4093..633bb8d 100644
--- a/src/ParquetFileViewer/Helpers/CustomScriptBasedSchemaAdapter.cs
+++ b/src/ParquetFileViewer/Helpers/CustomScriptBasedSchemaAdapter.cs
@@ -14,24 +14,26 @@ public class CustomScriptBasedSchemaAdapter
static CustomScriptBasedSchemaAdapter()
{
- Hashtable hashtable = new Hashtable();
- hashtable.Add(typeof(ulong), "bigint {1}NULL");
- hashtable.Add(typeof(long), "bigint {1}NULL");
- hashtable.Add(typeof(bool), "bit {1}NULL");
- hashtable.Add(typeof(char), "char {1}NULL");
- hashtable.Add(typeof(DateTime), "datetime {1}NULL");
- hashtable.Add(typeof(double), "float {1}NULL");
- hashtable.Add(typeof(uint), "int {1}NULL");
- hashtable.Add(typeof(int), "int {1}NULL");
- hashtable.Add(typeof(Guid), "uniqueidentifier {1}NULL");
- hashtable.Add(typeof(ushort), "smallint {1}NULL");
- hashtable.Add(typeof(short), "smallint {1}NULL");
- hashtable.Add(typeof(decimal), "real {1}NULL");
- hashtable.Add(typeof(byte), "tinyint {1}NULL");
- hashtable.Add(typeof(sbyte), "tinyint {1}NULL");
- hashtable.Add(typeof(string), "nvarchar({0}) {1}NULL");
- hashtable.Add(typeof(TimeSpan), "int {1}NULL");
- hashtable.Add(typeof(byte[]), "varbinary {1}NULL");
+ Hashtable hashtable = new Hashtable
+ {
+ { typeof(ulong), "BIGINT {1}NULL" },
+ { typeof(long), "BIGINT {1}NULL" },
+ { typeof(bool), "BIT {1}NULL" },
+ { typeof(char), "CHAR {1}NULL" },
+ { typeof(DateTime), "DATETIME {1}NULL" },
+ { typeof(double), "FLOAT {1}NULL" },
+ { typeof(uint), "INT {1}NULL" },
+ { typeof(int), "INT {1}NULL" },
+ { typeof(Guid), "UNIQUEIDENTIFIER {1}NULL" },
+ { typeof(ushort), "SMALLINT {1}NULL" },
+ { typeof(short), "SMALLINT {1}NULL" },
+ { typeof(decimal), "REAL {1}NULL" },
+ { typeof(byte), "TINYINT {1}NULL" },
+ { typeof(sbyte), "TINYINT {1}NULL" },
+ { typeof(string), "NVARCHAR({0}) {1}NULL" },
+ { typeof(TimeSpan), "INT {1}NULL" },
+ { typeof(byte[]), "VARBINARY {1}NULL" }
+ };
TypeMap = hashtable;
}
@@ -132,7 +134,7 @@ private string MakeList(DataColumnCollection columns)
{
if (!flag)
{
- stringBuilder.Append(" , ");
+ stringBuilder.Append(", ");
}
string str = this.MakeSafe(column.ColumnName);
string typeFor = this.GetTypeFor(column);
@@ -163,7 +165,7 @@ private string MakeRelation(DataRelation relation)
protected string MakeSafe(string inputValue)
{
string str = inputValue.Trim();
- string str1 = string.Format("[{0}]", str.Substring(0, Math.Min(128, str.Length)));
+ string str1 = string.Format("[{0}]", str[..Math.Min(128, str.Length)]);
return str1;
}
@@ -172,7 +174,7 @@ private string MakeTable(DataTable table, bool markTablesAsLocalTemp)
StringBuilder stringBuilder = new StringBuilder();
string str = this.MakeSafe(string.Concat(markTablesAsLocalTemp ? "#" : string.Empty, this.TablePrefix, table.TableName));
string str1 = this.MakeList(table.Columns);
- stringBuilder.AppendFormat("CREATE TABLE {0} ({1});\n", str, str1);
+ stringBuilder.AppendFormat("CREATE TABLE {0} ({1}\n);", str, str1);
return stringBuilder.ToString();
}
}
diff --git a/src/ParquetFileViewer/MainForm.Designer.cs b/src/ParquetFileViewer/MainForm.Designer.cs
index 1af3852..fc8c7f3 100644
--- a/src/ParquetFileViewer/MainForm.Designer.cs
+++ b/src/ParquetFileViewer/MainForm.Designer.cs
@@ -37,7 +37,7 @@ private void InitializeComponent()
this.offsetTextBox = new ParquetFileViewer.Controls.DelayedOnChangedTextBox();
this.runQueryButton = new System.Windows.Forms.Button();
this.searchFilterLabel = new System.Windows.Forms.LinkLabel();
- this.searchFilterTextBox = new ParquetFileViewer.Controls.DelayedOnChangedTextBox();
+ this.searchFilterTextBox = new System.Windows.Forms.TextBox();
this.clearFilterButton = new System.Windows.Forms.Button();
this.mainGridView = new System.Windows.Forms.DataGridView();
this.openParquetFileDialog = new System.Windows.Forms.OpenFileDialog();
@@ -211,7 +211,6 @@ private void InitializeComponent()
//
this.searchFilterTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.mainTableLayoutPanel.SetColumnSpan(this.searchFilterTextBox, 2);
- this.searchFilterTextBox.DelayedTextChangedTimeout = 1000;
this.searchFilterTextBox.Location = new System.Drawing.Point(100, 6);
this.searchFilterTextBox.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.searchFilterTextBox.Name = "searchFilterTextBox";
@@ -669,7 +668,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem changeFieldsMenuStripButton;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
- private ParquetFileViewer.Controls.DelayedOnChangedTextBox searchFilterTextBox;
+ private System.Windows.Forms.TextBox searchFilterTextBox;
private System.Windows.Forms.Button runQueryButton;
private System.Windows.Forms.Button clearFilterButton;
private System.Windows.Forms.ToolStripStatusLabel showingRecordCountStatusBarLabel;
diff --git a/src/ParquetFileViewer/MainForm.cs b/src/ParquetFileViewer/MainForm.cs
index bfb353c..6f4e321 100644
--- a/src/ParquetFileViewer/MainForm.cs
+++ b/src/ParquetFileViewer/MainForm.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -144,8 +144,8 @@ public MainForm()
{
InitializeComponent();
this.DefaultFormTitle = this.Text;
- this.offsetTextBox.Text = DefaultOffset.ToString();
- this.recordCountTextBox.Text = DefaultRowCount.ToString();
+ this.offsetTextBox.SetTextQuiet(DefaultOffset.ToString());
+ this.recordCountTextBox.SetTextQuiet(DefaultRowCount.ToString());
this.MainDataSource = new DataTable();
this.OpenFilePath = null;
@@ -396,7 +396,7 @@ private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
private void userGuideToolStripMenuItem_Click(object sender, EventArgs e)
{
- System.Diagnostics.Process.Start(WikiURL);
+ Process.Start(new ProcessStartInfo(WikiURL) { UseShellExecute = true });
}
private void MainGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
@@ -668,8 +668,18 @@ private void mainGridView_DataBindingComplete(object sender, DataGridViewBinding
private void OpenNewFile(string filePath)
{
this.OpenFilePath = filePath;
- this.offsetTextBox.Text = string.IsNullOrWhiteSpace(this.offsetTextBox.Text) ? DefaultOffset.ToString() : this.offsetTextBox.Text;
- this.recordCountTextBox.Text = string.IsNullOrWhiteSpace(this.recordCountTextBox.Text) ? DefaultRowCount.ToString() : this.recordCountTextBox.Text;
+
+ if (!DefaultOffset.ToString().Equals(this.offsetTextBox.Text)) //Without this 'if' SetTextQuiet doesn't work correctly!
+ {
+ this.offsetTextBox.SetTextQuiet(DefaultOffset.ToString());
+ this.currentMaxRowCount = DefaultRowCount;
+ }
+
+ if (!DefaultRowCount.ToString().Equals(this.recordCountTextBox.Text)) //Without this 'if' SetTextQuiet doesn't work correctly!
+ {
+ this.recordCountTextBox.SetTextQuiet(DefaultRowCount.ToString());
+ this.currentOffset = DefaultOffset;
+ }
this.OpenFieldSelectionDialog(false);
}
@@ -852,15 +862,9 @@ public ParquetReadResult(DataTable result, long totalNumberOfRecordsInFile)
private void GetSQLCreateTableScriptToolStripMenuItem_Click(object sender, EventArgs e)
{
- string tableName = DefaultTableName;
- try
- {
- tableName = Path.GetFileNameWithoutExtension(this.OpenFilePath);
- }
- catch { /* just in case */ }
-
try
{
+ string tableName = Path.GetFileNameWithoutExtension(this.OpenFilePath) ?? DefaultTableName;
if (this.mainDataSource?.Columns.Count > 0)
{
var dataset = new DataSet();
diff --git a/src/ParquetFileViewer/Properties/AssemblyInfo.cs b/src/ParquetFileViewer/Properties/AssemblyInfo.cs
index 41f5b69..d990eae 100644
--- a/src/ParquetFileViewer/Properties/AssemblyInfo.cs
+++ b/src/ParquetFileViewer/Properties/AssemblyInfo.cs
@@ -31,4 +31,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.4.1.0")]
+[assembly: AssemblyVersion("2.4.1.1")]