UsrWorkMode.cs
7.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Asa.FaceControl;
using BLL;
using ClosedXML.Excel;
using Model;
using SmartScan.SetControl.WPF.Model;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan
{
public partial class UsrWorkMode : UserControl, ISetMenu
{
public UsrWorkMode()
{
InitializeComponent();
//打印机
LstPrinter.Items.AddRange(Printer.AllName);
LstPrinter.Text = BLLCommon.config.PrinterName;
if (BLLCommon.config.PrintLandscape)
RdoLandscape.Checked = true;
else
RdoVertical.Checked = true;
//图像保存
((FaceRadioBox)facePanel1.Controls["Rdo" + BLLCommon.config.HistoryImage.ToString()]).Checked = true;
//6个复选框
ChkSelectPN.Checked = BLLCommon.config.SelectHttpPN;
ChkLabelEmptyCheck.Checked = BLLCommon.config.LabelEmptyCheck;
ChkOpenEnterWork.Checked = BLLCommon.config.OpenStartWork;
ChkPrintCompletedClear.Checked = BLLCommon.config.PrintCompletedClear;
ChkOpenMaximize.Checked = BLLCommon.config.OpenMaximize;
ChkTriggerOpenLight.Checked = BLLCommon.config.TriggerOpenLight;
ChkPromptAfterPrinting.Checked = BLLCommon.config.PromptAfterPrinting;
ChkAutoPrint.Checked = BLLCommon.config.AutoPrint;
ChkAllowModifyPrint.Checked = Config.AllowModifyPrintInfo;
ChkCheckFunction.Checked = BLLCommon.config.CheckFunction; ;
//默认标签
LstLabel.Items.AddRange(BLLCommon.labelEdit.Name);
LstLabel.Text = BLLCommon.config.DefaultPrintLabel;
//优先模板
LstMate.Items.AddRange(BLLCommon.mateEdit.Name);
LstMate.Text = BLLCommon.config.DefaultMaterialName;
Language.SetLanguage(this);
}
public FacePanel GetPanel()
{
return facePanel1;
}
public void Save()
{
//保存打印机
BLLCommon.config.PrintLandscape = RdoLandscape.Checked;
if (LstPrinter.SelectedIndex == -1)
{
if (LstPrinter.Items.Count == 1)
BLLCommon.config.PrinterName = LstPrinter.Items[0];
}
else
{
BLLCommon.config.PrinterName = LstPrinter.Text;
}
//追溯图像保存
if (RdoOriginal.Checked)
BLLCommon.config.HistoryImage = HistoryImage.Original;
else if (RdoCondense.Checked)
BLLCommon.config.HistoryImage = HistoryImage.Condense;
else if (RdoNoImage.Checked)
BLLCommon.config.HistoryImage = HistoryImage.NoImage;
//默认打印标签
if (LstLabel.SelectedIndex == -1)
{
if (LstLabel.Items.Count == 1)
BLLCommon.config.DefaultPrintLabel = LstLabel.Items[0];
}
else
{
BLLCommon.config.DefaultPrintLabel = LstLabel.Text;
}
//优先匹配模板
if (LstMate.SelectedIndex == -1)
{
if (LstMate.Items.Count == 1)
BLLCommon.config.DefaultMaterialName = LstMate.Items[0];
}
else
{
BLLCommon.config.DefaultMaterialName = LstMate.Text;
}
//6个复选框
BLLCommon.config.SelectHttpPN = ChkSelectPN.Checked;
BLLCommon.config.LabelEmptyCheck = ChkLabelEmptyCheck.Checked;
BLLCommon.config.OpenStartWork = ChkOpenEnterWork.Checked;
BLLCommon.config.OpenMaximize = ChkOpenMaximize.Checked;
BLLCommon.config.PrintCompletedClear = ChkPrintCompletedClear.Checked;
BLLCommon.config.TriggerOpenLight = ChkTriggerOpenLight.Checked;
BLLCommon.config.PromptAfterPrinting = ChkPromptAfterPrinting.Checked;
BLLCommon.config.AutoPrint = ChkAutoPrint.Checked;
BLLCommon.config.CheckFunction = ChkCheckFunction.Checked;
BLLCommon.config.Save();
}
int i = 0;
private void but_Readfileprint_Click(object sender, EventArgs e)
{
Dictionary<int, Dictionary<string, string>> valuePairs = new Dictionary<int, Dictionary<string, string>>();
i++;
if (i==10)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect =false;
openFileDialog.Title = "请选择文件";
openFileDialog.Filter = "所有文件(*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string file=openFileDialog.FileName;
ContinuousPrinting(file);
}
i = 0;
}
}
public delegate void PrintDelegate(Dictionary<string, string> content);
public static event PrintDelegate Printing;
public void ContinuousPrinting(string filepath)
{
Dictionary<int, Dictionary<string, string>> valuePairs = new Dictionary<int, Dictionary<string, string>>();
if (!File.Exists(filepath))
{
string YU = BLLCommon.config.Language;
if (YU == "English")
{
bool result = NeoAlertBox.Show( "", "File not found", AlertType.Warning, "NEO SCAN", true);
}
else if (YU=="日语")
{
bool result = NeoAlertBox.Show("", "ファイルが存在しません", AlertType.Warning, "NEO SCAN", true);
}
else
{
bool result = NeoAlertBox.Show( "", "文件不存在", AlertType.Warning, "NEO SCAN", true);
}
return;
}
var Titles = ExtraFileData.ParseXLSFileTitle(filepath);
try
{
XLWorkbook wb = new XLWorkbook(filepath);
IXLWorksheet ws = wb.Worksheet(1);
int emptyrow = 0;
int currow = 1;
while (emptyrow < 3)
{
var rowdata = new Dictionary<string, string>();
for (int i = 0; i < Titles.Count; i++)
{
var v = ws.Row(currow + 1).Cell(i + 1).Value.ToString().Trim();
rowdata.Add(Titles[i], v);
}
currow++;
if (!valuePairs.ContainsKey(currow))
{
valuePairs.Add(currow, rowdata);
}
if (rowdata.Values.Contains(""))
{
emptyrow++;
}
}
}
catch (Exception ex)
{
LogNet.log.Info("数据源加载文件出错:" + ex.ToString());
}
foreach (var item in valuePairs)
{
Printing?.Invoke(item.Value);
}
}
}
}