FrmLabelEdit.cs
4.3 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
using CodeLibrary;
using DeviceLibrary;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using JsonHelper = OnlineStore.Common.JsonHelper;
namespace PrintLabel
{
public partial class FrmLabelEdit : Form
{
public FrmLabelEdit()
{
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;
loadCames();
}
void loadCames()
{
comboBox1.Items.AddRange(CodeManager.cameraNameList.ToArray());
if (comboBox1.Items.Count > 0)
comboBox1.SelectedIndex = 0;
}
string filename = "";
List<CodeInfo> codeinfo = null;
Dictionary<string, string> keyword;
bool[] amatch = null;
Dictionary<string, int> newpointanlge;
private void btnAcquire_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(delegate
{
(codeinfo, keyword, filename, newpointanlge) = CodeManager.CameraScan(new List<string>() { comboBox1.SelectedItem.ToString() },7);
if (string.IsNullOrEmpty(filename)) return;
pictureBox1.Image = new Bitmap(filename);
});
}
LabelParam labelparam = new LabelParam();
private void btnCalculate_Click(object sender, EventArgs e)
{
//if (string.IsNullOrEmpty(filename)) return;
//labelparam.BitmapFilename = filename;
//labelparam.LabelContent = new LabelContent();
//labelparam.LabelContent.codeInfos = codeinfo;
//labelparam.LabelContent.PN = textBox2.Text;
//labelparam.TrayCenterInImg_X = int.Parse(txtX.Text);
//labelparam.TrayCenterInImg_Y = int.Parse(txtY.Text);
//labelparam.LabelInImgAngle = int.Parse(txtLabel_R_Angle_Diff.Text);
//labelparam.RelativeAngle = int.Parse(txtRelativeAngle.Text);
//(string resFile, int codeAngle, int labelAngle, int needRound) res = LabelManager.CalcLabelAngle(labelparam, true);
//lblCodePos.Text = $"二维码角度:{res.codeAngle}°";
//lblAngle.Text = $"旋转角度:{res.needRound}°";
//lblLabelAngle.Text = $"标签角度:{res.labelAngle}°";
//pictureBox2.Image = new Bitmap(res.resFile);
//textBox1.Text = JsonHelper.SerializeObject(codeinfo);
}
private void load(int side = 0)
{
if (side == 0)
{
//txtX.Text = ConfigAppSettings.GetValue(Setting_Init.TrayCenterInImg_X_CamA,"2600");
//txtY.Text = ConfigAppSettings.GetValue(Setting_Init.TrayCenterInImg_Y_CamA,"1700");
//txtLabel_R_Angle_Diff.Text = ConfigAppSettings.GetValue(Setting_Init.LabelInImgAngle_CamA,"190");
//txtRelativeAngle.Text = ConfigAppSettings.GetValue(Setting_Init.RelativeAngle_CamA,"150");
}
}
private void save(int side = 0)
{
//if (side == 0)
//{
// ConfigAppSettings.SaveValue(Setting_Init.TrayCenterInImg_X_CamA, txtX.Text);
// ConfigAppSettings.SaveValue(Setting_Init.TrayCenterInImg_Y_CamA, txtY.Text);
// ConfigAppSettings.SaveValue(Setting_Init.LabelInImgAngle_CamA, txtLabel_R_Angle_Diff.Text);
// ConfigAppSettings.SaveValue(Setting_Init.RelativeAngle_CamA, txtRelativeAngle.Text);
//}
//else if (side == 1)
//{
// ConfigAppSettings.SaveValue(Setting_Init.TrayCenterInImg_X_CamB, txtX.Text);
// ConfigAppSettings.SaveValue(Setting_Init.TrayCenterInImg_Y_CamB, txtY.Text);
// ConfigAppSettings.SaveValue(Setting_Init.LabelInImgAngle_CamB, txtLabel_R_Angle_Diff.Text);
// ConfigAppSettings.SaveValue(Setting_Init.RelativeAngle_CamB, txtRelativeAngle.Text);
//}
//else
// return;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
load(comboBox1.SelectedIndex);
}
private void button1_Click(object sender, EventArgs e)
{
save(comboBox1.SelectedIndex);
}
}
}