miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 1 changed files with 82 additions and 0 deletions.
Added +82 -0
Added +82 -0
diff --git a/minisqlquery-master/src/MiniSqlQuery/NewFileForm.cs b/minisqlquery-master/src/MiniSqlQuery/NewFileForm.cs
new file mode 100644
index 0000000..bac78a5
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery/NewFileForm.cs
@@ -0,0 +1,82 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using System;
+using System.Windows.Forms;
+using MiniSqlQuery.Core;
+
+namespace MiniSqlQuery
+{
+    /// <summary>The new file form.</summary>
+    public partial class NewFileForm : Form
+    {
+        /// <summary>The _file editor resolver.</summary>
+        private readonly IFileEditorResolver _fileEditorResolver;
+
+        /// <summary>Initializes a new instance of the <see cref="NewFileForm"/> class.</summary>
+        /// <param name="fileEditorResolver">The file editor resolver.</param>
+        public NewFileForm(IFileEditorResolver fileEditorResolver)
+        {
+            InitializeComponent();
+            _fileEditorResolver = fileEditorResolver;
+        }
+
+        /// <summary>Gets FileEditorDescriptor.</summary>
+        public FileEditorDescriptor FileEditorDescriptor
+        {
+            get { return lstFileTypes.SelectedItem as FileEditorDescriptor; }
+        }
+
+        /// <summary>Gets a value indicating whether IsValid.</summary>
+        public bool IsValid
+        {
+            get { return lstFileTypes.SelectedItem != null; }
+        }
+
+        /// <summary>The do ok.</summary>
+        private void DoOK()
+        {
+            DialogResult = DialogResult.OK;
+            Close();
+        }
+
+        /// <summary>The new file form_ load.</summary>
+        /// <param name="sender">The sender.</param>
+        /// <param name="e">The e.</param>
+        private void NewFileForm_Load(object sender, EventArgs e)
+        {
+            lstFileTypes.DataSource = _fileEditorResolver.GetFileTypes();
+        }
+
+        /// <summary>The btn o k_ click.</summary>
+        /// <param name="sender">The sender.</param>
+        /// <param name="e">The e.</param>
+        private void btnOK_Click(object sender, EventArgs e)
+        {
+            DoOK();
+        }
+
+        /// <summary>The lst file types_ double click.</summary>
+        /// <param name="sender">The sender.</param>
+        /// <param name="e">The e.</param>
+        private void lstFileTypes_DoubleClick(object sender, EventArgs e)
+        {
+            if (IsValid)
+            {
+                DoOK();
+            }
+        }
+
+        /// <summary>The lst file types_ selected value changed.</summary>
+        /// <param name="sender">The sender.</param>
+        /// <param name="e">The e.</param>
+        private void lstFileTypes_SelectedValueChanged(object sender, EventArgs e)
+        {
+            btnOK.Enabled = IsValid;
+        }
+    }
+}
\ No newline at end of file