-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformToolOptions.cs
75 lines (67 loc) · 1.89 KB
/
TransformToolOptions.cs
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
using System;
using System.Windows.Forms;
using Caravel.Core.Entity;
namespace CaravelEditor
{
public partial class TransformToolOptions : UserControl
{
private EditorApp m_EditorApp;
private Cv_Entity m_EditorCamera;
public TransformToolOptions()
{
InitializeComponent();
}
public void Initialize(EditorApp app)
{
if (m_EditorApp != null)
{
return;
}
m_EditorApp = app;
stepXTextBox.Text = "1";
stepYTextBox.Text = "1";
m_EditorApp.EditorLogic.EntityDragStepX = 1;
m_EditorApp.EditorLogic.EntityDragStepY = 1;
}
private void TextBoxChanged(object sender, EventArgs e)
{
TextBox textBox = (TextBox)sender;
int step;
if (int.TryParse(textBox.Text, out step))
{
if (step < 0)
{
step = -step;
textBox.Text = step.ToString();
}
else if (step == 0)
{
step = 1;
textBox.Text = step.ToString();
}
}
else
{
step = 1;
textBox.Text = step.ToString();
}
if (textBox == stepXTextBox)
{
m_EditorApp.EditorLogic.EntityDragStepX = step;
}
else if (textBox == stepYTextBox)
{
m_EditorApp.EditorLogic.EntityDragStepY = step;
}
}
private void TextBoxOnKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TextBoxChanged(sender, e);
e.Handled = true;
e.SuppressKeyPress = true;
}
}
}
}