forked from CANopenNode/CANopenEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeMappingWidth.cs
More file actions
69 lines (64 loc) · 1.91 KB
/
ChangeMappingWidth.cs
File metadata and controls
69 lines (64 loc) · 1.91 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ODEditor
{
/// <summary>
/// A small dialog for PDO mapping width adjustments
/// </summary>
public partial class ChangeMappingWidth : Form
{
public int selected_width = 1;
private int default_width = 1;
public ChangeMappingWidth(int current_width, int max_width)
{
InitializeComponent();
// Validate params
if (current_width < 1)
current_width = 1;
if (max_width < 1)
max_width = 1;
if (current_width > max_width)
current_width = max_width;
updown_newwidth.Maximum = max_width;
updown_newwidth.Value = current_width;
selected_width = current_width;
default_width = current_width;
}
private void button_ok_Click(object sender, EventArgs e)
{
selected_width = (int)updown_newwidth.Value;
if (selected_width != default_width)
{
this.DialogResult = DialogResult.OK;
}
else
{
this.DialogResult = DialogResult.Cancel;
}
this.Close();
}
private void button_cancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void ChangeMappingWidth_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.button_ok_Click(null, null);
}
else if (e.KeyCode == Keys.Escape)
{
this.button_cancel_Click(null, null);
}
}
}
}