FrmSetPlus.cs
4.9 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
using Asa.FaceControl;
using BLL;
using Model;
using SmartScan.PlusSettingFrm;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace SmartScan
{
public partial class FrmSetPlus : FaceFormNormal
{
private readonly Dictionary<FaceButton, Model.ISetMenu> menu = new();
public FrmSetPlus()
{
InitializeComponent();
//Language.SetLanguage(this);
this.SizeChanged += FrmSetPlus_SizeChanged;
this.FormClosing += FrmSetPlus_FormClosing;
//this.Width = 1024;
//this.Height = 738;
this.Top = 15;
this.Left = 0;
WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
LogNet.log = log4net.LogManager.GetLogger("SmartScan");
}
private void FrmSetPlus_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
ShowWindow(this.Handle, SW_HIDE);
//this.WindowState = FormWindowState.Minimized;
//this.Hide();
}
private void FrmSetPlus_SizeChanged(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.Hide();
}
}
private void FrmSet_Load(object sender, EventArgs e)
{
foreach (FaceButton button in menu.Keys)
{
Controls.Remove(menu[button].GetPanel());
}
menu.Clear();
menu.Add(BtnWorkMode, new UsrWorkMode2());
//menu.Add(BtnLabel, new UsrPrintTemplate());
menu.Add(BtnMaterial, new UsrMaterialTemplate(true));
menu.Add(BtnKeyword, new UsrMacro());
//menu.Add(but_Labeling, new UsrCustomlabeling());
menu.Add(Keywordlabeling, new UsrKeywordlabeling());
foreach (FaceButton button in menu.Keys)
{
FacePanel pnl = menu[button].GetPanel();
pnl.Left = PnlTemp.Left;
pnl.Top = PnlTemp.Top;
pnl.Width = PnlTemp.Width;
pnl.Height = PnlTemp.Height;
pnl.Anchor = PnlTemp.Anchor;
pnl.Visible = false;
Controls.Add(pnl);
}
BtnMaterial.HoldPress = true;
menu[BtnMaterial].GetPanel().Visible = true;
//语言
CboLanguage.Items.Clear();
CboLanguage.Items.AddRange(Language.Name.ToArray());
CboLanguage.SelectedText = BLLCommon.config.Language;
Language.SetLanguage(this);
}
private void BtnMenu_Click(object sender, EventArgs e)
{
foreach (FaceButton button in menu.Keys)
{
bool rtn = button == sender;
button.HoldPress = rtn;
menu[button].GetPanel().Visible = rtn;
}
}
private void BtnOK_Click(object sender, EventArgs e)
{
foreach (FaceButton button in menu.Keys)
menu[button].Save();
string text = Language.Dialog(Model.LanguageDialogKey.SAVE_SUCCEED);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
DialogResult = DialogResult.OK;
//WindowState = FormWindowState.Minimized;
ShowWindow(this.Handle, SW_HIDE);
}
public const int SW_HIDE = 0;
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
private void BtnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
FrmSet_Load(this, EventArgs.Empty);
WindowState = FormWindowState.Minimized;
Hide();
}
private void BtnApply_Click(object sender, EventArgs e)
{
foreach (FaceButton button in menu.Keys)
menu[button].Save();
string text = Language.Dialog(Model.LanguageDialogKey.SAVE_SUCCEED);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
}
private void CboLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
if (BLLCommon.config.Language != CboLanguage.Text)
{
Language.LoadLanguage(CboLanguage.Text);
BLLCommon.config.Language = CboLanguage.Text;
BLLCommon.config.Save();
FrmSet_Load(this, EventArgs.Empty);
}
}
private void BtnHistory_Click(object sender, EventArgs e)
{
FrmRetrospect frm = new FrmRetrospect();
frm.WindowState = FormWindowState.Maximized;
frm.Show();
}
}
}