-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCurSaveConfigWidget.cs
129 lines (118 loc) · 4.37 KB
/
CurSaveConfigWidget.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
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
// Decompiled with JetBrains decompiler
// Type: PaintDotNet.Data.CurSaveConfigWidget
// Assembly: IcoCur, Version=4.0.1.0, Culture=neutral, PublicKeyToken=null
// MVID: EEB2FED8-625F-4555-8E27-7F881F458B17
// Assembly location: C:\src\cs\Paint.net\IcoCur.dll
using System;
using System.Drawing;
using System.Windows.Forms;
using PaintDotNet;
namespace IcoCur;
internal class CurSaveConfigWidget : SaveConfigWidget
{
private Label label1;
private NumericUpDown XUpDown;
private Label label2;
private RadioButton Bit32RBtn;
private RadioButton Bit8RBtn;
private NumericUpDown YUpDown;
public CurSaveConfigWidget() => InitializeComponent();
protected override void InitFileType() => fileType = new PDNIcoCurFormat();
protected override void InitTokenFromWidget()
{
((CurSaveConfigToken)Token).HotSpot.X = (int)XUpDown.Value;
((CurSaveConfigToken)Token).HotSpot.Y = (int)YUpDown.Value;
((CurSaveConfigToken)Token).EightBit = Bit8RBtn.Checked;
}
protected override void InitWidgetFromToken(SaveConfigToken token)
{
CurSaveConfigToken curSaveConfigToken = (CurSaveConfigToken)token;
XUpDown.Value = curSaveConfigToken.HotSpot.X;
YUpDown.Value = curSaveConfigToken.HotSpot.Y;
Bit8RBtn.Checked = curSaveConfigToken.EightBit;
Bit32RBtn.Checked = !curSaveConfigToken.EightBit;
}
private void InitializeComponent()
{
label1 = new Label();
XUpDown = new NumericUpDown();
label2 = new Label();
YUpDown = new NumericUpDown();
Bit32RBtn = new RadioButton();
Bit8RBtn = new RadioButton();
XUpDown.BeginInit();
YUpDown.BeginInit();
this.SuspendLayout();
label1.AutoSize = true;
label1.Location = new Point(3, 11);
label1.Name = "label1";
label1.Size = new Size(57, 13);
label1.TabIndex = 2;
label1.Text = "Hotspot X:";
XUpDown.Location = new Point(91, 11);
XUpDown.Maximum = new decimal(new int[4]
{
31,
0,
0,
0
});
XUpDown.Name = "XUpDown";
XUpDown.Size = new Size(56, 20);
XUpDown.TabIndex = 3;
XUpDown.ValueChanged += new EventHandler(HotSpotChange);
XUpDown.KeyPress += new KeyPressEventHandler(HotSpotKeyPress);
label2.AutoSize = true;
label2.Location = new Point(3, 36);
label2.Name = "label2";
label2.Size = new Size(57, 13);
label2.TabIndex = 4;
label2.Text = "Hotspot Y:";
YUpDown.Location = new Point(91, 37);
YUpDown.Maximum = new decimal(new int[4]
{
31,
0,
0,
0
});
YUpDown.Name = "YUpDown";
YUpDown.Size = new Size(56, 20);
YUpDown.TabIndex = 5;
YUpDown.ValueChanged += new EventHandler(HotSpotChange);
YUpDown.KeyPress += new KeyPressEventHandler(HotSpotKeyPress);
Bit32RBtn.AutoSize = true;
Bit32RBtn.Checked = true;
Bit32RBtn.Location = new Point(6, 76);
Bit32RBtn.Name = "Bit32RBtn";
Bit32RBtn.Size = new Size(51, 17);
Bit32RBtn.TabIndex = 6;
Bit32RBtn.TabStop = true;
Bit32RBtn.Text = "32-bit";
Bit32RBtn.UseVisualStyleBackColor = true;
Bit32RBtn.CheckedChanged += new EventHandler(DepthCheckChanged);
Bit8RBtn.AutoSize = true;
Bit8RBtn.Location = new Point(91, 76);
Bit8RBtn.Name = "Bit8RBtn";
Bit8RBtn.Size = new Size(45, 17);
Bit8RBtn.TabIndex = 7;
Bit8RBtn.Text = "8-bit";
Bit8RBtn.UseVisualStyleBackColor = true;
Bit8RBtn.CheckedChanged += new EventHandler(DepthCheckChanged);
this.AutoScaleDimensions = new SizeF(96f, 96f);
this.Controls.Add(Bit8RBtn);
this.Controls.Add(Bit32RBtn);
this.Controls.Add(YUpDown);
this.Controls.Add(label2);
this.Controls.Add(XUpDown);
this.Controls.Add(label1);
this.Name = nameof(CurSaveConfigWidget);
XUpDown.EndInit();
YUpDown.EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void HotSpotChange(object sender, EventArgs e) => UpdateToken();
private void HotSpotKeyPress(object sender, KeyPressEventArgs e) => UpdateToken();
private void DepthCheckChanged(object sender, EventArgs e) => UpdateToken();
}