120 lines
2.6 KiB
C#
120 lines
2.6 KiB
C#
|
#region Using Directives
|
|||
|
|
|||
|
using ryCommon;
|
|||
|
using ScintillaNET;
|
|||
|
using System;
|
|||
|
using System.Windows.Forms;
|
|||
|
using WeifenLuo.WinFormsUI.Docking;
|
|||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endregion Using Directives
|
|||
|
|
|||
|
namespace ScintillaNET_FindReplaceDialog
|
|||
|
{
|
|||
|
public class GoTo
|
|||
|
{
|
|||
|
private Scintilla _scintilla=null;
|
|||
|
private GoToDialog _window;
|
|||
|
|
|||
|
#region Methods
|
|||
|
|
|||
|
public void Line(int number)
|
|||
|
{
|
|||
|
if (_scintilla == null) { return; }
|
|||
|
_scintilla.Lines[number].Goto();
|
|||
|
}
|
|||
|
|
|||
|
public void Position(int pos)
|
|||
|
{
|
|||
|
if (_scintilla == null) { return; }
|
|||
|
_scintilla.GotoPosition(pos);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowGoToDialog()
|
|||
|
{
|
|||
|
if (_scintilla == null) { return; }
|
|||
|
//GoToDialog gd = new GoToDialog();
|
|||
|
GoToDialog gd = _window;
|
|||
|
|
|||
|
gd.CurrentLineNumber = _scintilla.CurrentLine;
|
|||
|
gd.MaximumLineNumber = _scintilla.Lines.Count;
|
|||
|
gd.Scintilla = _scintilla;
|
|||
|
if (!_window.Visible)
|
|||
|
{
|
|||
|
var form = _scintilla.FindForm();
|
|||
|
if (form != null)
|
|||
|
{
|
|||
|
if (form is DockContent dc)
|
|||
|
{
|
|||
|
var parent = dc.DockPanel.FindForm();
|
|||
|
_window.StartPosition = FormStartPosition.Manual;
|
|||
|
_window.Location = new System.Drawing.Point(parent.Left+(parent.Width - _window.Width) / 2, parent.Top+(parent.Height - _window.Height) / 2);
|
|||
|
_window.Show(parent);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_window.Show(form);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_window.StartPosition = FormStartPosition.CenterScreen;
|
|||
|
_window.Show();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//_window.ShowDialog(_scintilla.FindForm());
|
|||
|
//_window.Show(_scintilla.FindForm());
|
|||
|
|
|||
|
//if (gd.ShowDialog() == DialogResult.OK)
|
|||
|
//Line(gd.GotoLineNumber);
|
|||
|
|
|||
|
//gd.ShowDialog();
|
|||
|
//gd.Show();
|
|||
|
|
|||
|
_scintilla.Focus();
|
|||
|
}
|
|||
|
|
|||
|
#endregion Methods
|
|||
|
|
|||
|
#region Constructors
|
|||
|
|
|||
|
protected virtual GoToDialog CreateWindowInstance()
|
|||
|
{
|
|||
|
return new GoToDialog();
|
|||
|
}
|
|||
|
|
|||
|
public GoTo(Scintilla scintilla)
|
|||
|
{
|
|||
|
_scintilla = scintilla;
|
|||
|
_window = CreateWindowInstance();
|
|||
|
_window.Scintilla = scintilla;
|
|||
|
}
|
|||
|
public GoTo()
|
|||
|
{
|
|||
|
_scintilla = null;
|
|||
|
_window = CreateWindowInstance();
|
|||
|
_window.Scintilla = null;
|
|||
|
}
|
|||
|
public Scintilla Scintilla
|
|||
|
{
|
|||
|
get { return _scintilla; }
|
|||
|
set {
|
|||
|
_scintilla = value;
|
|||
|
_window.Scintilla = value;
|
|||
|
if (value != null)
|
|||
|
{
|
|||
|
GoToDialog gd = _window;
|
|||
|
gd.CurrentLineNumber = _scintilla.CurrentLine;
|
|||
|
gd.MaximumLineNumber = _scintilla.Lines.Count;
|
|||
|
gd.Scintilla = _scintilla;
|
|||
|
gd.UpdateUI();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion Constructors
|
|||
|
}
|
|||
|
}
|