SettingControl.cs
6.6 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using CodeLibrary;
using ConfigHelper;
using DeviceLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoScanAndLabel
{
public partial class SettingControl : UserControl
{
public SettingControl()
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
//chbAutoRun.Enabled = false;
chbAutoRun.Checked = Convert.ToBoolean(ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun));
this.chbAutoRun.CheckedChanged += new System.EventHandler(this.chbAutoRun_CheckedChanged);
//chbAutoRun.Enabled = true;
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (!state)
return;
cb_printerselect.Items.Clear();
cb_labelselect.Items.Clear();
foreach (string sPrint in System.Drawing.Printing.PrinterSettings.InstalledPrinters)//获取所有打印机名称
{
cb_printerselect.Items.Add(sPrint);
}
if (RobotManage.printerHelper != null)
{
foreach (string labelname in RobotManage.printerHelper.GetLabelList())
{
cb_labelselect.Items.Add(labelname);
}
}
string PrintName = ConfigHelper.Config.Get(Setting_Init.PrinterName);
string labelName = ConfigHelper.Config.Get(Setting_Init.LabelName);
cb_printerselect.Text = PrintName;
cb_labelselect.Text = labelName;
}
private void SettingControl_Load(object sender, EventArgs e)
{
}
private void cb_printerselect_SelectedIndexChanged(object sender, EventArgs e)
{
Config.Set(Setting_Init.PrinterName, (sender as ComboBox).Text);
RobotManage.LoadPrintSetting();
}
private void cb_labelselect_SelectedIndexChanged(object sender, EventArgs e)
{
Config.Set(Setting_Init.LabelName, (sender as ComboBox).Text);
RobotManage.LoadPrintSetting();
}
private void btn_labeledit_Click(object sender, EventArgs e)
{
var keys = File.ReadAllLines("NeoScan\\Config\\MacroKey.txt");
//RobotManage.PrintBean.EditLabel();
PrintLabel.FrmLabel frmLabel = new PrintLabel.FrmLabel();
//crc.CurrLanguage = "";
frmLabel.Text = crc.GetString("FrmLabel_Text", "标签编辑");
crc.LanguageProcess(frmLabel, "FrmLabel");
frmLabel.KeyWord.AddRange(keys);
frmLabel.ShowDialog();
RobotManage_LoadFinishEvent(true, "");
RobotManage.LoadPrintSetting();
}
public static void AutoRun(string strName, bool value)
{
try
{
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//设置运行文件
startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
//设置启动参数
startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
//如果不是管理员,则启动UAC
System.Diagnostics.Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void chbAutoRun_CheckedChanged(object sender, EventArgs e)
{
if (chbAutoRun.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
AutoRun(Application.ExecutablePath, false);
}
}
private void btn_labelDebug_Click(object sender, EventArgs e)
{
//Bitmap bitmap = new Bitmap("16-51-26-94.bmp");
//List<CodeInfo> tlci = EyemDecode2.Decoder(ref bitmap);
//bitmap.Dispose();
List<CodeInfo> tlci = new List<CodeInfo>();
tlci.Add(new CodeInfo("", 413, 1809));
LabelParam labelParam = new LabelParam();
labelParam.codeInfos = tlci;
labelParam.bitmapfilename = @"D:\logs\827\15-02-40-402.bmp";
LabelParam aaa = labelParam.clone();
Point Right_Batch_Point = new Point(RobotManage.Config.Right_Batch_X, RobotManage.Config.Right_Batch_Y);
Point p = Common.CalcLabelPoint(labelParam, Right_Batch_Point, RobotManage.Config.Label_R_Offset, RobotManage.Config.Label_R_Angle_Diff, out int labelAngle);
//计算贴标角度的脉冲值
int labelAxisPos = RobotManage.Config.Label_R_360 / 360 * labelAngle;
//计算像素点位与中心点的差
Point p1 = new Point(p.X - Right_Batch_Point.X, p.Y - Right_Batch_Point.Y);
//计算像素*脉冲像素比得到脉冲值+中心点基准脉冲
p1.X = (int)(p1.X * RobotManage.Config.Cam_Pixel_X_Ratio) + RobotManage.Config.Label_X_Base;
p1.Y = (int)(p1.Y * RobotManage.Config.Cam_Pixel_Y_Ratio) + RobotManage.Config.Label_Y_Base;
}
private void listEdit_pn_DataRefresh(object sender, EventArgs e)
{
Common.LoadMatchList();
}
private void btn_codetest_Click(object sender, EventArgs e)
{
DeviceLibrary.LabelParam labelParam = new DeviceLibrary.LabelParam();
labelParam.codeInfos = new List<CodeLibrary.CodeInfo>();
labelParam.codeInfos.Add(new CodeLibrary.CodeInfo(txt_code.Text, 0, 0));
Common.codeProcess(labelParam, out string debugstring);
label_matchdebugstring.Text = debugstring;
}
private void button1_Click(object sender, EventArgs e)
{
RemoteDecodeHelper_mod.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper_mod.RemoteDecodeParam();
var bmp = new Bitmap("d:\\17-09-05-154.bmp");
var cc = RemoteDecodeHelper_mod.DecodeRequest(bmp, remoteDecodeParam);
}
}
}