diff --git a/CHANGE.LOG b/CHANGE.LOG index 00cefbe..81f85a0 100644 --- a/CHANGE.LOG +++ b/CHANGE.LOG @@ -1,8 +1,17 @@ +2023/05/29 v1.5.0 Feature: The SQL query editor now opens immediately after + loading a database. + Feature: Ctrl+Enter in the SQL query editor only + executes the surrounding statement around the cursor. + Optimization: Added an assembly dependency to the + System.Data.SqlServerCe assembly, and eliminated the + use of reflection to interact with it. + Feature: A new setting to avoid showing the popup + for only executing the selected text. 2017/07/13 v1.4.14 Fix bug: Failed to display tables of more than 255 fields. 2017/02/17 v1.4.13 Right-clicking on the header causes the width of the column fit all cells. - Added German translation (Thanks to Peet Baldem). + Added German translation (Thanks to Peet Baldem). 2015/11/11 v1.4.12 Added traditional and simplified Chinese translations (Thanks to Jordan Chen). 2015/08/31 v1.4.11 Added Turkish translation. diff --git a/CompactView.csproj b/CompactView.csproj index adad3de..0f7ceed 100644 --- a/CompactView.csproj +++ b/CompactView.csproj @@ -84,6 +84,7 @@ AboutForm.cs + Form diff --git a/DataSetExtensions.cs b/DataSetExtensions.cs new file mode 100644 index 0000000..32b292a --- /dev/null +++ b/DataSetExtensions.cs @@ -0,0 +1,36 @@ +/************************************************************************** +Copyright (C) 2023 Rekkonnect + +This file is part of CompactView. + +CompactView is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +CompactView is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with CompactView. If not, see . + +CompactView web site . +**************************************************************************/ + +using System.Data; + +namespace CompactView +{ + public static class DataSetExtensions + { + public static void ReadField(this DataTable table, DataRow row, string name, ref T field) + { + if (table.Columns.Contains(name)) + { + field = row.Field(name); + } + } + } +} diff --git a/GlobalText.cs b/GlobalText.cs index 159effd..5ddc7ca 100644 --- a/GlobalText.cs +++ b/GlobalText.cs @@ -195,7 +195,9 @@ private static void FillEnglish() { "Indexes", "Indexes" }, { "Keys", "Keys" }, { "TableConstraints", "Table Constraints" }, - { "ForeignConstraints", "Foreign Constraints" } + { "ForeignConstraints", "Foreign Constraints" }, + { "BehaviorSettingsGroup", "Behavior" }, + { "ExecuteSelectedStatementWithoutAsking", "Always execute the selected statement without asking" }, }; string fileName = XmlName("en-EN"); diff --git a/MainForm.cs b/MainForm.cs index 8408fd8..8b1def5 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -265,7 +265,7 @@ private void LoadDatabase(string fileName, string password) { GlobalText.ShowError("UnableToOpen", ex.Message); btnQuery.Enabled = btnExecute.Enabled = btnClear.Enabled = false; - settings.RemoveFromRecentFiles(fileName); + settings.RecentFiles.Remove(fileName); UpdateRecentFilesMenu(); } Cursor = Cursors.Default; @@ -454,8 +454,9 @@ private void ExecuteQuery(bool shouldWarnPartialSelection) if (isEmptySql) return; - bool partial = !string.IsNullOrWhiteSpace(rtbQuery.SelectedText); - shouldWarnPartialSelection &= partial; + bool isPartialSelection = !string.IsNullOrWhiteSpace(rtbQuery.SelectedText); + shouldWarnPartialSelection &= isPartialSelection + && !settings.OmitSelectedTextExecutionPopup; if (shouldWarnPartialSelection) { DialogResult result = MessageBox.Show(GlobalText.GetValue("SelectedTextQuery"), GlobalText.GetValue("Confirm"), @@ -463,9 +464,9 @@ private void ExecuteQuery(bool shouldWarnPartialSelection) if (result == DialogResult.Cancel) return; - shouldWarnPartialSelection = result == DialogResult.Yes; + isPartialSelection = result == DialogResult.Yes; } - string sql = shouldWarnPartialSelection + string sql = isPartialSelection ? rtbQuery.SelectedText.Trim() : rtbQuery.Text.Trim(); diff --git a/OptionsForm.Designer.cs b/OptionsForm.Designer.cs index 90312c4..afea2a7 100644 --- a/OptionsForm.Designer.cs +++ b/OptionsForm.Designer.cs @@ -52,8 +52,11 @@ private void InitializeComponent() this.label7 = new System.Windows.Forms.Label(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.behaviorGroupBox = new System.Windows.Forms.GroupBox(); + this.alwaysExecuteSelectedStatementCheckBox = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); + this.behaviorGroupBox.SuspendLayout(); this.SuspendLayout(); // // cbBackground1 @@ -157,7 +160,7 @@ private void InitializeComponent() // btnOk // this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOk.Location = new System.Drawing.Point(239, 229); + this.btnOk.Location = new System.Drawing.Point(239, 324); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(92, 25); this.btnOk.TabIndex = 2; @@ -167,7 +170,7 @@ private void InitializeComponent() // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(360, 229); + this.btnCancel.Location = new System.Drawing.Point(360, 324); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(92, 25); this.btnCancel.TabIndex = 2; @@ -284,13 +287,35 @@ private void InitializeComponent() this.colorDialog1.AnyColor = true; this.colorDialog1.FullOpen = true; // + // behaviorGroupBox + // + this.behaviorGroupBox.Controls.Add(this.alwaysExecuteSelectedStatementCheckBox); + this.behaviorGroupBox.Location = new System.Drawing.Point(12, 221); + this.behaviorGroupBox.Name = "behaviorGroupBox"; + this.behaviorGroupBox.Size = new System.Drawing.Size(669, 97); + this.behaviorGroupBox.TabIndex = 4; + this.behaviorGroupBox.TabStop = false; + this.behaviorGroupBox.Text = "Behavior"; + // + // alwaysExecuteSelectedStatementCheckBox + // + this.alwaysExecuteSelectedStatementCheckBox.AutoSize = true; + this.alwaysExecuteSelectedStatementCheckBox.Location = new System.Drawing.Point(14, 28); + this.alwaysExecuteSelectedStatementCheckBox.Name = "alwaysExecuteSelectedStatementCheckBox"; + this.alwaysExecuteSelectedStatementCheckBox.Size = new System.Drawing.Size(281, 17); + this.alwaysExecuteSelectedStatementCheckBox.TabIndex = 0; + this.alwaysExecuteSelectedStatementCheckBox.Text = "Always execute the selected statement without asking"; + this.alwaysExecuteSelectedStatementCheckBox.UseVisualStyleBackColor = true; + this.alwaysExecuteSelectedStatementCheckBox.CheckedChanged += new System.EventHandler(this.alwaysExecuteSelectedStatementCheckBox_CheckedChanged); + // // OptionsForm // this.AcceptButton = this.btnOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(693, 265); + this.ClientSize = new System.Drawing.Size(693, 361); + this.Controls.Add(this.behaviorGroupBox); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnOk); @@ -306,6 +331,8 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.OptionsForm_Load); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + this.behaviorGroupBox.ResumeLayout(false); + this.behaviorGroupBox.PerformLayout(); this.ResumeLayout(false); } @@ -334,5 +361,7 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox cbColorSet; private System.Windows.Forms.Label label7; private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox behaviorGroupBox; + private System.Windows.Forms.CheckBox alwaysExecuteSelectedStatementCheckBox; } } \ No newline at end of file diff --git a/OptionsForm.cs b/OptionsForm.cs index 1414e95..f4b3a44 100644 --- a/OptionsForm.cs +++ b/OptionsForm.cs @@ -70,6 +70,7 @@ private void SetCultureTexts() groupBox2.Text = GlobalText.GetValue("UserDefined"); btnOk.Text = GlobalText.GetValue("Ok"); btnCancel.Text = GlobalText.GetValue("Cancel"); + behaviorGroupBox.Text = GlobalText.GetValue("Colors"); } private void comboBox_SelectedIndexChanged(object sender, EventArgs e) @@ -211,5 +212,10 @@ private void cbColorSet_SelectedIndexChanged(object sender, EventArgs e) label1.ForeColor = label3.ForeColor = dataGrid.DefaultCellStyle.ForeColor; label2.ForeColor = label4.ForeColor = dataGrid.AlternatingRowsDefaultCellStyle.ForeColor; } + + private void alwaysExecuteSelectedStatementCheckBox_CheckedChanged(object sender, EventArgs e) + { + settings.OmitSelectedTextExecutionPopup = alwaysExecuteSelectedStatementCheckBox.Checked; + } } } diff --git a/OptionsForm.resx b/OptionsForm.resx index 2f1895d..c1eb6fd 100644 --- a/OptionsForm.resx +++ b/OptionsForm.resx @@ -120,82 +120,82 @@ - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAy1JREFUOE8dzFFs - EwUcwOGrD9UHU1/OB6kaU0z0TJDTLDnBWNBwSvCII4czHBM5hxxmC8zpEJUH28JG1EWmbjvYoJu4guwQ - yW6JazCshjkbxWqEhjjrw+yD2ERMTTQNSX/+48P3+inNZRGaW8RnEf78O8KxZgRT3NK8g0hzj1gg8usN - Iv1NblrRRI80yYjFyA2aka9RGndHaTgiiPLH9ShjjShPiVsbdxFt7BHzRH/+l2h/g5tXNng42iAjrkb/ - oRG9iFK/N0a9XZyO8dvvMY7WY2wQan05sXq3mCN25S9ifXVua6ljxOpkxE+x69Rjcyg1TaX2gjipUllS - 8WsqG8Wy2v2otR7xJeoP11D7aty+qsajao2M+F69Rk09j1JdGae6XUzGufpLnJFqnE3inuqDxKs9Ypb4 - t0vE+6rc+ViVtfEqGVGML1GNf4FSaUlQ6RAfJ/jxSoLhSoLN4r5KC4nKq2KGxPwiiYMVlj9RYV2iQlpc - TCxSSYQo5dUa5ZfEuMZ3JY2PyhrPiRXlVWjlXnEObe4y2sEyDzxZZr1WJi0uaJcpa+dQSmt1Sp4Y05n/ - RueDks5W0VJag17qFWfQ85fQD5R46OkSG/USaTGrX6KkByhF06D4sjhqcOErg8NFg21idXEdRnGv+BRj - ZgHjQJF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W5rqWPE6mTET7Hr1GNzKDVNpfaCOKlSWVLxayobxbLa/ai1HvEl + 6g/XUPtq3L6qxqNqjYz4Xr1GTT2PUl0Zp7pdTMa5+kuckWqcTeKe6oPEqz1ilvi3S8T7qtz5WJW18SoZ + UYwvUY1/gVJpSVDpEB8n+PFKguFKgs3ivkoLicqrYobE/CKJgxWWP1FhXaJCWlxMLFJJhCjl1Rrll8S4 + xncljY/KGs+JFeVVaOVecQ5t7jLawTIPPFlmvVYmLS5olylr51BKa3VKnhjTmf9G54OSzlbRUlqDXuoV + Z9Dzl9APlHjo6RIb9RJpMatfoqQHKEXToPiyOGpw4SuDw0WDbWJ1cR1Gca/4FGNmAeNAkUdai2wyiqRF + aCxQNE6hFDYkKXQKP8ns+STvF5K44vHCBpKF18Ukyc/nSGYKrNlcoC1ZICXOJucoJD9Bybea5HeLIZPp + GZOBvMkOsT7fipnfJyYwp2YxM3nMLXkcM09KnDZnyZvjKGGbRdgtPrQ4c9bivdBil3gmbMMK3xDHsHLT + WJkQ6/mQbVZISkxa04TWGErQbhP0iMM2J0/ZvBPYdIpng63YwZviCPbEFHY6wH4xoMMOSIlxe4rAPoKS + cx1yr4kBh4kTDodyDrtFe247Tu4tMYQzNomTzuHszOE5OVJi1Jkk5wyhZD2X7F7xrsvomEt/1uUV0ZHd + iZvdLwZxR47jprK4nVm63Cxv7xhl2D1O1h1E8bs8/H3ikMfQsEef79ErdvldeP5+MYA3OIKX8vG6fbo9 + //9g0BvB9wb4D8Btf08eNjC2AAAAAElFTkSuQmCC diff --git a/Settings.cs b/Settings.cs index eacd2e0..2e72278 100644 --- a/Settings.cs +++ b/Settings.cs @@ -30,18 +30,26 @@ namespace CompactView { public class Settings { - public int X { get; set; } - public int Y { get; set; } - public int Width { get; set; } - public int Height { get; set; } - public bool Maximized { get; set; } - public int TextColor1 { get; set; } - public int TextColor2 { get; set; } - public int BackColor1 { get; set; } - public int BackColor2 { get; set; } - public int ColorSet { get; set; } - public StringCollection RecentFiles { get; set; } - public int MaxRecentFiles { get; set; } + // Window + public int X; + public int Y; + public int Width; + public int Height; + public bool Maximized; + + // Appearance + public int TextColor1; + public int TextColor2; + public int BackColor1; + public int BackColor2; + public int ColorSet; + + // Behavior + public bool OmitSelectedTextExecutionPopup; + + // Recent Files + public StringCollection RecentFiles; + public int MaxRecentFiles; public Settings() { @@ -61,15 +69,6 @@ public bool AddToRecentFiles(string fileName) return true; } - public bool RemoveFromRecentFiles(string fileName) - { - int i = RecentFiles.IndexOf(fileName); - bool ok = i >= 0; - if (ok) - RecentFiles.RemoveAt(i); - return ok; - } - private string FileName { get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName + @"\Settings.xml"); } @@ -93,26 +92,19 @@ public void Load() return; DataRow row = table.Rows[0]; - if (table.Columns.Contains("X")) - X = row.Field("X"); - if (table.Columns.Contains("Y")) - Y = row.Field("Y"); - if (table.Columns.Contains("Width")) - Width = row.Field("Width"); - if (table.Columns.Contains("Height")) - Height = row.Field("Height"); - if (table.Columns.Contains("Maximized")) - Maximized = row.Field("Maximized"); - if (table.Columns.Contains("TextColor1")) - TextColor1 = row.Field("TextColor1"); - if (table.Columns.Contains("TextColor2")) - TextColor2 = row.Field("TextColor2"); - if (table.Columns.Contains("BackColor1")) - BackColor1 = row.Field("BackColor1"); - if (table.Columns.Contains("BackColor2")) - BackColor2 = row.Field("BackColor2"); - if (table.Columns.Contains("ColorSet")) - ColorSet = row.Field("ColorSet"); + table.ReadField(row, "X", ref X); + table.ReadField(row, "Y", ref Y); + table.ReadField(row, "Width", ref Width); + table.ReadField(row, "Height", ref Height); + table.ReadField(row, "Maximized", ref Maximized); + + table.ReadField(row, "TextColor1", ref TextColor1); + table.ReadField(row, "TextColor2", ref TextColor2); + table.ReadField(row, "BackColor1", ref BackColor1); + table.ReadField(row, "BackColor2", ref BackColor2); + table.ReadField(row, "ColorSet", ref ColorSet); + + table.ReadField(row, nameof(OmitSelectedTextExecutionPopup), ref OmitSelectedTextExecutionPopup); RecentFiles.Clear(); for (int i = 1; i <= MaxRecentFiles; i++) @@ -125,16 +117,21 @@ public void Load() public void Save() { var table = new DataTable("Settings"); + table.Columns.Add("X", typeof(int)); table.Columns.Add("Y", typeof(int)); table.Columns.Add("Width", typeof(int)); table.Columns.Add("Height", typeof(int)); table.Columns.Add("Maximized", typeof(bool)); + table.Columns.Add("TextColor1", typeof(int)); table.Columns.Add("TextColor2", typeof(int)); table.Columns.Add("BackColor1", typeof(int)); table.Columns.Add("BackColor2", typeof(int)); table.Columns.Add("ColorSet", typeof(int)); + + table.Columns.Add(nameof(OmitSelectedTextExecutionPopup), typeof(bool)); + for (int i = 1; i <= RecentFiles.Count; i++) table.Columns.Add($"RecentFiles{i}", typeof(string)); @@ -144,13 +141,18 @@ public void Save() row[2] = Width; row[3] = Height; row[4] = Maximized; + row[5] = TextColor1; row[6] = TextColor2; row[7] = BackColor1; row[8] = BackColor2; row[9] = ColorSet; + + row[10] = OmitSelectedTextExecutionPopup; + for (int i = 0; i < RecentFiles.Count; i++) - row[i + 10] = RecentFiles[i]; + row[i + 11] = RecentFiles[i]; + table.Rows.Add(row); try