From cd31fc5cd1a0278057235fe78aff3c6ff80b6f58 Mon Sep 17 00:00:00 2001 From: Rekkonnect Date: Mon, 29 May 2023 01:47:42 +0300 Subject: [PATCH] Open query panel upon loading database --- MainForm.cs | 12 +++++++++++- SqlCeDb.cs | 17 +++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index b683d22..8408fd8 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -241,6 +241,11 @@ private void LoadDatabase(string fileName, string password) main.Expand(); treeDb.EndUpdate(); treeDb.SelectedNode = treeDb.Nodes[0]; + + // Show query panel immediately + btnQuery.Checked = true; + UpdateQueryPanelState(); + settings.AddToRecentFiles(fileName); UpdateRecentFilesMenu(); } @@ -358,7 +363,7 @@ private void btnOpen_Click(object sender, EventArgs e) LoadDatabase(openFileDialog1.FileName); } - private void btnQuery_Click(object sender, EventArgs e) + private void UpdateQueryPanelState() { splitterHorizontal.Panel1Collapsed = splitterHorizontal.IsSplitterFixed = !btnQuery.Checked; showEditorMenuItem.Checked = btnQuery.Checked; @@ -366,6 +371,11 @@ private void btnQuery_Click(object sender, EventArgs e) UpdateStatus(); } + private void btnQuery_Click(object sender, EventArgs e) + { + UpdateQueryPanelState(); + } + private void mainForm_FormClosing(object sender, FormClosingEventArgs e) { SaveSettings(); diff --git a/SqlCeDb.cs b/SqlCeDb.cs index 9af7760..7e1eaa2 100644 --- a/SqlCeDb.cs +++ b/SqlCeDb.cs @@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License using System; using System.Collections.Generic; using System.Data.Common; +using System.Globalization; using System.Linq; using System.Text; using System.Windows.Forms; @@ -29,15 +30,15 @@ namespace CompactView { public class SqlCeDb : SqlCeBase { - private System.Globalization.CultureInfo culture; - private Dictionary tablesDdl = new Dictionary(); - private Dictionary primaryKeysDdl = new Dictionary(); - private Dictionary indexesDdl = new Dictionary(); - private Dictionary foreignKeysDdl = new Dictionary(); + private CultureInfo culture; + private readonly Dictionary tablesDdl = new Dictionary(); + private readonly Dictionary primaryKeysDdl = new Dictionary(); + private readonly Dictionary indexesDdl = new Dictionary(); + private readonly Dictionary foreignKeysDdl = new Dictionary(); public SqlCeDb() : base() { - culture = System.Globalization.CultureInfo.InvariantCulture; + culture = CultureInfo.InvariantCulture; } new public bool Open(string databaseFile, string password) @@ -271,7 +272,7 @@ private Constraint GetConstraint(ref DbDataReader dr) return cst; } - private void AddColumnLine(ref StringBuilder ddl, Column col) + private void AddColumnLine(StringBuilder ddl, Column col) { switch (col.DataType) { @@ -363,7 +364,7 @@ private void AddColumnsDdl(ref StringBuilder ddl, string tableName) first = false; else ddl.Append($",{Environment.NewLine}"); - AddColumnLine(ref ddl, GetColumn(ref dr)); + AddColumnLine(ddl, GetColumn(ref dr)); } dr.Close(); }