forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoToDialog.cs
More file actions
215 lines (199 loc) · 7.93 KB
/
GoToDialog.cs
File metadata and controls
215 lines (199 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using System;
using System.Drawing;
using System.Windows.Forms;
using PluginCore.Localization;
using FlashDevelop.Helpers;
using PluginCore.Managers;
using PluginCore.Helpers;
using PluginCore;
namespace FlashDevelop.Dialogs
{
public class GoToDialog : Form
{
private System.Windows.Forms.Button lineButton;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button positionButton;
private System.Windows.Forms.TextBox lineTextBox;
private System.Windows.Forms.Label valueLabel;
public GoToDialog()
{
this.Owner = Globals.MainForm;
this.Font = Globals.Settings.DefaultFont;
this.InitializeComponent();
this.ApplyLocalizedTexts();
ScaleHelper.AdjustForHighDPI(this);
}
#region Windows Forms Designer Generated Code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lineTextBox = new System.Windows.Forms.TextBox();
this.positionButton = new System.Windows.Forms.Button();
this.valueLabel = new System.Windows.Forms.Label();
this.closeButton = new System.Windows.Forms.Button();
this.lineButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lineTextBox
//
this.lineTextBox.Location = new System.Drawing.Point(52, 10);
this.lineTextBox.Name = "lineTextBox";
this.lineTextBox.Size = new System.Drawing.Size(150, 21);
this.lineTextBox.TabIndex = 1;
//
// positionButton
//
this.positionButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.positionButton.Location = new System.Drawing.Point(79, 38);
this.positionButton.Name = "positionButton";
this.positionButton.Size = new System.Drawing.Size(59, 23);
this.positionButton.TabIndex = 3;
this.positionButton.Text = "&Position";
this.positionButton.Click += new System.EventHandler(this.PositionButtonClick);
//
// valueLabel
//
this.valueLabel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.valueLabel.Location = new System.Drawing.Point(15, 12);
this.valueLabel.Name = "valueLabel";
this.valueLabel.Size = new System.Drawing.Size(37, 15);
this.valueLabel.TabIndex = 0;
this.valueLabel.Text = "Value:";
//
// closeButton
//
this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.closeButton.Location = new System.Drawing.Point(150, 38);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(53, 23);
this.closeButton.TabIndex = 4;
this.closeButton.Text = "&Close";
this.closeButton.Click += new System.EventHandler(this.CancelButtonClick);
//
// lineButton
//
this.lineButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.lineButton.Location = new System.Drawing.Point(12, 38);
this.lineButton.Name = "lineButton";
this.lineButton.Size = new System.Drawing.Size(55, 23);
this.lineButton.TabIndex = 2;
this.lineButton.Text = "&Line";
this.lineButton.Click += new System.EventHandler(this.LineButtonClick);
//
// GoToDialog
//
this.AcceptButton = this.lineButton;
this.CancelButton = this.closeButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(216, 71);
this.Controls.Add(this.lineButton);
this.Controls.Add(this.positionButton);
this.Controls.Add(this.closeButton);
this.Controls.Add(this.lineTextBox);
this.Controls.Add(this.valueLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GoToDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = " Goto";
this.VisibleChanged += new System.EventHandler(this.VisibleChange);
this.Closing += new System.ComponentModel.CancelEventHandler(this.DialogClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
#region Methods And Event Handlers
/// <summary>
/// Applies the localized texts to the form
/// </summary>
private void ApplyLocalizedTexts()
{
this.lineButton.Text = TextHelper.GetString("Label.Line");
this.positionButton.Text = TextHelper.GetString("Label.Position");
this.closeButton.Text = TextHelper.GetString("Label.Close");
this.valueLabel.Text = TextHelper.GetString("Info.Value");
this.Text = " " + TextHelper.GetString("Title.GoToDialog");
}
/// <summary>
/// Selects the textfield's text
/// </summary>
private void SelectLineTextBox()
{
this.lineTextBox.Select();
this.lineTextBox.SelectAll();
}
/// <summary>
/// Some event handling when showing the form
/// </summary>
private void VisibleChange(Object sender, System.EventArgs e)
{
if (this.Visible)
{
this.SelectLineTextBox();
this.CenterToParent();
}
}
/// <summary>
/// Hides only the dialog when user closes it
/// </summary>
private void DialogClosing(Object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
Globals.CurrentDocument.Activate();
this.Hide();
}
/// <summary>
/// Moves the cursor to the specified line
/// </summary>
private void LineButtonClick(Object sender, System.EventArgs e)
{
if (Globals.SciControl == null) return;
try
{
Int32 line = Convert.ToInt32(this.lineTextBox.Text) - 1;
Globals.SciControl.EnsureVisible(line);
Globals.SciControl.GotoLineIndent(line);
this.Close();
}
catch
{
String message = TextHelper.GetString("Info.GiveProperInt32Value");
ErrorManager.ShowInfo(message);
}
}
/// <summary>
/// Moves the cursor to the specified position
/// </summary>
private void PositionButtonClick(Object sender, System.EventArgs e)
{
if (Globals.SciControl == null) return;
try
{
Int32 pos = Convert.ToInt32(this.lineTextBox.Text) - 1;
Int32 line = Globals.SciControl.LineFromPosition(pos);
Globals.SciControl.EnsureVisible(line);
Globals.SciControl.GotoPos(pos);
this.Close();
}
catch
{
String message = TextHelper.GetString("Info.GiveProperInt32Value");
ErrorManager.ShowInfo(message);
}
}
/// <summary>
/// Hides the goto dialog
/// </summary>
private void CancelButtonClick(Object sender, System.EventArgs e)
{
this.Close();
}
#endregion
}
}