Commit 34242b4e 王海洋

1

1 个父辈 a1028fa1
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true"/>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="90000000" maxBufferPoolSize="90000000" maxBufferSize="90000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas maxStringContentLength="90000000" maxArrayLength="90000000" maxBytesPerRead="90000000" />
<security mode="None"/>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
......@@ -9,6 +9,9 @@ using Asa.FaceControl;
using System.Windows.Forms;
using BLL;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Office.CustomUI;
using System.Windows.Forms.Integration;
using SmartScan.SetControl.WPF;
namespace SmartScan
{
......@@ -28,7 +31,7 @@ namespace SmartScan
menu.Add(BtnLabel, new UsrPrintTemplate());
menu.Add(BtnDataSource, new UsrDataSource());
menu.Add(BtnGenneralSetting, new UsrWorkMode());
// menu.Add(BtnIdentify, new UsrCamera());
// menu.Add(AAA, new UsrWpfPanel(new NS_Keyword()));
......@@ -83,5 +86,7 @@ namespace SmartScan
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
}
}
}
......@@ -304,3 +304,8 @@ FrmSetPlus_RdoNoImage 不保存 Arial,12,,
FrmSetPlus_RdoCondense 压缩图 Arial,12,,
FrmSetPlus_RdoOriginal 原始图 Arial,12,,
FrmSetPlus_LblHistoryImage 追溯图像保存 Arial,12,,
BtnAddKey 添加 Add
BtnDelKey 删除 Delect
BtnUpdateKey 更新 Update
BtnAppendKey 添加到生成条件 Added to build condition
btn_setriid 切换自动RI Automatic switchingRI
\ No newline at end of file
......@@ -353,3 +353,8 @@ FrmCodeExtract_LblSplitPart 获取分割部分 获取分割部分 Arial,12,,
FrmCodeExtract_ChkLengthEnd 截取至结尾 截取至结尾 Arial,12,,
FrmCodeExtract_ChoMatchMiddleType 匹配数量等于 匹配数量等于 Arial,12,,
Dialog_ReplaceData ReplaceData ReplaceData Arial,12,,
BtnAddKey 添加 添加
BtnDelKey 删除 删除
BtnUpdateKey 更新 更新
BtnAppendKey 添加到生成条件 添加到生成条件
btn_setriid 切换自动RI 切换自动RI
\ No newline at end of file
using BLL;
using Model;
using SmartScan.Properties;
using SmartScan.SetControl.WPF;
using System;
using System.Collections.Generic;
using System.Diagnostics;
......@@ -90,6 +92,7 @@ namespace SmartScan
}
}
}
return;
}
......@@ -137,7 +140,29 @@ namespace SmartScan
}
Exit();
}
public static void Service_OnChengeLanguage(string language)
{
ChangeLanguge(language);
}
public static void ChangeLanguge(string languge)
{
if (languge == "Chinese")
{
var path = "pack://application:,,,/Wesky/Chinese.xaml";
// Resources.MergedDictionaries[0].Source = new Uri(path);
}
else if (languge == "English")
{
var path = "pack://application:,,,/Wesky/English.xaml";
// Resources.MergedDictionaries[0].Source = new Uri(path);
}
}
private static bool IsRun()
{
Process current = Process.GetCurrentProcess();
......
......@@ -176,6 +176,8 @@ namespace SmartScan
{
string key = "[datetime:yyyyMMddHHmmss]";
TxtReelIDMatch.AppendText(key);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace SmartScan.SetControl.WPF.Convent
{
public class BoolToColorConverter : IValueConverter
{
public Color TrueColor { get; set; } = Colors.Red;
public Color FalseColor { get; set; } = Colors.Gray;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (value is bool boolValue && boolValue)
? new SolidColorBrush(TrueColor)
: new SolidColorBrush(FalseColor);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.KeyName"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SmartScan.SetControl.WPF"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800" >
<UserControl.Resources>
<!-- 选项卡按钮样式 -->
<Style TargetType="RadioButton" x:Key="TabButtonStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border Background="{TemplateBinding Background}"
CornerRadius="3,3,0,0"
Padding="15,5">
<ContentPresenter HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 字段列表项样式 -->
<Style TargetType="ListBoxItem" x:Key="FieldListItemStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 勾选状态 -->
<Path Data="M0,6 L4,10 12,2"
Stroke="#FF00FF00"
StrokeThickness="2"
/>
<TextBlock Grid.Column="1"
Text="{Binding Name}"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<RadioButton Content="字段配置"
GroupName="Tabs"
Style="{StaticResource TabButtonStyle}"
Background="#FF0066CC"
IsChecked="True"/>
<RadioButton Content="匹配规则"
GroupName="Tabs"
Style="{StaticResource TabButtonStyle}"
Background="#FF2D2D30"/>
<RadioButton Content="高级选项"
GroupName="Tabs"
Style="{StaticResource TabButtonStyle}"
Background="#FF2D2D30"/>
</StackPanel>
<!-- 主内容区 -->
<Grid Grid.Row="1" Margin="0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 左侧字段列表 -->
<GroupBox Header="标准字段"
Foreground="White"
BorderBrush="#FF3E3E42">
<ListBox ItemsSource="{Binding StandardFields}"
ItemContainerStyle="{StaticResource FieldListItemStyle}"
SelectedItem="{Binding SelectedField}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsEnabled}"
Margin="0,0,10,0"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</GroupBox>
<!-- 右侧配置面板 -->
<ScrollViewer Grid.Column="1" Margin="10,0">
<GroupBox Header="Reel ID配置"
Foreground="White"
BorderBrush="#FF3E3E42">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 基本配置 -->
<StackPanel Grid.Row="0">
<TextBlock Text="字段标识符" Margin="0,5"/>
<TextBox Text="{Binding FieldID}"
Background="#FF252526"/>
<TextBlock Text="显示名称" Margin="0,10,0,5"/>
<TextBox Text="{Binding DisplayName}"
Background="#FF252526"/>
<CheckBox Content="启用"
IsChecked="{Binding IsEnabled}"
Margin="0,10"/>
</StackPanel>
<!-- 验证规则 -->
</Grid>
</GroupBox>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// KeyName.xaml 的交互逻辑
/// </summary>
public partial class KeyName : UserControl
{
public KeyName()
{
InitializeComponent();
DataContext = this;
}
public class FieldConfig
{
public string Name { get; set; }
public bool IsEnabled { get; set; }
public string FieldID { get; set; }
public string DisplayName { get; set; }
public string StartString { get; set; }
public string EndString { get; set; }
public int DigitCount { get; set; }
public bool ZeroPadding { get; set; }
public string RegexPattern { get; set; }
}
public ObservableCollection<FieldConfig> StandardFields { get; } = new()
{
new FieldConfig { Name = "RID", IsEnabled = true },
new FieldConfig { Name = "QTY", IsEnabled = true },
new FieldConfig { Name = "LOT", IsEnabled = true },
new FieldConfig { Name = "VPN", IsEnabled = false }
};
}
}
using Asa.FaceControl;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media;
using System.Xml;
using Control = System.Windows.Controls.Control;
using Font = System.Drawing.Font;
using FontStyle = System.Drawing.FontStyle;
namespace SmartScan.SetControl.WPF
{
public class LanguageWwitchover
{
private class ClsLangText
{
public string Name = "";
public string Text = "";
public Font Font = null;
}
public static List<string> Name { get; private set; } = new List<string>();
private static readonly Dictionary<string, Dictionary<string, ClsLangText>> langDict = new Dictionary<string, Dictionary<string, ClsLangText>>();
public static string CurrentLng { get; private set; } = "zh-CN";
private static string filePath;
public static void LoadPath(string path)
{
langDict.Clear();
filePath = path;
string[] files = Directory.GetFiles(path, "*.lngres");
string[] array = files;
foreach (var file in array)
{
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
//var langDictTemp = new Dictionary<string, string>();
if (fileNameWithoutExtension.ToLower() == "en-US".ToLower())
{
Name.Add("English");
}
else if (fileNameWithoutExtension.ToLower() == "zh-CN".ToLower())
{
Name.Add("简体中文");
}
langDict.Add(fileNameWithoutExtension, new Dictionary<string, ClsLangText>());
var lines = File.ReadAllLines(file);
string[] array3 = lines;
foreach (var line in array3)
{
string[] parts = line.Split('\t');
if (parts.Length >= 3)
{
var key = parts[0];
var text = parts[2];
string s = ((parts.Length > 3) ? parts[3] : "");
ClsLangText clsLangText = new ClsLangText();
clsLangText.Font = ConvFont(s);
clsLangText.Name = key;
clsLangText.Text = text;
if (!langDict[fileNameWithoutExtension].ContainsKey(key))
{
langDict[fileNameWithoutExtension].Add(key, clsLangText);
}
}
}
//langDict.Add(fileNameWithoutExtension, langDictTemp);
}
}
private static Font ConvFont(string s)
{
if (string.IsNullOrWhiteSpace(s))
{
return null;
}
string[] array = s.Split(',');
float emSize = Convert.ToSingle(array[1]);
FontStyle fontStyle = FontStyle.Regular;
if (array[2] == "B")
{
fontStyle |= FontStyle.Bold;
}
if (array[3] == "I")
{
fontStyle |= FontStyle.Italic;
}
return new Font(array[0], emSize, fontStyle);
}
public static void LoadLanguage(string name)
{
CurrentLng = name;
}
public static string GetText(string key)
{
if (langDict.ContainsKey(CurrentLng) && langDict[CurrentLng].ContainsKey(key))
{
return langDict[CurrentLng][key].ToString();
}
return key; // Return key if text not found
}
public static void SetLanguage(DependencyObject parent)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
SetLanguage(child);
if (child is Control control)
{
// 执行你需要的操作,例如设置文本或字体
Console.WriteLine($"Control Type: {control.GetType().Name}, Name: {control.Name}, Content:{control.Name}");
var key = control.Name; // 假设控件名称是资源键
var text = LanguageWwitchover.GetText(key);
if (control is System.Windows.Controls.Button button)
{
try
{
text = LanguageWwitchover.GetText(langDict[CurrentLng][key].Text);
button.Content = text;
}
catch (Exception)
{
}
}
// 示例:设置控件文本
// string text = LanguageSwitcher.GetText("YourKeyHere");
// control.Content = text;
// 示例:设置控件字体
// if (control is TextBlock textBlock)
// {
// var font = new FontFamily("微软雅黑"), emSize = 12, fontStyle = FontStyles.Normal;
// textBlock.FontFamily = font;
// textBlock.FontSize = emSize;
// textBlock.FontStyle = fontStyle;
// }
}
}
//if (langDict.ContainsKey(CurrentLng) && langDict[CurrentLng].ContainsKey(frm.Name + "_" + frm.Name))
//{
// frm.Text = langDict[CurrentLng][frm.Name + "_" + frm.Name].Text;
// frm.TitleFont = langDict[CurrentLng][frm.Name + "_" + frm.Name].Font;
// SetLang(frm.Name, frm);
//}
}
private static void SetLang(string frmname, System.Windows.Forms.Control ctl)
{
if (!langDict.ContainsKey(CurrentLng))
{
return;
}
foreach (System.Windows.Forms.Control control in ctl.Controls)
{
if (control.Name == "")
{
continue;
}
string key = frmname + "_" + control.Name;
if (control.HasChildren)
{
SetLang(frmname, control);
}
}
}
private static bool HasChinese(string txt)
{
if (Regex.IsMatch(txt.ToString(), "[\\u4E00-\\u9FA5]+"))
{
return true;
}
return false;
}
public static void UpdateUI(UIElement element, string key)
{
if (element is FrameworkElement fe)
{
fe.Dispatcher.Invoke(() =>
{
var text = GetText(key);
if (fe is TextBlock tb)
{
tb.Text = text;
}
else if (fe is System.Windows.Controls.Button btn)
{
btn.Content = text;
}
// Add more controls as needed
});
}
}
}
}
using Asa.FaceControl;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.Integration;
namespace SmartScan
{
internal class MenuElementHost : ElementHost, ISetMenu
{
FacePanel ISetMenu.GetPanel()
{
//throw new NotImplementedException();
return null;
}
void ISetMenu.Save()
{
//throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace SmartScan.SetControl.WPF.Models
{
public class ItemModel: INotifyPropertyChanged
{
private string _value;
private bool _isSelected;
public string Value
{
get => _value;
set { _value = value; OnPropertyChanged(); }
}
public bool IsSelected
{
get => _isSelected;
set { _isSelected = value; OnPropertyChanged(); }
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
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);
}
}
}
namespace SmartScan.SetControl.WPF
{
partial class UsrWpfPanel
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.facepnl = new Asa.FaceControl.FacePanel();
this.SuspendLayout();
//
// facepnl
//
this.facepnl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.facepnl.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.facepnl.BorderWidth = 2;
this.facepnl.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.facepnl.Location = new System.Drawing.Point(16, 20);
this.facepnl.Name = "facepnl";
this.facepnl.Padding = new System.Windows.Forms.Padding(3);
this.facepnl.ShowText = false;
this.facepnl.Size = new System.Drawing.Size(906, 758);
this.facepnl.TabIndex = 2;
this.facepnl.Text = "facePanel1";
this.facepnl.TitleFont = new System.Drawing.Font("宋体", 12F);
//
// UsrWpfPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.facepnl);
this.Name = "UsrWpfPanel";
this.Size = new System.Drawing.Size(1286, 866);
this.ResumeLayout(false);
}
#endregion
private Asa.FaceControl.FacePanel facepnl;
}
}
using Asa.FaceControl;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
namespace SmartScan.SetControl.WPF
{
public partial class UsrWpfPanel : UserControl, ISetMenu
{
public UsrWpfPanel(UIElement ctl)
{
InitializeComponent();
elementHost = new ElementHost
{
Dock = DockStyle.Fill,
};
elementHost.Child = ctl;
}
ElementHost elementHost;
FacePanel ISetMenu.GetPanel()
{
facepnl.Controls.Add(elementHost);
return facepnl;
}
void ISetMenu.Save()
{
//ctl.Save();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -77,8 +77,11 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedDll\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml, Version=2.16.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.2.16.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
<Reference Include="DocumentFormat.OpenXml, Version=3.0.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.3.0.2\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml.Framework, Version=3.0.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.Framework.3.0.2\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath>
</Reference>
<Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath>
......@@ -89,6 +92,14 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="SharpDocx, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDocx.2.5.0\lib\net45\SharpDocx.dll</HintPath>
</Reference>
<Reference Include="SharpImage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDocx.2.5.0\lib\net45\SharpImage.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
......@@ -97,6 +108,7 @@
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -107,6 +119,7 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common.cs" />
......@@ -183,6 +196,22 @@
<Compile Include="SetControl\UsrWorkMode2.Designer.cs">
<DependentUpon>UsrWorkMode2.cs</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\Convent\BoolToColorConverter.cs" />
<Compile Include="SetControl\WPF\KeyName.xaml.cs">
<DependentUpon>KeyName.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\LanguageWwitchover.cs" />
<Compile Include="SetControl\WPF\MenuElementHost.cs" />
<Compile Include="SetControl\WPF\Models\ItemModel.cs" />
<Compile Include="SetControl\WPF\NS_Keyword.xaml.cs">
<DependentUpon>NS_Keyword.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UsrWpfPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="SetControl\WPF\UsrWpfPanel.Designer.cs">
<DependentUpon>UsrWpfPanel.cs</DependentUpon>
</Compile>
<Compile Include="UserLoginWindow.cs" />
<Compile Include="Form\FrmAbout.cs">
<SubType>Form</SubType>
......@@ -384,6 +413,9 @@
<EmbeddedResource Include="SetControl\UsrCodeExtractList.resx">
<DependentUpon>UsrCodeExtractList.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SetControl\WPF\UsrWpfPanel.resx">
<DependentUpon>UsrWpfPanel.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Language\en-US.lngres">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......@@ -457,6 +489,16 @@
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<Page Include="SetControl\WPF\KeyName.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\NS_Keyword.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>rem copy C:\Neotel\DLL\Halcon\halcondotnet.dll $(TargetDir)halcondotnet.dll
......
......@@ -111,14 +111,9 @@ namespace SmartScan
public WebResultCamera GetPrintAiing(string a)
{
BLLCommon.extension.Clear();
scanWork.workCodeInfo = new();
//string[] parts = a.Split(';');
//if (a.StartsWith("[") && a.EndsWith("]"))
//{
// a = a.Substring(1, a.Length - 2);
// Console.WriteLine(a);
//}
//BLLCommon.extension.Clear();
//scanWork.workCodeInfo = new();
var aa = BLLCommon.macroKey;
// 2. 初始化目标字典
Dictionary<string, string> aaa = new Dictionary<string, string>();// { { "LOT",null} };
......@@ -128,141 +123,20 @@ namespace SmartScan
}
try
{
// 解析 JSON 字符串
// 解析 JSON 字符串反序列化
aaa = JsonConvert.DeserializeObject<Dictionary<string, string>>(a);
// 将解析结果赋值给 aaa 字典
//foreach (var key in aaa.Keys)
//{
// if (jsonObject.ContainsKey(key))
// {
// aaa[key] = jsonObject[key];
// }
//}
}
catch (JsonException ex)
{
Console.WriteLine($"JSON 解析出错: {ex.Message}");
LogNet.log.Info($"JSON 解析出错: {ex.Message}");
}
//string output = Regex.Replace(a, @"^-\s*|\n", "");
//string trimmed = a.Trim('[', ']').Replace("\n", "").Replace(" ", "");
//// 按逗号分隔字符串
//string[] keyValuePairs = trimmed.Split(new[] { '\"', ',' }, StringSplitOptions.RemoveEmptyEntries);
//foreach (var line in keyValuePairs)
//{
// string[] part = line.Split(new[] { ':' }, 2); // Split on first colon only
// if (part.Length == 2)
// {
// var key = part[0].Trim();
// var value = part[1].Trim();
// aaa[key] = value;
// }
//}
//var dataDict = new Dictionary<string, string>();
//foreach (var part in parts)
//{
// if (part.Contains(":"))
// {
// var keyValue = part.Split(new[] { ':' }, 2);
// dataDict[keyValue[0].Trim()] = keyValue[1].Trim();
// }
//}
//// Extract specific values with fallback to empty string if not found
//string article = parts[0]; // "ArticleRTIRES09221"
//string cleanedArticle = article.StartsWith("Article") ? article.Substring(7) : article; // 去掉 "Article"
//string vpn = dataDict.TryGetValue("VP/N", out var v) ? v : "";
//string lot = dataDict.TryGetValue("LOT", out var l) ? l : "";
//string qty = dataDict.TryGetValue("QTY", out var q) ? q : "";
//string coo = dataDict.TryGetValue("COO", out var c) ? c : "";
//string articleNumber = parts[0].Replace("Article", "PR"); // 将Article替换为PR
//string vpn = "";
//string lot = "";
//string qty = "";
//string coo = "AUSTIN"; // 根据要求固定为AUSTIN
//foreach (string segment in parts)
//{
// if (segment.StartsWith("VP/N:"))
// {
// vpn = segment.Substring(5); // 获取VP/N的值
// }
// else if (segment.StartsWith("LOT:"))
// {
// lot = segment.Substring(4); // 获取LOT的值
// }
// else if (segment == "5000") // QTY是单独的分段
// {
// qty = "5000";
// }
//}
//string text1 = articleNumber; // PRTIRES09221
//string text2 = $"{vpn};{lot};{qty};{coo}"; // CR0603-10W-2001FT;330NO057040;5000;AUSTIN
//// 4. 添加到workCodeInfo
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text1 });
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text2 });
// 2. Create the required text entries
//var text1 = $"{cleanedArticle}";
//var text2 = $"{vpn};{lot};{qty};{coo.Split(' ').FirstOrDefault()}";
// 3. Add to workCodeInfo
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text1 });
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text2 });
// aaa.Add(aa);
//{
// { "LOT", null }, // 默认值为 null
// { "Sample_2", null }, // 默认值为 null
// { "RID", null }, // 默认值为 null
// { "QTY", null }, // 默认值为 null
// { "VPN", null }, // 默认值为 null
// { "VPN_2", null }, // 默认值为 null
// { "FC", null }, // 默认值为 null
// // 默认值为 null
//};
// 3. 遍历所有字段,提取 LOT 和 RID
// 遍历所有字段,提取目标值
//foreach (string part in parts)
//{
// 检查字段是否包含目标键(如 "LOT:"、"QTY:"、"VP/N:")
// foreach (string key in aaa.Keys.ToList()) // 遍历字典的键
// {
// 特殊处理 VP/ N → VPN(替换 "/" 为 "_")
// string prefix = (key == "VPN") ? "VP/N:" : key + ":";
// if (part.StartsWith(prefix))
// {
// aaa[key] = part.Substring(prefix.Length); // 提取冒号后的值
// break; // 找到后跳出当前循环
// }
// if (part.StartsWith(prefix))
// {
// if (key == "LOT")
// {
// aaa[key] = $"<OCR>{part.Substring(prefix.Length)}";
// }
// else
// {
// aaa[key] = part.Substring(prefix.Length);
// aaa[key] = $"<OCR>{part.Substring(prefix.Length)}";
// }
// break;
// }
// }
//}
try
{
bool hasMatch = scanWork.MatchingTemplate();
//bool hasMatch = scanWork.MatchingTemplate();
bool hasMatch = true;
BLLCommon.extension.SetKey(scanWork.originalCodeText, aaa, hasMatch, out _);
BLLCommon.extension.Print(hasMatch, aaa);
}
......@@ -272,11 +146,7 @@ namespace SmartScan
return new WebResultCamera { Text = "NG" };
}
//Common.frmMain.Invoke(delegate ()
//{
//scanWork.SetKey(hasMatch);
//});
//PrintAiing?.Invoke(aaa);
return new WebResultCamera { Text = "OK" };
}
public static void SaveBitmapToFile(Bitmap bmp, string filePath)
......
......@@ -57,7 +57,7 @@
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ClosedXML" version="0.96.0" targetFramework="net472" />
<package id="DocumentFormat.OpenXml" version="2.16.0" targetFramework="net472" />
<package id="DocumentFormat.OpenXml" version="3.0.2" targetFramework="net472" />
<package id="DocumentFormat.OpenXml.Framework" version="3.0.2" targetFramework="net472" />
<package id="ExcelNumberFormat" version="1.1.0" targetFramework="net472" />
<package id="log4net" version="2.0.12" targetFramework="net461" />
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="SharpDocx" version="2.5.0" targetFramework="net472" />
</packages>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!