回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,180 +1,178 @@
|
|
1
|
-
案1 `InkCollector`を`Panel`にでも引っ掛けて自前で制御
|
2
|
-
好きなタイミングで手書き認識できる。
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
using
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
{
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
inkCollector =
|
24
|
-
inkCollector.
|
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
|
-
/// <summary>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
/// <summary>
|
70
|
-
///
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
///
|
85
|
-
///
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
this.
|
91
|
-
this.
|
92
|
-
this.
|
93
|
-
this.
|
94
|
-
this.
|
95
|
-
this.panel2
|
96
|
-
this.
|
97
|
-
|
98
|
-
|
99
|
-
//
|
100
|
-
|
101
|
-
|
102
|
-
this.inkEdit1.
|
103
|
-
this.inkEdit1.
|
104
|
-
this.inkEdit1.
|
105
|
-
this.inkEdit1.
|
106
|
-
this.inkEdit1.
|
107
|
-
this.inkEdit1.
|
108
|
-
this.inkEdit1.
|
109
|
-
this.inkEdit1.
|
110
|
-
this.inkEdit1.
|
111
|
-
this.inkEdit1.
|
112
|
-
|
113
|
-
|
114
|
-
//
|
115
|
-
|
116
|
-
|
117
|
-
this.panel1.
|
118
|
-
this.panel1.
|
119
|
-
this.panel1.
|
120
|
-
this.panel1.
|
121
|
-
|
122
|
-
|
123
|
-
//
|
124
|
-
|
125
|
-
|
126
|
-
this.textBox1.
|
127
|
-
this.textBox1.
|
128
|
-
|
129
|
-
|
130
|
-
//
|
131
|
-
|
132
|
-
|
133
|
-
this.textBox2.
|
134
|
-
this.textBox2.
|
135
|
-
|
136
|
-
|
137
|
-
//
|
138
|
-
|
139
|
-
|
140
|
-
this.panel2.
|
141
|
-
this.panel2.
|
142
|
-
this.panel2.
|
143
|
-
this.panel2.
|
144
|
-
|
145
|
-
|
146
|
-
//
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
//
|
152
|
-
|
153
|
-
|
154
|
-
this.
|
155
|
-
this.
|
156
|
-
this.
|
157
|
-
this.Controls.Add(this.
|
158
|
-
this.Controls.Add(this.
|
159
|
-
this.
|
160
|
-
this.
|
161
|
-
this.
|
162
|
-
this.
|
163
|
-
this.
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
private
|
172
|
-
private System.Windows.Forms.
|
173
|
-
private System.Windows.Forms.
|
174
|
-
private System.Windows.Forms.
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
}
|
179
|
-
```
|
1
|
+
* 案1 `InkCollector`を`Panel`にでも引っ掛けて自前で制御
|
2
|
+
好きなタイミングで手書き認識できる。
|
3
|
+
* 案2 `InkEdit`の上側を隠し`ReadOnly`に
|
4
|
+
バカバカしいが効果的。
|
5
|
+
|
6
|
+
```cs:Form1.cs
|
7
|
+
using System;
|
8
|
+
using System.Windows.Forms;
|
9
|
+
using Microsoft.Ink;
|
10
|
+
|
11
|
+
namespace Questions252021
|
12
|
+
{
|
13
|
+
public partial class Form1 : Form
|
14
|
+
{
|
15
|
+
private InkCollector inkCollector;
|
16
|
+
|
17
|
+
public Form1()
|
18
|
+
{
|
19
|
+
InitializeComponent();
|
20
|
+
|
21
|
+
inkCollector = new InkCollector(panel1);
|
22
|
+
inkCollector.CollectionMode = CollectionMode.InkOnly;
|
23
|
+
inkCollector.Enabled = true;
|
24
|
+
inkCollector.Stroke += InkCollector_Stroke;
|
25
|
+
}
|
26
|
+
|
27
|
+
private void InkCollector_Stroke(object sender, InkCollectorStrokeEventArgs e)
|
28
|
+
{
|
29
|
+
// なにか描かれたらタイマー再スタート
|
30
|
+
timer1.Stop();
|
31
|
+
timer1.Start();
|
32
|
+
}
|
33
|
+
|
34
|
+
private void Timer1_Tick(object sender, EventArgs e)
|
35
|
+
{
|
36
|
+
timer1.Stop();
|
37
|
+
|
38
|
+
// TextBoxに文字を挿入
|
39
|
+
textBox1.Paste(inkCollector.Ink.Strokes.ToString());
|
40
|
+
// 手書きのクリア
|
41
|
+
inkCollector.Ink.DeleteStrokes(inkCollector.Ink.Strokes);
|
42
|
+
// パネル再描画(クリア)
|
43
|
+
panel1.Refresh();
|
44
|
+
}
|
45
|
+
|
46
|
+
private void InkEdit1_TextChanged(object sender, EventArgs e)
|
47
|
+
{
|
48
|
+
// TextBoxに文字を挿入
|
49
|
+
textBox2.Paste(inkEdit1.Text);
|
50
|
+
// 手書きのクリア
|
51
|
+
inkEdit1.Text = "";
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
```cs:Form1.Designer.cs
|
58
|
+
namespace Questions252021
|
59
|
+
{
|
60
|
+
partial class Form1
|
61
|
+
{
|
62
|
+
/// <summary>
|
63
|
+
/// 必要なデザイナー変数です。
|
64
|
+
/// </summary>
|
65
|
+
private System.ComponentModel.IContainer components = null;
|
66
|
+
|
67
|
+
/// <summary>
|
68
|
+
/// 使用中のリソースをすべてクリーンアップします。
|
69
|
+
/// </summary>
|
70
|
+
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
|
71
|
+
protected override void Dispose(bool disposing)
|
72
|
+
{
|
73
|
+
if(disposing && (components != null))
|
74
|
+
{
|
75
|
+
components.Dispose();
|
76
|
+
}
|
77
|
+
base.Dispose(disposing);
|
78
|
+
}
|
79
|
+
|
80
|
+
#region Windows フォーム デザイナーで生成されたコード
|
81
|
+
|
82
|
+
/// <summary>
|
83
|
+
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
|
84
|
+
/// コード エディターで変更しないでください。
|
85
|
+
/// </summary>
|
86
|
+
private void InitializeComponent()
|
87
|
+
{
|
88
|
+
this.components = new System.ComponentModel.Container();
|
89
|
+
this.inkEdit1 = new Microsoft.Ink.InkEdit();
|
90
|
+
this.panel1 = new System.Windows.Forms.Panel();
|
91
|
+
this.textBox1 = new System.Windows.Forms.TextBox();
|
92
|
+
this.textBox2 = new System.Windows.Forms.TextBox();
|
93
|
+
this.panel2 = new System.Windows.Forms.Panel();
|
94
|
+
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
95
|
+
this.panel2.SuspendLayout();
|
96
|
+
this.SuspendLayout();
|
97
|
+
//
|
98
|
+
// inkEdit1
|
99
|
+
//
|
100
|
+
this.inkEdit1.BackColor = System.Drawing.SystemColors.Window;
|
101
|
+
this.inkEdit1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
102
|
+
this.inkEdit1.Cursor = System.Windows.Forms.Cursors.Default;
|
103
|
+
this.inkEdit1.InkMode = Microsoft.Ink.InkMode.Ink;
|
104
|
+
this.inkEdit1.Location = new System.Drawing.Point(0, -30);
|
105
|
+
this.inkEdit1.Name = "inkEdit1";
|
106
|
+
this.inkEdit1.ReadOnly = true;
|
107
|
+
this.inkEdit1.Size = new System.Drawing.Size(400, 130);
|
108
|
+
this.inkEdit1.TabIndex = 0;
|
109
|
+
this.inkEdit1.Text = "";
|
110
|
+
this.inkEdit1.UseMouseForInput = true;
|
111
|
+
this.inkEdit1.TextChanged += new System.EventHandler(this.InkEdit1_TextChanged);
|
112
|
+
//
|
113
|
+
// panel1
|
114
|
+
//
|
115
|
+
this.panel1.BackColor = System.Drawing.SystemColors.Window;
|
116
|
+
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
117
|
+
this.panel1.Location = new System.Drawing.Point(12, 38);
|
118
|
+
this.panel1.Name = "panel1";
|
119
|
+
this.panel1.Size = new System.Drawing.Size(400, 100);
|
120
|
+
this.panel1.TabIndex = 4;
|
121
|
+
//
|
122
|
+
// textBox1
|
123
|
+
//
|
124
|
+
this.textBox1.Location = new System.Drawing.Point(13, 13);
|
125
|
+
this.textBox1.Name = "textBox1";
|
126
|
+
this.textBox1.Size = new System.Drawing.Size(266, 19);
|
127
|
+
this.textBox1.TabIndex = 5;
|
128
|
+
//
|
129
|
+
// textBox2
|
130
|
+
//
|
131
|
+
this.textBox2.Location = new System.Drawing.Point(14, 183);
|
132
|
+
this.textBox2.Name = "textBox2";
|
133
|
+
this.textBox2.Size = new System.Drawing.Size(266, 19);
|
134
|
+
this.textBox2.TabIndex = 6;
|
135
|
+
//
|
136
|
+
// panel2
|
137
|
+
//
|
138
|
+
this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
139
|
+
this.panel2.Controls.Add(this.inkEdit1);
|
140
|
+
this.panel2.Location = new System.Drawing.Point(12, 208);
|
141
|
+
this.panel2.Name = "panel2";
|
142
|
+
this.panel2.Size = new System.Drawing.Size(400, 100);
|
143
|
+
this.panel2.TabIndex = 7;
|
144
|
+
//
|
145
|
+
// timer1
|
146
|
+
//
|
147
|
+
this.timer1.Interval = 2000;
|
148
|
+
this.timer1.Tick += new System.EventHandler(this.Timer1_Tick);
|
149
|
+
//
|
150
|
+
// Form1
|
151
|
+
//
|
152
|
+
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
153
|
+
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
154
|
+
this.ClientSize = new System.Drawing.Size(422, 320);
|
155
|
+
this.Controls.Add(this.panel2);
|
156
|
+
this.Controls.Add(this.textBox2);
|
157
|
+
this.Controls.Add(this.textBox1);
|
158
|
+
this.Controls.Add(this.panel1);
|
159
|
+
this.Name = "Form1";
|
160
|
+
this.Text = "Form1";
|
161
|
+
this.panel2.ResumeLayout(false);
|
162
|
+
this.ResumeLayout(false);
|
163
|
+
this.PerformLayout();
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
#endregion
|
168
|
+
|
169
|
+
private Microsoft.Ink.InkEdit inkEdit1;
|
170
|
+
private System.Windows.Forms.Panel panel1;
|
171
|
+
private System.Windows.Forms.TextBox textBox1;
|
172
|
+
private System.Windows.Forms.TextBox textBox2;
|
173
|
+
private System.Windows.Forms.Panel panel2;
|
174
|
+
private System.Windows.Forms.Timer timer1;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
```
|
180
178
|
雑なので何か穴がありそう^^;
|