#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.Media; using System.Windows.Forms; using MiniSqlQuery.Core; namespace MiniSqlQuery.PlugIns.SearchTools { /// The go to line form. public partial class GoToLineForm : Form { /// The _services. private readonly IApplicationServices _services; /// Initializes a new instance of the class. /// The services. public GoToLineForm(IApplicationServices services) { _services = services; InitializeComponent(); } /// Gets or sets LineValue. public string LineValue { get { return txtLine.Text; } set { txtLine.Text = value; } } /// The go to line form_ load. /// The sender. /// The e. private void GoToLineForm_Load(object sender, EventArgs e) { INavigatableDocument navDoc = _services.HostWindow.ActiveChildForm as INavigatableDocument; if (navDoc != null) { LineValue = (navDoc.CursorLine + 1).ToString(); Text = string.Format("{0} (1-{1})", Text, navDoc.TotalLines); } } /// The btn ok_ click. /// The sender. /// The e. private void btnOk_Click(object sender, EventArgs e) { INavigatableDocument navDoc = _services.HostWindow.ActiveChildForm as INavigatableDocument; if (navDoc != null) { int line; if (int.TryParse(LineValue, out line)) { int column = 0; line = Math.Abs(line - 1); // todo - copy column? if (navDoc.SetCursorByLocation(line, column)) { Close(); } } // otherwise SystemSounds.Beep.Play(); } } } }