#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 { /// The new file form. public partial class NewFileForm : Form { /// The _file editor resolver. private readonly IFileEditorResolver _fileEditorResolver; /// Initializes a new instance of the class. /// The file editor resolver. public NewFileForm(IFileEditorResolver fileEditorResolver) { InitializeComponent(); _fileEditorResolver = fileEditorResolver; } /// Gets FileEditorDescriptor. public FileEditorDescriptor FileEditorDescriptor { get { return lstFileTypes.SelectedItem as FileEditorDescriptor; } } /// Gets a value indicating whether IsValid. public bool IsValid { get { return lstFileTypes.SelectedItem != null; } } /// The do ok. private void DoOK() { DialogResult = DialogResult.OK; Close(); } /// The new file form_ load. /// The sender. /// The e. private void NewFileForm_Load(object sender, EventArgs e) { lstFileTypes.DataSource = _fileEditorResolver.GetFileTypes(); } /// The btn o k_ click. /// The sender. /// The e. private void btnOK_Click(object sender, EventArgs e) { DoOK(); } /// The lst file types_ double click. /// The sender. /// The e. private void lstFileTypes_DoubleClick(object sender, EventArgs e) { if (IsValid) { DoOK(); } } /// The lst file types_ selected value changed. /// The sender. /// The e. private void lstFileTypes_SelectedValueChanged(object sender, EventArgs e) { btnOK.Enabled = IsValid; } } }