NS_Keyword.xaml.cs
4.7 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
using BLL;
using Model;
using SmartScan.PlusSettingFrm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// NS_Keyword.xaml 的交互逻辑
/// </summary>
public partial class NS_Keyword : System.Windows.Controls.UserControl
{
private readonly List<string> keyCopy;
public string ButtonContent => LanguageWwitchover.GetText("ButtonContentKey");
public string TextBlockContent => LanguageWwitchover.GetText("TextBlockContentKey");
public NS_Keyword()
{
InitializeComponent();
keyCopy = new(BLLCommon.macroKey);
LstKey.ItemsSource=keyCopy;
string YU = BLLCommon.config.Language;
if (YU == "简体中文")
{
YU = "zh-CN";
}
else
{
YU = "en-US";
}
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
//ChangeInfo.LanguageService.ChangLanguagePublic(YU);
//LanguageWwitchover.SetLanguage(this);
}
private void LstKey_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LstKey.SelectedItem != null)
{
string selectedValue = LstKey.SelectedItem.ToString();
lst_key.Text = selectedValue.ToString();
}
}
private void BtnAddKey_Click(object sender, RoutedEventArgs e)
{
string text = lst_key.Text;
int index = keyCopy.FindIndex(match => match == text);
if (index == -1)
{
keyCopy.Add(text);
LstKey.ItemsSource = null;
LstKey.ItemsSource=keyCopy;
}
else
{
string hint = Asa.FaceControl.Language.Dialog("KeyExists");
hint = hint.Replace("[name]", text);
new Asa.FaceControl.FaceMessageBox("", hint, MessageBoxButtons.OK).ShowDialog();
}
}
private void BtnDelKey_Click(object sender, RoutedEventArgs e)
{
int index = LstKey.SelectedIndex;
if (index == -1 || index >= keyCopy.Count) return;
keyCopy.RemoveAt(index);
LstKey.ItemsSource = null;
LstKey.ItemsSource = keyCopy;
var keyname = ConfigHelper.Config.Get("Label_Key");
if (!string.IsNullOrWhiteSpace(keyname))
{
UsrKeywordlabeling.Deletskeyname();
}
}
private void BtnUpdateKey_Click(object sender, RoutedEventArgs e)
{
if (LstKey.SelectedIndex == -1) return;
string text = lst_key.Text;
int index = keyCopy.FindIndex(match => match == text);
if (index == -1)
{
keyCopy[LstKey.SelectedIndex] = text;
var oldname = LstKey.Items[LstKey.SelectedIndex];
var keyname = ConfigHelper.Config.Get("Label_Key");
if (!string.IsNullOrWhiteSpace(keyname))
{
//ConfigHelper.Config.Set("Label_Key", "Part No");
if (oldname.ToString() == keyname)
{
UsrKeywordlabeling.Updatekeyname(text);
}
}
LstKey.ItemsSource = null;
LstKey.ItemsSource = keyCopy;
//LstKey.Items[LstKey.SelectedIndex] = text;
setRIkey();
}
else
{
string hint = Asa.FaceControl.Language.Dialog("KeyExists");
hint = hint.Replace("[name]", text);
new Asa.FaceControl.FaceMessageBox("", hint, MessageBoxButtons.OK).ShowDialog();
}
}
void setRIkey()
{
//LstKey.Items.Clear();
LstKey.ItemsSource=keyCopy;
for (int i = 0; i < LstKey.Items.Count; i++)
{
if (LstKey.Items[i] == BLLCommon.config.ReelIDKeyWord)
LstKey.Items[i] = "[RI]" + LstKey.Items[i];
}
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
LanguageWwitchover.SetLanguage(this);
}
}
}