Commit ade252a8 王海洋

1

1 个父辈 a1028fa1
正在显示 95 个修改的文件 包含 3234 行增加271 行删除
......@@ -121,12 +121,16 @@
<Compile Include="LabelingPosition.cs" />
<Compile Include="LightSource.cs" />
<Compile Include="MatchAnalysis.cs" />
<Compile Include="MessageboxNeo.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MonitorMouseKeyboard.cs" />
<Compile Include="NamedPipeClient.cs" />
<Compile Include="PaddleOCRHelper.cs" />
<Compile Include="PrinterHelper.cs" />
<Compile Include="PrintLabelEdit.cs" />
<Compile Include="MaterialEdit.cs" />
<Compile Include="PrintLabelShow - 复制.cs" />
<Compile Include="PrintLabelShow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Replacekeywords.cs" />
......
......@@ -17,12 +17,25 @@ namespace BLL
public static ServerCommunication SCMM;
public static List<string> macroKey;
public static List<string> macroKeyValue;
public static List<string> extraKey=new List<string>();
//public static Dictionary<string, Dictionary<string, string>> extraData = new Dictionary<string, Dictionary<string, string>>();
public static int mateMaxCodeID;
public static readonly string[] CODE_SPLIT = new string[] { ",", ";", ":", "@", "#", "$", "%", "&", "-", "_", "+", "|", "!", "^", "*", "?", "/", "\\", "[Space]", "[Tab]","[GS]","[RS]"};
public static List<AutoGenRule> AutoGenRules;
public class SetKeyEventArgs : EventArgs
{
public string[] OriginalCode { get; }
public Dictionary<string, string> Key { get; }
public bool HasMatch { get; }
public SetKeyEventArgs(string[] originalCode, Dictionary<string, string> key, bool hasMatch)
{
OriginalCode = originalCode;
Key = key;
HasMatch = hasMatch;
}
}
}
}
......@@ -111,22 +111,28 @@ namespace BLL
}
public static Bitmap[] CaptureAndGetCode(out List<BarcodeInfo> barcodeInfos)
{
LogNet.log.Info("扫码相机获取图片!");
Bitmap[] result = new Bitmap[1];
barcodeInfos = new List<BarcodeInfo>();
LogNet.log.Info("1!");
if (useIDCamera)
{
LogNet.log.Info("2!");
barcodeInfos = grabOne(out Bitmap bitmap);
if (bitmap==null)
{
LogNet.log.Info("扫码相机获取图片为空!");
}
result[0] = bitmap;
LogNet.log.Info("3!");
}
else
{
LogNet.log.Info("4!");
cameraVision.Open();
LogNet.log.Info("6!");
result = cameraVision.GetImage();
LogNet.log.Info("7!");
for (int i = 0; i < result.Length; i++)
{
if (result[i] != null)
......@@ -139,8 +145,10 @@ namespace BLL
}
}
}
LogNet.log.Info("5!");
cameraVision.Close();
}
LogNet.log.Info("6!"+ result);
return result;
}
public static List<BarcodeInfo> GetBarCode(Bitmap bitmap)
......
using ConfigHelper;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
......@@ -117,7 +119,14 @@ namespace BLL
get => config.Read<bool>(Check_Function);
set => config.Write(Check_Function, value);
}
/// <summary>
/// AI地址
/// </summary>
public string AI
{
get => config.Read<string>(AUTO_AI);
set => config.Write(AUTO_AI, value);
}
/// <summary>
/// 打开软件后开启工作模式
/// </summary>
......@@ -347,6 +356,12 @@ namespace BLL
public static MyConfig<bool> Func_UseIDCamera=false;
[MyConfigComment("隐藏软件logo")]
public static MyConfig<bool> AppUI_HideLogo=false;
// 在BLLCommon.config类中添加
public string CharacterTypeKeywords
{
get => config.Read<string>(CHARACTER_TYPE_KEYWORDS);
set => config.Write(CHARACTER_TYPE_KEYWORDS, value);
}
public void Save()
{
config.Save();
......@@ -397,6 +412,8 @@ namespace BLL
private const string WEB_SERVICE = "WebService";
private const string LIGHT_SERIAL_PORT = "LightSerialPort";
private const string AUTO_PRINT = "AutoPrint";
private const string AUTO_AI = "AI";
private const string CHARACTER_TYPE_KEYWORDS = "CharacterTypeKeywords";
}
}
......@@ -52,7 +52,7 @@ namespace BLL
catch (Exception ex)
{
LogNet.log.Error("Alcoelectro", ex);
System.Windows.Forms.MessageBox.Show(ex.Message, "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
Clear();
}
......
......@@ -134,7 +134,7 @@ namespace BLL
catch (Exception ex)
{
LogNet.log.Error("ReadReelID", ex);
System.Windows.Forms.MessageBox.Show(ex.Message, "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
}
......
此文件的差异被折叠, 点击展开。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using Model;
......@@ -217,45 +219,104 @@ namespace BLL
temp.State = TemplateState.Saved;
}
//private void PrintTest_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
//{
// var brect = new RectangleF(0, 0, interimLabel.Size.Width, interimLabel.Size.Height);
// brect = ObjConversion.MmToPx(brect);
// Bitmap bmp = new Bitmap((int)brect.Width, (int)brect.Height);
// Graphics gg = Graphics.FromImage(bmp);
// for (int i = 0; i < interimLabel.Field.Count; i++)
// {
// PrintLabelField field = interimLabel.Field[i];
// RectangleF rect = ObjConversion.MmToPx(field.Rectangle);
// if (field.Type == PrintLabelFieldType.Text)
// {
// if (interimLabel.FieldShowKey)
// {
// e.Graphics.DrawString(field.Text, field.Font, Brushes.Black, rect);
// gg.DrawString(field.Text, field.Font, Brushes.Black, rect);
// }
// else
// {
// e.Graphics.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
// gg.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
// }
// }
// else
// {
// if (field.Image != null)
// { e.Graphics.DrawImage(field.Image, rect);
// gg.DrawImage(field.Image, rect);
// }
// }
// //e.Graphics.DrawRectangle(Pens.LightGray, rect.X, rect.Y, rect.Width, rect.Height);
// }
// gg.Save();
// try
// {
// bmp.Save("printlabel.png");
// }
// catch (Exception EX)
// {
// }
//}
private void PrintTest_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
var brect = new RectangleF(0, 0, interimLabel.Size.Width, interimLabel.Size.Height);
brect = ObjConversion.MmToPx(brect);
Bitmap bmp = new Bitmap((int)brect.Width, (int)brect.Height);
Graphics gg = Graphics.FromImage(bmp);
for (int i = 0; i < interimLabel.Field.Count; i++)
using (Bitmap bmp = new Bitmap((int)brect.Width, (int)brect.Height))
using (Graphics gg = Graphics.FromImage(bmp))
{
PrintLabelField field = interimLabel.Field[i];
RectangleF rect = ObjConversion.MmToPx(field.Rectangle);
if (field.Type == PrintLabelFieldType.Text)
for (int i = 0; i < interimLabel.Field.Count; i++)
{
if (interimLabel.FieldShowKey)
PrintLabelField field = interimLabel.Field[i];
RectangleF rect = ObjConversion.MmToPx(field.Rectangle);
if (field.Type == PrintLabelFieldType.Text)
{
e.Graphics.DrawString(field.Text, field.Font, Brushes.Black, rect);
gg.DrawString(field.Text, field.Font, Brushes.Black, rect);
if (interimLabel.FieldShowKey)
{
e.Graphics.DrawString(field.Text, field.Font, Brushes.Black, rect);
gg.DrawString(field.Text, field.Font, Brushes.Black, rect);
}
else
{
e.Graphics.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
gg.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
}
}
else
{
e.Graphics.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
gg.DrawString(ObjConversion.StrRemoveKey(field.Text), field.Font, Brushes.Black, rect);
if (field.Image != null)
{
e.Graphics.DrawImage(field.Image, rect);
gg.DrawImage(field.Image, rect);
}
}
//e.Graphics.DrawRectangle(Pens.LightGray, rect.X, rect.Y, rect.Width, rect.Height);
}
else
gg.Save();
try
{
if (field.Image != null)
{ e.Graphics.DrawImage(field.Image, rect);
gg.DrawImage(field.Image, rect);
}
bmp.Save("printlabel.png", ImageFormat.Png);
}
catch (UnauthorizedAccessException)
{
}
//e.Graphics.DrawRectangle(Pens.LightGray, rect.X, rect.Y, rect.Width, rect.Height);
}
gg.Save();
bmp.Save("printlabel.bmp");
}
}
private void PrintLast_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
......
......@@ -21,6 +21,7 @@ namespace Model
public static readonly string CONFIG_APP = Environment.CurrentDirectory + "\\Config\\app.config";
public static readonly string CONFIG_CAMERA = Environment.CurrentDirectory + "\\Config\\Camera.json";
public static readonly string CONFIG_MACRO_KEY = Environment.CurrentDirectory + "\\Config\\MacroKey.txt";
public static readonly string CONFIG_MACRO_Value = Environment.CurrentDirectory + "\\Config\\MacroValue.txt";
public static readonly string CONFIG_HTTP_TEST_DATA = Environment.CurrentDirectory + "\\Config\\HttpTestData.json";
public static readonly string CONFIG_EXTENSION = Environment.CurrentDirectory + "\\Config\\Extension.json";
public static readonly string CONFIG_REELID = Environment.CurrentDirectory + "\\Config\\ReelID";
......
<?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>
......@@ -39,8 +39,7 @@ namespace SmartScan
//
this.pictureBox1.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.pictureBox1.Image = global::SmartScan.Properties.Resources.App;
this.pictureBox1.Location = new System.Drawing.Point(51, 69);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.pictureBox1.Location = new System.Drawing.Point(38, 55);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(411, 94);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
......@@ -55,11 +54,10 @@ namespace SmartScan
this.LblName.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.LblName.BorderWidth = 2;
this.LblName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LblName.Location = new System.Drawing.Point(15, 194);
this.LblName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LblName.Location = new System.Drawing.Point(11, 155);
this.LblName.Name = "LblName";
this.LblName.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LblName.Size = new System.Drawing.Size(619, 62);
this.LblName.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.LblName.Size = new System.Drawing.Size(464, 50);
this.LblName.TabIndex = 8;
this.LblName.Text = "faceLabel1";
//
......@@ -71,27 +69,24 @@ namespace SmartScan
this.faceLabel2.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.faceLabel2.BorderWidth = 2;
this.faceLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.faceLabel2.Location = new System.Drawing.Point(15, 264);
this.faceLabel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.faceLabel2.Location = new System.Drawing.Point(11, 211);
this.faceLabel2.Name = "faceLabel2";
this.faceLabel2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.faceLabel2.Size = new System.Drawing.Size(619, 56);
this.faceLabel2.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.faceLabel2.Size = new System.Drawing.Size(464, 45);
this.faceLabel2.TabIndex = 9;
this.faceLabel2.Text = "faceLabel2";
this.faceLabel2.Click += new System.EventHandler(this.faceLabel2_Click);
//
// FrmAbout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(648, 424);
this.ClientSize = new System.Drawing.Size(486, 339);
this.Controls.Add(this.faceLabel2);
this.Controls.Add(this.LblName);
this.Controls.Add(this.pictureBox1);
this.Icon = global::SmartScan.Properties.Resources.App;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "FrmAbout";
this.Padding = new System.Windows.Forms.Padding(11, 10, 11, 10);
this.Text = "FrmAbout";
this.Load += new System.EventHandler(this.FrmAbout_Load);
this.Controls.SetChildIndex(this.pictureBox1, 0);
......
......@@ -8,22 +8,90 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
namespace SmartScan
{
public partial class FrmAbout : Asa.FaceControl.FaceFormFixed
{
private ElementHost wpfHost;
private SmartScan.SetControl.WPF.AboutWindowHost aboutControl;
public FrmAbout()
{
InitializeComponent();
// 设置WinForms窗体的基本属性
this.FormBorderStyle = FormBorderStyle.None;
this.BackColor = System.Drawing.Color.FromArgb(18, 18, 18); // 与WPF背景相匹配
this.StartPosition = FormStartPosition.CenterParent;
this.Size = new System.Drawing.Size(490, 342); // 设置与WPF控件相同的尺寸
// 初始化ElementHost
//InitializeWpfControl();
}
private void InitializeWpfControl()
{
// 创建ElementHost控件
wpfHost = new ElementHost();
wpfHost.Dock = DockStyle.Fill;
// 创建WPF用户控件实例
aboutControl = new SmartScan.SetControl.WPF.AboutWindowHost();
RegisterWpfEvents();
// 设置WPF控件的事件处理
// 假设您在WPF控件中公开了一个CloseRequested事件
// aboutControl.CloseRequested += (s, e) => this.Close();
// 将WPF控件分配给ElementHost
wpfHost.Child = aboutControl;
private void FrmAbout_Load(object sender, EventArgs e)
// 将ElementHost添加到WinForms窗体
this.Controls.Add(wpfHost);
}
private void RegisterWpfEvents()
{
faceLabel2.Text = BLLCommon.config.SoftVersion;
// 如果WPF控件提供了关闭和最小化事件,可以在这里注册
// 例如:
aboutControl.CloseRequested += (s, e) => this.Close();
aboutControl.MinimizeRequested += (s, e) => this.WindowState = FormWindowState.Minimized;
aboutControl.VersionTextClicked += AboutControl_VersionTextClicked;
}
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST && m.Result.ToInt32() == HTCLIENT)
{
m.Result = (IntPtr)HTCAPTION;
}
}
private void FrmAbout_Load(object sender, EventArgs e)
{
//faceLabel2.Text = BLLCommon.config.SoftVersion;
// 保存版本信息,以便可能需要在WPF控件中使用
string versionInfo = BLLCommon.config.SoftVersion;
// 隐藏所有现有的WinForms控件
HideExistingControls();
// 初始化和显示WPF控件
InitializeWpfControl();
}
private void HideExistingControls()
{
// 遍历当前窗体上的所有控件并隐藏它们
foreach (Control control in this.Controls)
{
// 如果不想隐藏特定控件,可以在这里添加条件判断
control.Visible = false;
}
}
private void AboutControl_VersionTextClicked(object sender, EventArgs e)
{
// 在这里处理版本号点击
// 例如显示高级配置对话框
ConfigHelper.AdvanceConfigForm.ShowEditDialog(this);
}
private void faceLabel2_Click(object sender, EventArgs e)
{
ConfigHelper.AdvanceConfigForm.ShowEditDialog(this);
......
......@@ -40,10 +40,11 @@
this.faceButton1.BorderWidth = 2;
this.faceButton1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.faceButton1.HoldPress = false;
this.faceButton1.Location = new System.Drawing.Point(58, 155);
this.faceButton1.Location = new System.Drawing.Point(44, 124);
this.faceButton1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.faceButton1.Name = "faceButton1";
this.faceButton1.Padding = new System.Windows.Forms.Padding(3);
this.faceButton1.Size = new System.Drawing.Size(239, 64);
this.faceButton1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.faceButton1.Size = new System.Drawing.Size(179, 51);
this.faceButton1.TabIndex = 6;
this.faceButton1.Text = "OK";
this.faceButton1.Click += new System.EventHandler(this.faceButton1_Click);
......@@ -55,23 +56,26 @@
this.faceButton2.BorderWidth = 2;
this.faceButton2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.faceButton2.HoldPress = false;
this.faceButton2.Location = new System.Drawing.Point(394, 155);
this.faceButton2.Location = new System.Drawing.Point(296, 124);
this.faceButton2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.faceButton2.Name = "faceButton2";
this.faceButton2.Padding = new System.Windows.Forms.Padding(3);
this.faceButton2.Size = new System.Drawing.Size(239, 64);
this.faceButton2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.faceButton2.Size = new System.Drawing.Size(179, 51);
this.faceButton2.TabIndex = 7;
this.faceButton2.Text = "Modfiy";
this.faceButton2.Click += new System.EventHandler(this.faceButton2_Click);
//
// FrmDrawText
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(696, 335);
this.ClientSize = new System.Drawing.Size(506, 242);
this.Controls.Add(this.faceButton2);
this.Controls.Add(this.faceButton1);
this.Icon = ((System.Drawing.Bitmap)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "FrmDrawText";
this.Padding = new System.Windows.Forms.Padding(6, 6, 6, 6);
this.Text = "Using OCR Result";
this.Controls.SetChildIndex(this.faceButton1, 0);
this.Controls.SetChildIndex(this.faceButton2, 0);
......
......@@ -69,6 +69,7 @@ namespace SmartScan
LogNet.log.Info("读取关键字文件");
LogNet.log.Debug("关键字文件路径:" + FilePath.CONFIG_MACRO_KEY);
BLLCommon.macroKey = new();
BLLCommon.macroKeyValue = new();
if (System.IO.File.Exists(FilePath.CONFIG_MACRO_KEY))
{
......@@ -80,6 +81,16 @@ namespace SmartScan
{
LogNet.log.Debug("关键字文件路径不存在");
}
if (System.IO.File.Exists(FilePath.CONFIG_MACRO_Value))
{
string[] lines = System.IO.File.ReadAllLines(FilePath.CONFIG_MACRO_Value);
BLLCommon.macroKeyValue.AddRange(lines);
LogNet.log.Debug($"添加关键字 {lines.Length} 行");
}
else
{
LogNet.log.Debug("关键字文件路径不存在");
}
}
private void Shortcut()
......
......@@ -42,6 +42,8 @@ namespace SmartScan
this.BtnMatchedName = new Asa.FaceControl.FaceButton();
this.LblVersion = new Asa.FaceControl.FaceLabel();
this.LblUserName = new Asa.FaceControl.FaceLabel();
this.wpf_image = new System.Windows.Forms.Panel();
this.wpf_top = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// BtnStart
......@@ -167,12 +169,13 @@ namespace SmartScan
this.PicShow.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.PicShow.BorderWidth = 2;
this.PicShow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.PicShow.Location = new System.Drawing.Point(177, 55);
this.PicShow.Location = new System.Drawing.Point(224, 55);
this.PicShow.Name = "PicShow";
this.PicShow.Padding = new System.Windows.Forms.Padding(3);
this.PicShow.Size = new System.Drawing.Size(667, 722);
this.PicShow.Size = new System.Drawing.Size(620, 722);
this.PicShow.TabIndex = 10;
this.PicShow.Text = "facePictureBox1";
this.PicShow.Visible = false;
//
// PnlExtension
//
......@@ -198,7 +201,7 @@ namespace SmartScan
this.CboLanguage.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.CboLanguage.BorderWidth = 2;
this.CboLanguage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.CboLanguage.Location = new System.Drawing.Point(805, 11);
this.CboLanguage.Location = new System.Drawing.Point(782, 11);
this.CboLanguage.Name = "CboLanguage";
this.CboLanguage.Padding = new System.Windows.Forms.Padding(3);
this.CboLanguage.ReadOnly = true;
......@@ -258,10 +261,33 @@ namespace SmartScan
this.LblUserName.TabIndex = 15;
this.LblUserName.Text = "UserName";
//
// wpf_image
//
this.wpf_image.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.wpf_image.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.wpf_image.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.wpf_image.Location = new System.Drawing.Point(224, 55);
this.wpf_image.Margin = new System.Windows.Forms.Padding(0);
this.wpf_image.Name = "wpf_image";
this.wpf_image.Size = new System.Drawing.Size(538, 722);
this.wpf_image.TabIndex = 16;
this.wpf_image.Text = "facePictureBox1";
//
// wpf_top
//
this.wpf_top.Location = new System.Drawing.Point(2, 3);
this.wpf_top.Name = "wpf_top";
this.wpf_top.Size = new System.Drawing.Size(1451, 56);
this.wpf_top.TabIndex = 0;
//
// FrmMain
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1096, 788);
this.Controls.Add(this.wpf_top);
this.Controls.Add(this.wpf_image);
this.Controls.Add(this.PicShow);
this.Controls.Add(this.LblUserName);
this.Controls.Add(this.LblVersion);
......@@ -297,6 +323,8 @@ namespace SmartScan
this.Controls.SetChildIndex(this.LblVersion, 0);
this.Controls.SetChildIndex(this.LblUserName, 0);
this.Controls.SetChildIndex(this.PicShow, 0);
this.Controls.SetChildIndex(this.wpf_image, 0);
this.Controls.SetChildIndex(this.wpf_top, 0);
this.ResumeLayout(false);
}
......@@ -316,6 +344,8 @@ namespace SmartScan
private Asa.FaceControl.FaceLabel LblVersion;
private Asa.FaceControl.FaceLabel LblUserName;
public Asa.FaceControl.FacePictureBox PicShow;
private System.Windows.Forms.Panel wpf_image;
private System.Windows.Forms.Panel wpf_top;
}
}
using Asa.FaceControl;
using BLL;
using Model;
using SmartScan.SetControl.WPF;
using SmartScan.SetControl.WPF.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
......@@ -9,7 +11,10 @@ using System.IO;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan
{
......@@ -25,7 +30,88 @@ namespace SmartScan
public FrmRetrospect()
{
InitializeComponent();
ElementHost host= new ElementHost();
host.Dock = DockStyle.Fill;
var wpf = new WPF_Date_From();
// 订阅事件
wpf.MinimizeClicked += (s, e) => this.WindowState = FormWindowState.Minimized;
wpf.MaximizeClicked += (s, e) => {
if (this.WindowState == FormWindowState.Maximized)
this.WindowState = FormWindowState.Normal;
else
this.WindowState = FormWindowState.Maximized;
};
//启动服务事件
wpf.startservice += Wpf_startservice;
wpf.CloseClicked += (s, e) => this.Close();
// 订阅打印事件
wpf.PrintRequested += Wpf_PrintRequested;
host.Child = wpf;
panel1.Controls.Add(host);
}
private void Wpf_startservice(object sender, EventArgs e)
{
try
{
Process proes = new Process();
string servicename = ConfigHelper.Config.Get("Display_GetDataAppName");
var pss = Process.GetProcessesByName(servicename);
if (pss.Length > 0)
return;
var serverpath = Application.StartupPath + "\\" + ConfigHelper.Config.Get("Display_GetDataAppPath");
if (!File.Exists(serverpath))
throw new Exception("未找到服务文件!");
proes.StartInfo = new ProcessStartInfo
{
FileName = serverpath,
WorkingDirectory = System.IO.Path.Combine(Application.StartupPath, "ASTI"),
Verb = "runas" // 这里设置为 "runas" 表示以管理员身份运行
};
proes.StartInfo.UseShellExecute = false;
proes.Start();
}
catch (Exception)
{
}
}
private void Wpf_PrintRequested(object sender, Dictionary<string, string> printParameters)
{
if (printParameters != null && printParameters.Count > 0)
{
// 例如,记录日志
Console.WriteLine($"收到打印请求,参数数量: {printParameters.Count}");
// 访问打印参数
foreach (var param in printParameters)
{
Console.WriteLine($"键: {param.Key}, 值: {param.Value}");
}
// 调用WinForm中的打印方法
Print?.Invoke(printParameters);
}
else
{
string YU = BLLCommon.config.Language;
if (YU == "English")
{
bool result = NeoAlertBox.Show("", "No valid print parameters available?", 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);
}
}
}
private class HistoryPath
{
public string cameraPath = "";
......
......@@ -45,6 +45,7 @@ namespace SmartScan
this.BtnGenneralSetting.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnGenneralSetting.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnGenneralSetting.BorderWidth = 2;
this.BtnGenneralSetting.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnGenneralSetting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnGenneralSetting.HoldPress = false;
this.BtnGenneralSetting.Location = new System.Drawing.Point(11, 292);
......@@ -60,6 +61,7 @@ namespace SmartScan
this.BtnLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnLabel.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnLabel.BorderWidth = 2;
this.BtnLabel.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnLabel.HoldPress = false;
this.BtnLabel.Location = new System.Drawing.Point(11, 178);
......@@ -75,6 +77,7 @@ namespace SmartScan
this.BtnMaterial.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnMaterial.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnMaterial.BorderWidth = 2;
this.BtnMaterial.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnMaterial.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnMaterial.HoldPress = false;
this.BtnMaterial.Location = new System.Drawing.Point(11, 121);
......@@ -90,6 +93,7 @@ namespace SmartScan
this.BtnKeyword.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnKeyword.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnKeyword.BorderWidth = 2;
this.BtnKeyword.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnKeyword.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnKeyword.HoldPress = false;
this.BtnKeyword.Location = new System.Drawing.Point(11, 64);
......@@ -103,9 +107,10 @@ namespace SmartScan
// BtnOK
//
this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOK.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnOK.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(120)))), ((int)(((byte)(208)))));
this.BtnOK.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnOK.BorderWidth = 2;
this.BtnOK.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnOK.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOK.HoldPress = false;
this.BtnOK.Location = new System.Drawing.Point(641, 717);
......@@ -119,9 +124,10 @@ namespace SmartScan
// BtnCancel
//
this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(120)))), ((int)(((byte)(208)))));
this.BtnCancel.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnCancel.BorderWidth = 2;
this.BtnCancel.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnCancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnCancel.HoldPress = false;
this.BtnCancel.Location = new System.Drawing.Point(767, 717);
......@@ -153,9 +159,10 @@ namespace SmartScan
// BtnApply
//
this.BtnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnApply.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnApply.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(120)))), ((int)(((byte)(208)))));
this.BtnApply.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnApply.BorderWidth = 2;
this.BtnApply.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnApply.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnApply.HoldPress = false;
this.BtnApply.Location = new System.Drawing.Point(893, 717);
......@@ -171,6 +178,7 @@ namespace SmartScan
this.BtnDataSource.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnDataSource.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnDataSource.BorderWidth = 2;
this.BtnDataSource.Font = new System.Drawing.Font("微软雅黑", 14F);
this.BtnDataSource.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnDataSource.HoldPress = false;
this.BtnDataSource.Location = new System.Drawing.Point(11, 235);
......
......@@ -9,6 +9,11 @@ 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;
using SmartScan.SetControl.WPF.Model;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan
{
......@@ -23,12 +28,17 @@ namespace SmartScan
}
private void FrmSet_Load(object sender, EventArgs e)
{
menu.Add(BtnKeyword, new UsrMacro());
menu.Add(BtnMaterial, new UsrMaterialTemplate());
//menu.Add(BtnKeyword, new UsrMacro());
menu.Add(BtnKeyword, new UsrWpfPanel(new NS_Keyword()));
menu.Add(BtnMaterial, new UsrWpfPanel(new WPF_MaterialTemplate()));
menu.Add(BtnLabel, new UsrPrintTemplate());
menu.Add(BtnDataSource, new UsrDataSource());
menu.Add(BtnGenneralSetting, new UsrWorkMode());
// menu.Add(BtnIdentify, new UsrCamera());
//menu.Add(BtnGenneralSetting, new UsrWorkMode());
menu.Add(BtnGenneralSetting, new UsrWpfPanel(new WPFWorkMode()));
// menu.Add(aaa, new UsrWpfPanel(new WPF_MaterialTemplate()));
Language.LoadLanguage(BLLCommon.config.Language);
Language.SetLanguage(this);
......@@ -64,7 +74,9 @@ namespace SmartScan
foreach (FaceButton button in menu.Keys)
menu[button].Save();
string text = Language.Dialog(Model.LanguageDialogKey.SAVE_SUCCEED);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
bool result = NeoAlertBox.Show("", text, AlertType.Success, "NEO SCAN", true);
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
DialogResult = DialogResult.OK;
......@@ -80,8 +92,11 @@ namespace SmartScan
foreach (FaceButton button in menu.Keys)
menu[button].Save();
string text = Language.Dialog(Model.LanguageDialogKey.SAVE_SUCCEED);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
bool result = NeoAlertBox.Show("", text, AlertType.Success, "NEO SCAN", true);
BLLCommon.extension.Update();
}
}
}
......@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
......@@ -70,7 +70,7 @@ namespace SmartScan
this.MinimizeBox = false;
this.Name = "FrmWaitting";
this.ShowIcon = false;
this.Text = "运行中请稍后...";
this.Text = "运行中请稍后..."; this.Visible = false;
this.Load += new System.EventHandler(this.FrmWaitting_Load);
this.ResumeLayout(false);
......
......@@ -22,36 +22,36 @@ namespace SmartScan
public void SetMessage(string msg)
{
if (this.InvokeRequired)
{
this.Invoke(delegate ()
{
SetMessage(msg);
});
return;
}
//if (this.InvokeRequired)
//{
// this.Invoke(delegate ()
// {
// SetMessage(msg);
// });
// return;
//}
label1.Text = msg;
Application.DoEvents();
//label1.Text = msg;
//Application.DoEvents();
}
private void FrmWaitting_Load(object sender, EventArgs e)
{
this.Text = Language.Dialog("PleaseWaiting");//请稍后
this.label1.Text= Language.Dialog("PleaseWaiting");
faceLoading1.Start();
Task.Run(()=> {
Task.Delay(10 * 1000).Wait();
if (this.Created)
{
this.Invoke(delegate ()
{
if (!this.IsDisposed)
this.Close();
});
}
//this.Text = Language.Dialog("PleaseWaiting");//请稍后
//this.label1.Text= Language.Dialog("PleaseWaiting");
//faceLoading1.Start();
//Task.Run(()=> {
// Task.Delay(10 * 1000).Wait();
// if (this.Created)
// {
// this.Invoke(delegate ()
// {
// if (!this.IsDisposed)
// this.Close();
// });
// }
});
//});
}
}
}
......@@ -59,21 +59,21 @@ FrmMain_BtnAbout 关于 About Arial,14,B,
FrmMain_BtnTriggerIO 触发识别设备 Manual Scan Arial,9,,
FrmMain_LblCameraExist 识别设备连接 Camera Arial,9,,
FrmMain_LblIOExist IO模块连接 Machine Arial,9,,
FrmMain_PnlExtension 功能 Print Info. Arial,14,,
FrmMain_PnlExtension 元件信息 Print Info. Arial,14,,
FrmMain_BtnPrint 打印标签 Print Label Arial,12,,
FrmMain_BtnSkip 跳过 Skip Arial,12,,
FrmMain_labresult 等待中 Waiting Arial,12,,
FrmMain_DynamicButton 替换数据 Replacedata 微软雅黑,12,,
FrmSet_FrmSet 设置 Setting Arial,20,B,
FrmSet_BtnGenneralSetting 通用设置 General Setting Arial,12,B,
FrmSet_FrmSet 设置 Setting Arial,12,,
FrmSet_BtnGenneralSetting 通用设置 General Setting Arial,12,,
FrmSet_BtnIdentify 识别条码 Recognition Arial,12,B,
FrmSet_BtnLabel 打印模版 Print Template Arial,12,B,
FrmSet_BtnMaterial 物料模版 Material Template Arial,12,B,
FrmSet_BtnKeyword 关键字 Keyword Arial,12,B,
FrmSet_BtnLabel 打印模版 Print Template Arial,12,,
FrmSet_BtnMaterial 物料模版 Material Template Arial,12,,
FrmSet_BtnKeyword 关键字 Keyword Arial,12,,
FrmSet_BtnOK 保存 Save Arial,12,,
FrmSet_BtnCancel 取消 Cancel Arial,12,,
FrmSet_BtnApply 应用 Apply Arial,12,,
FrmSet_BtnDataSource 数据源 Source Arial,12,B,
FrmSet_BtnDataSource 数据源 Source Arial,12,,
FrmSetPlus_FrmSetPlus 条码规则设置 Barcode Rule Setting Arial,20,B,
FrmSetPlus_BtnWorkMode 工作模式 Config. Arial,12,B,
FrmSetPlus_BtnIdentify 识别条码 Recog. Arial,12,B,
......@@ -113,7 +113,7 @@ UsrWorkMode_ChkAllowModifyPrint 允许修改打印内容 Allow Modify Printing C
UsrCamera_UsrCamera
UsrCamera_BtnOpenLight 打开光源 Turn On Light Arial,12,,
UsrCamera_BtnCloseLight 关闭光源 Turn Off Light Arial,12,,
UsrCamera_BtnCameraImage 获取设备图像 Gain Device Image Arial,12,,
UsrCamera_BtnCameraImage 获取设备图像 Gain Device Image Arial,11,,
UsrCamera_BtnLocalImage 打开本地图片 Open Local Image Arial,12,,
UsrCamera_BtnScanCode 识别条码 Recognition Arial,12,,
UsrCamera_BtnSaveImage 保存图像 Save Image Arial,12,,
......@@ -121,7 +121,7 @@ UsrCamera_LstCode Arial,12,,
UsrPrintTemplate_UsrPrintTemplate
UsrPrintTemplate_BtnAddLabel 新建标签 New Arial,12,,
UsrPrintTemplate_BtnDelLabel 删除标签 Delete Label Arial,12,,
UsrPrintTemplate_BtnCopyLabel 复制标签 Duplicate Label Arial,12,,
UsrPrintTemplate_BtnCopyLabel 复制标签 Duplicate Label Arial,11,,
UsrPrintTemplate_BtnRenameLabel 重命名 Rename Arial,12,,
UsrPrintTemplate_BtnPrintTest 打印测试 Print Test Arial,12,,
UsrPrintTemplate_BtnAddField 添加字段 Add Filed Arial,12,,
......@@ -146,14 +146,14 @@ UsrMaterialTemplate_BtnDelMate 删除模板 Delete Arial,12,,
UsrMaterialTemplate_BtnRenameMate 重命名 Rename Arial,12,,
UsrMaterialTemplate_BtnOpenLight 打开光源 Turn On Light Arial,12,,
UsrMaterialTemplate_BtnCloseLight 关闭光源 Turn Off Light Arial,12,,
UsrMaterialTemplate_BtnCameraImage 获取设备图像 Gain Device Image Arial,12,,
UsrMaterialTemplate_BtnCameraImage 获取设备图像 Gain Device Image Arial,11,,
UsrMaterialTemplate_BtnLocalImage 打开本地图片 Open Local Image Arial,12,,
UsrMaterialTemplate_BtnScanCode 识别 Recognition Arial,12,,
UsrMaterialTemplate_BtnExtractCode 提取 Extract Arial,12,,
UsrMaterialTemplate_BtnOcrCode OCR OCR Arial,12,,
UsrMaterialTemplate_BtnPrimaryCode 特征码 Set Primary Code Arial,12,,
UsrMaterialTemplate_BtnSaveImage 图片另存 Save As Arial,12,,
UsrMaterialTemplate_BtnTemplateValite 模板验证 Template Validation Arial,12,,
UsrMaterialTemplate_BtnTemplateValite 模板验证 Template Validation Arial,11,,
UsrMaterialTemplate_pnlMaterial 模板 Template Arial,12,,
UsrMaterialTemplate_pnlMaterialOp 模板操作 Template Operation Arial,12,,
UsrMaterialTemplate_pnlCode 条码 Barcode Arial,12,,
......@@ -304,3 +304,107 @@ 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
BtnStart 开始 Start
BtnRetrospect 追溯 Traceability
BtnSet 设置 Setting
BtnAI AI AI
BtnAbout 关于 About
BtnTriggerIO 图片识别 Image recognition
LblCameraExist 识别设备连接 Camera
LblIOExist IO模块连接 Machine
setting 配置 Configuration
NS_KW_identifier 字段标识符 Field Identifier
NS_KW_Display_name 显示名称 Display Name
NS_KW_api API和数据库中使用的唯一标识符 API and unique identifier used in the database
NS_KW_name 在界面中显示的名称 Name displayed in interface
NS_KW_ID 唯一键自增 Auto-increment for unique keys
LblContent 生成条件 Generation Conditions
LblPrefix 开头字符 Starting Characters
LblPostfix 结尾字符 Ending Characters
LblPlaces 数字位数 Number of Digits
NS_KW_WEISHU 位数不足前面补 Pad with zeros in front if digits are insufficient
NS_KW_H 标准字段 Standard field
UsrMacro_btn_1 < <
UsrMacro_btn_2 > >
VMC_Main_operation 主要操作 Main Operation
VMC_Image_control 图像控制 Image Control
ns_Pring 打印标签 Print Label
WPF_pring 打印方式 Printing Mode
RdoLandscape 横向打印 Landscape
RdoVertical 纵向打印 Portrait
WPF_camerasave 追溯图像保存 Save Retroactive Image
RdoOriginal 原图 Original
RdoCondense 压缩图像 Compressed Image
RdoNoImage 不保存 Skip Saving
WPF_Advanced_Options 高级选项 Advanced Options
ChkLabelEmptyCheck 打印版签空白内容提醒 Empty Label Alert
ChkSelectPN 从服务器查询PN Query PN From The Server
ChkPrintCompletedClear 打印版签后清除内容 Print&Clear
ChkOpenEnterWork 打开软件自动进入工作模式 Auto Start Mode
ChkOpenMaximize 打开软件最大化窗口 Always Open Maximized
ChkTriggerOpenLight 触发信号后自动开启光源 Turn On Light After Triggering Device
ChkPromptAfterPrinting 识别完成后提示 Prompt After Recognition Is Complete
ChkAutoPrint 自动打印 Auto Print
ChkAllowModifyPrint 允许修改打印内容 Allow Modify Printing Content
ChkCheckFunction Check功能 CheckFunction
PrinterInfoGridtext 打印机 Printer
PrinterInfoGridtext1 默认打印标签 Default Print Template
PrinterInfoGridtext2 优先匹配模板 Prioritize Match Template
NS_ISENABLE 是否启用 IsEnable
UsrMaterialTemplate_TxtAddMate + +
UsrMaterialTemplate_txtRenameMate ✎ ✎
UsrMaterialTemplate_txtDelMate - -
Camera_status 相机状态 Camera status
LblIOExists IO模块连接 Machine
UsrPrintTemplate_LblFieldSize 纸张大小 Paper size 微软雅黑,12,B,
Unique_code_generator 唯一码生成器 Unique Code Generator
Generate_keywords 生成字符 Generate Character
kesadd 选择关键词(点击添加) Select keywords (click to add)
Preview 唯一码预览: Unique code preview:
Reset 重置 Resets
Generate_a_unique_code 生成唯一码 Generate a unique code
BtnAutoId 唯一键自增 Auto-increment for unique keys
lbl_Green 绿色 - 完全正确 Green - Completely correct
lbl_yellow 黄色 - OCR识别结果,需要验证 Yellow - OCR recognition result, needs verification
lbl_red 红色 - 无法识别或有问题 Red -Unable to recognize or has issues
Rule 添加字符 Add Character
VMC_System_status 系统状态 System status
Barcode_content 条码内容 Barcode Content
WPF_FrmCodeExtract 提取条码 Extract Barcode
WPF_Condition 匹配条件 Matching Conditions
ChkCheckCodeType 条码类型 Barcode Type
ChkMatchingStart 开头字符 Starting Characters
ChkMatchingEnd 结尾字符 Ending Characters
ChkMatchingMiddle 任意位置字符 Characters at Any Position
WPF_COUNT 匹配次数: Match Count:
ChkCaseSensitivity 区分大小写 Case Sensitive
Characteristicbarcode 特征码 Feature Code
WPF_KEYS 关键字 Keywords
WPF_Add 添加 Add
WPF_Delect 删除 Delete
WPF_Reslues 解析结果 Parsing Result
WPF_Set 提取设置 Extraction Settings
WPF_ChooseKeys 选择关键字: Select Keyword:
ChkSplitBarcode 条码分割字符 Barcode Split Character
WPF_CHkSplit 获取分割部分: Get Split Part:
WPF_CHkSplitStart 截取起始位置: Substring Start Position:
WPF_SplitLenght 截取长度: Substring Length:
ChkMustBeNumber 必须为数字 Must Be Numeric
ChkExtractToEnd 截取至结尾 Extract to End
ChkMinLength 最小长度 Minimum Length
ChkMaxLength 最大长度 Maximum Length
WPF_Ok 确定 OK
WPF_ng 取消 Cancel
BtnMinimize - -
BtnMaximize □ □
BtnClose × ×
WPF_PringBehavior 打印行为 Printing behavior
WPF_Software 软件设置 Software Settings
WPF_API 数据源设置 API Setting
Serial_number 添加流水 Add the serial number
xianshi 已选关键词(按显示顺序排列) Selected keywords (arranged according to display order)
\ No newline at end of file
......@@ -58,27 +58,27 @@ FrmMain_BtnAbout 关于 关于 微软雅黑,14,B,
FrmMain_BtnTriggerIO 触发识别设备 触发识别设备 微软雅黑,9,,
FrmMain_LblCameraExist 识别设备连接 识别设备连接 微软雅黑,9,,
FrmMain_LblIOExist IO模块连接 IO模块连接 微软雅黑,9,,
FrmMain_PnlExtension 功能 功能 微软雅黑,14,,
FrmMain_PnlExtension 元件信息 元件信息 微软雅黑,14,,
FrmMain_BtnPrint 打印标签 打印标签 微软雅黑,12,,
FrmMain_DynamicButton 替换数据 替换数据 微软雅黑,12,,
FrmMain_BtnSkip 跳过 跳过 Arial,12,,
FrmMain_labresult 等待中 等待中 Arial,12,,
FrmSet_FrmSet 设置 设置 微软雅黑,20,B,
FrmSet_BtnGenneralSetting 通用设置 通用设置 微软雅黑,12,B,
FrmSet_FrmSet 设置 设置 微软雅黑,12,B,
FrmSet_BtnGenneralSetting 通用设置 通用设置 微软雅黑,12,,
FrmSet_BtnIdentify 识别条码 识别条码 微软雅黑,12,B,
FrmSet_BtnLabel 打印模版 打印模版 微软雅黑,12,B,
FrmSet_BtnMaterial 物料模版 物料模版 微软雅黑,12,B,
FrmSet_BtnKeyword 关键字 关键字 微软雅黑,12,B,
FrmSet_BtnLabel 打印模版 打印模版 微软雅黑,12,,
FrmSet_BtnMaterial 物料模版 物料模版 微软雅黑,12,,
FrmSet_BtnKeyword 关键字 关键字 微软雅黑,12,,
FrmSet_BtnOK 保存 保存 微软雅黑,12,,
FrmSet_BtnCancel 取消 取消 微软雅黑,12,,
FrmSet_BtnApply 应用 应用 微软雅黑,12,,
FrmSet_BtnDataSource 数据源 数据源 微软雅黑,12,B,
FrmSet_BtnDataSource 数据源 数据源 微软雅黑,12,,
FrmSetPlus_FrmSetPlus 条码规则设置 条码规则设置 微软雅黑,20,B,
FrmSetPlus_BtnWorkMode 工作模式 工作模式 微软雅黑,12,B,
FrmSetPlus_BtnIdentify 识别条码 识别条码 微软雅黑,12,B,
FrmSetPlus_BtnLabel 打印模版 打印模版 微软雅黑,12,B,
FrmSetPlus_BtnMaterial 物料模版 物料模版 微软雅黑,12,B,
FrmSetPlus_BtnKeyword 关键字 关键字 微软雅黑,12,B,
FrmSetPlus_BtnLabel 打印模版 打印模版 微软雅黑,14,B,
FrmSetPlus_BtnMaterial 物料模版 物料模版 微软雅黑,12,,
FrmSetPlus_BtnKeyword 关键字 关键字 微软雅黑,12,,
FrmSetPlus_BtnOK 保存 保存 微软雅黑,12,,
FrmSetPlus_BtnCancel 取消 取消 微软雅黑,12,,
FrmSetPlus_BtnApply 应用 应用 微软雅黑,12,,
......@@ -129,6 +129,7 @@ UsrPrintTemplate_BtnSetField 设置字段内容 设置字段内容 微软雅黑,
UsrPrintTemplate_LblFieldType 条形码类型 条形码类型 微软雅黑,12,B,
UsrPrintTemplate_ChkFieldShowKey 显示关键字 显示关键字 微软雅黑,12,,
UsrPrintTemplate_LblFieldX X(mm) X(mm) 微软雅黑,12,B,
UsrPrintTemplate_LblFieldSize 纸张大小 纸张大小 微软雅黑,12,B,
UsrPrintTemplate_LblFieldY Y(mm) Y(mm) 微软雅黑,12,B,
UsrPrintTemplate_LblFieldW W(mm) W(mm) 微软雅黑,12,B,
UsrPrintTemplate_LblFieldH L(mm) L(mm) 微软雅黑,12,B,
......@@ -179,6 +180,8 @@ UsrMacro_LblPostfix 结尾字符串 结尾字符串 微软雅黑,10,,
UsrMacro_LblPlaces 数字位数 数字位数 微软雅黑,10,,
UsrMacro_ChkReelIDFillZero 位数不足前面补0 位数不足前面补0 微软雅黑,12,,
UsrMacro_btn_adddatetime 添加日期时间 添加日期时间 微软雅黑,12,,
UsrMacro_btn_1 < <
UsrMacro_btn_2 > >
UsrCodeExtractList_UsrCodeExtractList
UsrCodeExtractList_ChkMatchingStart 开头字符 开头字符 微软雅黑,12,,
UsrCodeExtractList_ChkMatchingEnd 结尾字符 结尾字符 微软雅黑,12,,
......@@ -270,7 +273,6 @@ FrmDataFilePreview_BtnCancel 取消 取消 微软雅黑,12,,
FrmDataFilePreview_BtnOK 确认 确认 微软雅黑,12,,
FrmDataFilePreview_LblEncoding 编码格式 编码格式 微软雅黑,12,,
FrmDataFilePreview_FrmDataFilePreview 文件预览 文件预览 微软雅黑,12,,
UsrWorkMode2_ChkAutoPrint 自动打印 自动打印 Arial,12,,
UsrWorkMode2_ChkPromptAfterPrinting 打印完成后提示 打印完成后提示 Arial,12,,
UsrWorkMode2_ChkTriggerOpenLight 触发信号亮灯 触发信号亮灯 Arial,12,,
......@@ -353,3 +355,105 @@ 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
BtnStart 开始 开始
BtnRetrospect 追溯 追溯
BtnSet 设置 设置
BtnAI AI AI
BtnAbout 关于 关于
BtnTriggerIO 图片识别 本地图片识别
LblCameraExist 识别设备连接 识别设备连接
LblIOExist IO模块连接 IO模块连接
setting 配置 配置
NS_KW_identifier 字段标识符 字段标识符
NS_KW_Display_name 显示名称 显示名称
NS_KW_api API和数据库中使用的唯一标识符 API和数据库中使用的唯一标识符
NS_KW_name 在界面中显示的名称 在界面中显示的名称
NS_KW_ID 唯一键自增 唯一键自增
LblContent 生成条件 生成条件
LblPrefix 开头字符 开头字符
LblPostfix 结尾字符 结尾字符
LblPlaces 数字位数 数字位数
NS_KW_WEISHU 位数不足前面补0 位数不足前面补0
NS_KW_H 标准字段 标准字段
VMC_Main_operation 主要操作 主要操作
VMC_Image_control 图像控制 图像控制
ns_Pring 打印标签 打印标签
WPF_pring 打印方式 打印方式
RdoLandscape 横向打印 横向打印
RdoVertical 纵向打印 纵向打印
WPF_camerasave 追溯图像保存 追溯图像保存
RdoOriginal 原图 原图
RdoCondense 压缩图像 压缩图像
RdoNoImage 不保存 不保存
WPF_Advanced_Options 高级选项 高级选项
ChkLabelEmptyCheck 打印版签空白内容提醒 打印版签空白内容提醒
ChkSelectPN 从服务器查询PN 从服务器查询PN
ChkPrintCompletedClear 打印版签后清除内容 打印版签后清除内容
ChkOpenEnterWork 打开软件自动进入工作模式 打开软件自动进入工作模式
ChkOpenMaximize 打开软件最大化窗口 打开软件最大化窗口
ChkTriggerOpenLight 触发信号后自动开启光源 触发信号后自动开启光源
ChkPromptAfterPrinting 识别完成后提示 识别完成后提示
ChkAutoPrint 自动打印 自动打印
ChkAllowModifyPrint 允许修改打印内容 允许修改打印内容
ChkCheckFunction Check功能 Check功能
PrinterInfoGridtext 打印机 打印机
PrinterInfoGridtext1 默认打印标签 默认打印标签
PrinterInfoGridtext2 优先匹配模板 优先匹配模板
NS_ISENABLE 是否启用 是否启用
ShowLog 报警信息 等待运行
UsrMaterialTemplate_TxtAddMate + +
UsrMaterialTemplate_txtRenameMate ✎ ✎
UsrMaterialTemplate_txtDelMate - -
Camera_status 相机状态 相机状态
LblIOExists IO模块连接 IO模块
Unique_code_generator 唯一码生成器 唯一码生成器
Generate_keywords 生成字符 生成字符
kesadd 选择关键词(点击添加) 选择关键词(点击添加)
Preview 唯一码预览: 唯一码预览:
Reset 重置 重置
Generate_a_unique_code 生成唯一码 生成唯一码
BtnAutoId 唯一键自增 唯一键自增
lbl_Green 绿色 - 完全正确 绿色 - 完全正确
lbl_yellow 黄色 - OCR识别结果,需要验证 黄色 - OCR识别结果,需要验证
lbl_red 红色 - 无法识别或有问题 红色 - 无法识别或有问题
Rule 添加字符 添加字符
VMC_System_status 系统状态 系统状态
Barcode_content 条码内容 条码内容
WPF_FrmCodeExtract 提取条码 提取条码
WPF_Condition 匹配条件 匹配条件
ChkCheckCodeType 条码类型 条码类型
ChkMatchingStart 开头字符 开头字符
ChkMatchingEnd 结尾字符 结尾字符
ChkMatchingMiddle 任意位置字符 任意位置字符
WPF_COUNT 匹配次数: 匹配次数:
ChkCaseSensitivity 区分大小写 区分大小写
Characteristicbarcode 特征码 特征码
WPF_KEYS 关键字 关键字
WPF_Add 添加 添加
WPF_Delect 删除 删除
WPF_Reslues 解析结果 解析结果
WPF_Set 提取设置 提取设置
WPF_ChooseKeys 选择关键字: 选择关键字:
ChkSplitBarcode 条码分割字符 条码分割字符
WPF_CHkSplit 获取分割部分: 获取分割部分:
WPF_CHkSplitStart 截取起始位置: 截取起始位置:
WPF_SplitLenght 截取长度: 截取长度:
ChkMustBeNumber 必须为数字 必须为数字
ChkExtractToEnd 截取至结尾 截取至结尾
ChkMinLength 最小长度 最小长度
ChkMaxLength 最大长度 最大长度
WPF_Ok 确定 确定
WPF_ng 取消 取消
BtnMinimize - -
BtnMaximize □ □
BtnClose × ×
WPF_PringBehavior 打印行为 打印行为
WPF_Software 软件设置 软件设置
WPF_API 数据源设置 API设置
Serial_number 添加流水 添加流水
xianshi 已选关键词(按显示顺序排列) 已选关键词(按显示顺序排列)
\ No newline at end of file
using BLL;
using SmartScan.SetControl.WPF.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -8,6 +9,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan.PlusSettingFrm
{
......@@ -23,9 +25,21 @@ namespace SmartScan.PlusSettingFrm
private void faceButton1_Click(object sender, EventArgs e)
{
if (keyList.SelectedIndex==-1)
if (keyList.SelectedIndex==-1)
{
MessageBox.Show("请选择关键字!");
string YU = BLLCommon.config.Language;
if (YU == "English")
{
bool result = NeoAlertBox.Show("", "No keyword selected!", 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;
}
keyname = keyList.SelectedText;
......
using BLL;
using Asa.FaceControl;
using BLL;
using DocumentFormat.OpenXml.Drawing;
using Model;
using SmartScan.Properties;
using SmartScan.SetControl.WPF;
using System;
using System.Collections.Generic;
using System.Diagnostics;
......@@ -90,9 +94,10 @@ namespace SmartScan
}
}
}
return;
}
Asa.FaceControl.ThemeConfig.DefaultThemeColor = new DarkThemeColor2();
if (!isShow)
{
Application.EnableVisualStyles();
......@@ -135,9 +140,35 @@ namespace SmartScan
Application.Run(Common.frmMain);
}
}
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);
}else if (languge == "日语")
{
}
}
private static bool IsRun()
{
Process current = Process.GetCurrentProcess();
......@@ -156,7 +187,7 @@ namespace SmartScan
LogNet.log.Info("=====准备退出...=====");
BLLCommon.lightSource.Close();
BLLCommon.ioModule?.Close();
Camera.Dispose();
BLL.Camera.Dispose();
WebService.Close();
LogNet.log.Info("=====程序结束=====\r\n");
}
......
......@@ -229,7 +229,18 @@ namespace SmartScan.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap AI
{
get
{
object obj = ResourceManager.GetObject("Ai", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
......
......@@ -391,7 +391,7 @@ namespace SmartScan
{
if (codeIndex == -1)
{
string text = Language.Dialog(LanguageDialogKey.REMIND_SELECTCODE, "请选择一个条码");
string text = Language.Dialog(LanguageDialogKey.REMIND_SELECTCODE, "请选择一个条码!");
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return;
}
......
......@@ -30,6 +30,7 @@ namespace SmartScan
private void InitializeComponent()
{
this.facePanel1 = new Asa.FaceControl.FacePanel();
this.ChkCheckFunction = new Asa.FaceControl.FaceCheckBox();
this.but_Readfileprint = new System.Windows.Forms.Button();
this.ChkAllowModifyPrint = new Asa.FaceControl.FaceCheckBox();
this.ChkAutoPrint = new Asa.FaceControl.FaceCheckBox();
......@@ -52,7 +53,6 @@ namespace SmartScan
this.RdoCondense = new Asa.FaceControl.FaceRadioBox();
this.RdoOriginal = new Asa.FaceControl.FaceRadioBox();
this.LblHistoryImage = new Asa.FaceControl.FaceLabel();
this.ChkCheckFunction = new Asa.FaceControl.FaceCheckBox();
this.facePanel1.SuspendLayout();
this.SuspendLayout();
//
......@@ -94,6 +94,21 @@ namespace SmartScan
this.facePanel1.Text = "facePanel1";
this.facePanel1.TitleFont = new System.Drawing.Font("宋体", 12F);
//
// ChkCheckFunction
//
this.ChkCheckFunction.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.ChkCheckFunction.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.ChkCheckFunction.BorderWidth = 0;
this.ChkCheckFunction.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ChkCheckFunction.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.ChkCheckFunction.Location = new System.Drawing.Point(261, 646);
this.ChkCheckFunction.Name = "ChkCheckFunction";
this.ChkCheckFunction.Padding = new System.Windows.Forms.Padding(3);
this.ChkCheckFunction.Size = new System.Drawing.Size(453, 35);
this.ChkCheckFunction.TabIndex = 20;
this.ChkCheckFunction.Text = "Check功能";
this.ChkCheckFunction.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// but_Readfileprint
//
this.but_Readfileprint.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
......@@ -423,21 +438,6 @@ namespace SmartScan
this.LblHistoryImage.Text = "追溯图像保存";
this.LblHistoryImage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// ChkCheckFunction
//
this.ChkCheckFunction.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.ChkCheckFunction.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.ChkCheckFunction.BorderWidth = 0;
this.ChkCheckFunction.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ChkCheckFunction.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.ChkCheckFunction.Location = new System.Drawing.Point(261, 646);
this.ChkCheckFunction.Name = "ChkCheckFunction";
this.ChkCheckFunction.Padding = new System.Windows.Forms.Padding(3);
this.ChkCheckFunction.Size = new System.Drawing.Size(453, 35);
this.ChkCheckFunction.TabIndex = 20;
this.ChkCheckFunction.Text = "Check功能";
this.ChkCheckFunction.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// UsrWorkMode
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......
......@@ -8,6 +8,8 @@ using Asa.FaceControl;
using BLL;
using ClosedXML.Excel;
using Model;
using SmartScan.SetControl.WPF.Model;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan
{
......@@ -140,7 +142,20 @@ namespace SmartScan
Dictionary<int, Dictionary<string, string>> valuePairs = new Dictionary<int, Dictionary<string, string>>();
if (!File.Exists(filepath))
{
MessageBox.Show("文件不存在");
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);
......
<UserControl x:Class="SmartScan.SetControl.WPF.AboutWindowHost"
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="339" d:DesignWidth="486">
<UserControl.Resources>
<LinearGradientBrush x:Key="LogoBrush" StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#0077cc" Offset="0"/>
<GradientStop Color="#00ccff" Offset="1"/>
</LinearGradientBrush>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 标题栏 -->
<Grid Grid.Row="0" Background="#1E1E1E">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image Source="/Resources/App.png" Name="logos" />
<TextBlock Grid.Column="0" Text="关于" Foreground="White" FontSize="14" FontFamily="微软雅黑"
HorizontalAlignment="Center" Grid.ColumnSpan="3" VerticalAlignment="Center" Name="text1"/>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width="30" Height="30" Content="−" Background="Transparent"
Foreground="White" BorderThickness="0" Name="minimizeButton"/>
<Button Width="30" Height="30" Content="×" Background="Transparent"
Foreground="White" BorderThickness="0" Name="closeButton"/>
</StackPanel>
</Grid>
<!-- 内容区域 -->
<Grid Grid.Row="1" Background="#121212">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="/Resources/App.png" Width="400" />
<TextBlock Text="物料注册系统" FontSize="28" Foreground="White" FontFamily="微软雅黑"
HorizontalAlignment="Center" Margin="0,0,0,30" Name="text2"/>
<TextBlock Text="4.1.9238.19114" FontSize="18" Foreground="#666666"
HorizontalAlignment="Center" Margin="0,0,0,10" x:Name="versionTextBlock" MouseLeftButtonDown="VersionTextBlock_MouseLeftButtonDown"/>
</StackPanel>
</Grid>
</Grid>
</UserControl>
using BLL;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// AboutWindowHost.xaml 的交互逻辑
/// </summary>
public partial class AboutWindowHost : UserControl
{ // 声明一个事件,用于通知WinForms宿主关闭窗口
public event EventHandler CloseRequested;
public event EventHandler MinimizeRequested;
// 声明一个事件,用于通知WinForms宿主处理版本号点击
public event EventHandler VersionTextClicked;
public AboutWindowHost()
{
InitializeComponent();
// 假设您有关闭和最小化按钮,需要为它们添加事件处理
closeButton.Click += (s, e) => CloseRequested?.Invoke(this, EventArgs.Empty);
minimizeButton.Click += (s, e) => MinimizeRequested?.Invoke(this, EventArgs.Empty);
this.Loaded += (s, e) => {
if (logos is Image img)
{
// 将WinForms资源转换为WPF可用的BitmapSource
System.Drawing.Bitmap winFormsBitmap = global::SmartScan.Properties.Resources.App;
if (winFormsBitmap != null)
{
var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
winFormsBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
img.Source = bitmapSource;
}
}
};
string YU = BLLCommon.config.Language;
if (YU == "English")
{
text1.Text = "About";
text2.Text = "Material Registration System";
}
else if (YU=="日语")
{
text1.Text = "About";
text2.Text = "材料登録システム";
}
else
{
text1.Text ="关于";
text2.Text = "物料注册系统";
}
}
private void VersionTextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// 触发事件通知宿主
VersionTextClicked?.Invoke(this, EventArgs.Empty);
}
// 可选:添加属性来设置版本号文本
public string VersionInfo
{
get { return versionTextBlock.Text; }
set { versionTextBlock.Text = value; }
}
}
}
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();
}
}
}
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 BoolToColorConverter1 : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? new SolidColorBrush(Color.FromRgb(0, 120, 215)) : new SolidColorBrush(Colors.Transparent);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
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;
namespace SmartScan.SetControl.WPF.Convent
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return boolValue ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Visibility visibility)
{
return visibility == Visibility.Visible;
}
return false;
}
}
}
using BLL;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace SmartScan.SetControl.WPF.Convent
{
public class IsAutoIdFieldConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string fieldName)
{
// 检查字段名是否为当前设置的自增ID字段
return fieldName == BLLCommon.config.ReelIDKeyWord && !string.IsNullOrEmpty(BLLCommon.config.ReelIDKeyWord);
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
namespace SmartScan.SetControl.WPF.Convent
{
public class OcrTextHighlighterConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
string text = value.ToString();
// 创建一个TextBlock
TextBlock textBlock = new TextBlock
{
TextWrapping = TextWrapping.Wrap,
HorizontalAlignment = HorizontalAlignment.Stretch
};
// 检查文本是否包含"<OCR>"
int ocrIndex = text.IndexOf("<OCR>", StringComparison.OrdinalIgnoreCase);
if (ocrIndex < 0)
{
// 如果不包含OCR标记,直接添加整个文本
textBlock.Inlines.Add(new Run(text) { Foreground = Brushes.White });
}
else
{
// 添加OCR标记前的文本
if (ocrIndex > 0)
{
textBlock.Inlines.Add(new Run(text.Substring(0, ocrIndex)) { Foreground = Brushes.White });
}
// 添加红色的OCR标记
textBlock.Inlines.Add(new Run("<OCR>") { Foreground = Brushes.Red });
// 添加OCR标记后的文本
if (ocrIndex + 5 < text.Length)
{
textBlock.Inlines.Add(new Run(text.Substring(ocrIndex + 5)) { Foreground = Brushes.White });
}
}
return textBlock;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace SmartScan.SetControl.WPF.Convent
{
public class WidthMinusMarginConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double width)
{
// 根据需要调整这个值,减去滚动条宽度、边距等
return width - 30; // 30是一个估计值,调整为你需要的边距
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.ImageViewerControl"
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"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
>
<UserControl.Resources>
<!-- 按钮样式 -->
<Style x:Key="ImageViewerButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3E3E3E"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#555555"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#222222"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 图片显示区域 -->
<!-- 使用Zoombox替换原来的ScrollViewer和Image -->
<ScrollViewer x:Name="scrollViewer"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
Grid.Row="0"
MouseWheel="ScrollViewer_MouseWheel"
Background="#1E1E1E">
<Grid x:Name="imageContainer" HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image x:Name="mainImage"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="imageScaleTransform" ScaleX="1" ScaleY="1"/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Canvas x:Name="centerPointsCanvas" IsHitTestVisible="False" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ScrollViewer>
<!-- 控制按钮区域 -->
<Border Grid.Row="1" Background="#2D2D30">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8,0,8">
<!-- 放大按钮 -->
<Button x:Name="zoomInButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="ZoomInButton_Click"
ToolTip="放大">
<TextBlock Text="+" FontSize="16" FontWeight="Bold"/>
</Button>
<!-- 缩小按钮 -->
<Button x:Name="zoomOutButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="ZoomOutButton_Click"
ToolTip="缩小">
<TextBlock Text="-" FontSize="16" FontWeight="Bold"/>
</Button>
<!-- 适应屏幕按钮 -->
<Button x:Name="fitToScreenButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="FitToScreenButton_Click"
ToolTip="适应屏幕">
<Viewbox Width="16" Height="16">
<Path Data="M21,15H23V17H21V15M21,11H23V13H21V11M23,19H21V21C22.1,21 23,20.1 23,19M13,3H15V5H13V3M21,7H23V9H21V7M21,3V5H23C23,3.9 22.1,3 21,3M1,7H3V9H1V7M17,3H19V5H17V3M17,19H19V21H17V19M3,3C1.9,3 1,3.9 1,5H3V3M9,3H11V5H9V3M5,3H7V5H5V3M1,11H3V13H1V11M3,21V19H1C1,20.1 1.9,21 3,21M3,15H1V17H3V15M9,19H11V21H9V19M13,19H15V21H13V19M5,19H7V21H5V19Z"
Fill="White"
Stretch="Uniform" />
</Viewbox>
</Button>
</StackPanel>
</Border>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.IO;
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>
/// ImageViewerControl.xaml 的交互逻辑
/// </summary>
public partial class ImageViewerControl : UserControl
{
private const double MinZoom = 0.1;
private const double MaxZoom = 5.0;
private const double ZoomIncrement = 0.1;
private System.Drawing.PointF[] originalCenters;
public ImageViewerControl()
{
InitializeComponent();
// 当控件大小改变时自动调整图片大小
this.SizeChanged += (sender, e) => {
if (mainImage.Source != null)
{
FitToScreen();
}
};
// 当ScrollViewer大小改变时调整图片
scrollViewer.SizeChanged += (sender, e) => {
if (mainImage.Source != null)
{
FitToScreen();
}
};
}
/// <summary>
/// 从流中加载图片
/// </summary>
public void LoadImageFromStream(Stream stream)
{
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();
mainImage.Source = bitmapImage;
// 重置缩放
//imageScaleTransform.ScaleX = 1.0;
//imageScaleTransform.ScaleY = 1.0;
// 清除先前的中心点
centerPointsCanvas.Children.Clear();
// 图片加载后适应屏幕
// 延迟调用,确保布局已更新
Dispatcher.BeginInvoke(new Action(FitToScreen), System.Windows.Threading.DispatcherPriority.Loaded);
}
/// <summary>
/// 在图片上绘制代码中心点
/// </summary>
public void DrawCodeCenters(System.Drawing.PointF[] centers)
{
centerPointsCanvas.Children.Clear();
originalCenters = centers;
if (centers == null || centers.Length == 0 || mainImage.Source == null)
return;
RedrawCenters();
}
/// <summary>
/// 根据当前缩放比例重新绘制中心点
/// </summary>
private void RedrawCenters()
{
if (originalCenters == null || originalCenters.Length == 0 || mainImage.Source == null)
return;
centerPointsCanvas.Children.Clear();
// 获取图像的实际显示尺寸
var imageSource = (BitmapSource)mainImage.Source;
double scaleX = imageScaleTransform.ScaleX;
double scaleY = imageScaleTransform.ScaleY;
// 计算图像在控件中的实际位置
double offsetX = (scrollViewer.ViewportWidth - imageSource.PixelWidth * scaleX) / 2;
double offsetY = (scrollViewer.ViewportHeight - imageSource.PixelHeight * scaleY) / 2;
// 调整Canvas大小与图像显示尺寸一致
centerPointsCanvas.Width = imageSource.PixelWidth * scaleX;
centerPointsCanvas.Height = imageSource.PixelHeight * scaleY;
foreach (var point in originalCenters)
{
// 创建椭圆表示中心点
Ellipse ellipse = new Ellipse
{
Width = 10,
Height = 10,
Fill = Brushes.Red,
Stroke = Brushes.White,
StrokeThickness = 2
};
// 设置椭圆位置,只考虑缩放,不考虑偏移
Canvas.SetLeft(ellipse, point.X * scaleX - ellipse.Width / 2);
Canvas.SetTop(ellipse, point.Y * scaleY - ellipse.Height / 2);
centerPointsCanvas.Children.Add(ellipse);
}
}
/// <summary>
/// 放大按钮点击事件
/// </summary>
private void ZoomInButton_Click(object sender, RoutedEventArgs e)
{
if (imageScaleTransform.ScaleX < MaxZoom)
{
imageScaleTransform.ScaleX += ZoomIncrement;
imageScaleTransform.ScaleY += ZoomIncrement;
// 显示滚动条,因为放大后可能需要滚动查看图像细节
if (imageScaleTransform.ScaleX > 1.0)
{
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
}
RedrawCenters();
}
}
/// <summary>
/// 缩小按钮点击事件
/// </summary>
private void ZoomOutButton_Click(object sender, RoutedEventArgs e)
{
if (imageScaleTransform.ScaleX > MinZoom)
{
imageScaleTransform.ScaleX -= ZoomIncrement;
imageScaleTransform.ScaleY -= ZoomIncrement;
// 如果缩放到原始大小或更小,隐藏滚动条
if (imageScaleTransform.ScaleX <= 1.0)
{
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
RedrawCenters();
}
}
/// <summary>
/// 适应屏幕按钮点击事件
/// </summary>
private void FitToScreenButton_Click(object sender, RoutedEventArgs e)
{
FitToScreen();
}
/// <summary>
/// 适应屏幕逻辑
/// </summary>
public void FitToScreen()
{
if (mainImage.Source == null)
return;
// 获取父容器的实际尺寸
double viewportWidth = scrollViewer.ActualWidth;
double viewportHeight = scrollViewer.ActualHeight;
// 获取图像尺寸
double imageWidth = ((BitmapSource)mainImage.Source).PixelWidth;
double imageHeight = ((BitmapSource)mainImage.Source).PixelHeight;
// 计算合适的缩放比例,考虑容器的边距
double scaleX = viewportWidth / imageWidth;
double scaleY = viewportHeight / imageHeight;
// 使用较小的缩放因子确保整个图像可见
double scale = Math.Min(scaleX, scaleY);
// 限制缩放范围
//scale = Math.Max(MinZoom, Math.Min(scale, MaxZoom));
// 应用缩放
imageScaleTransform.ScaleX = scale;
imageScaleTransform.ScaleY = scale;
// 强制关闭滚动条,除非确实需要
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
// 确保更新UI
scrollViewer.UpdateLayout();
// 更新中心点
RedrawCenters();
}
/// <summary>
/// 实际大小按钮点击事件
/// </summary>
private void ActualSizeButton_Click(object sender, RoutedEventArgs e)
{
imageScaleTransform.ScaleX = 1.0;
imageScaleTransform.ScaleY = 1.0;
RedrawCenters();
}
/// <summary>
/// 鼠标滚轮事件处理
/// </summary>
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e)
{
double delta = e.Delta > 0 ? ZoomIncrement : -ZoomIncrement;
double newScale = imageScaleTransform.ScaleX + delta;
if (newScale >= MinZoom && newScale <= MaxZoom)
{
// 获取鼠标相对于图像的位置
Point mousePos = e.GetPosition(mainImage);
// 更新缩放
imageScaleTransform.ScaleX = newScale;
imageScaleTransform.ScaleY = newScale;
// 调整滚动条可见性
if (newScale > 1.0)
{
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
}
else
{
scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
// 更新中心点
RedrawCenters();
// 防止事件继续传递
e.Handled = true;
}
}
}
}
using BLL;
using SmartScan.SetControl.WPF.Model;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// MainWindow_Top.xaml 的交互逻辑
/// </summary>
public partial class MainWindow_Top : UserControl
{ // 定义事件来与WinForms通信
public event EventHandler MinimizeClicked;
public event EventHandler MaximizeClicked;
public event EventHandler CloseClicked;
public event EventHandler<string> LanguageChanged;
// 添加一个拖动请求事件
public event EventHandler DragRequested;
public MainWindow_Top()
{
InitializeComponent();
// 从配置中获取当前语言
string configLanguage = BLLCommon.config.Language;
// 根据配置设置选择正确的ComboBoxItem
SelectLanguageInUI(configLanguage);
this.Loaded += (s, e) => {
if (Logos is Image img)
{
// 将WinForms资源转换为WPF可用的BitmapSource
System.Drawing.Bitmap winFormsBitmap = global::SmartScan.Properties.Resources.NEO_64;
if (winFormsBitmap != null)
{
var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
winFormsBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
img.Source = bitmapSource;
}
}
};
//this.StateChanged += MainWindow_StateChanged;
}
// 这个方法将被WinForms宿主调用
public void BeginDragMove()
{
// 这个方法在WinForm中被调用,不会直接使用WPF DragMove方法
// 而是通知WinForm父窗体进行拖动
if (Window.GetWindow(this) == null)
{
// 触发一个事件,让WinForms知道要开始拖动
DragRequested?.Invoke(this, EventArgs.Empty);
}
}
private void SelectLanguageInUI(string language)
{
// 避免触发选择变更事件
LanguageSelector.SelectionChanged -= LanguageSelector_SelectionChanged;
bool found = false;
// 遍历所有ComboBoxItem寻找匹配的语言
foreach (ComboBoxItem item in LanguageSelector.Items)
{
if (item.Content is StackPanel panel &&
panel.Children[0] is System.Windows.Controls.TextBlock textBlock &&
textBlock.Text == language)
{
// 找到匹配项,选择它
LanguageSelector.SelectedItem = item;
found = true;
break;
}
}
// 如果没有找到匹配项,有可能以下几种情况:
// 1. 配置中的语言值与UI中的显示不匹配
// 2. UI中没有该语言选项
// 3. UI控件结构与预期不同
if (!found)
{
Console.WriteLine($"警告: 未找到匹配的语言UI选项: {language}");
// 可以选择设置默认语言
// 例如:如果英文是默认语言
if (LanguageSelector.Items.Count > 0)
{
LanguageSelector.SelectedIndex = 0;
}
}
if (language == "简体中文")
{
mf_name.Text = "物料注册系统";
}
else if (language == "日语")
{
mf_name.Text = "材料登録システム";
}
else
{
mf_name.Text = "Material Registration System";
}
// 重新启用事件处理
LanguageSelector.SelectionChanged += LanguageSelector_SelectionChanged;
}
// 更新窗口状态(正常/最大化)
public void UpdateWindowState(bool isMaximized)
{
MaximizePath.Visibility = isMaximized ? Visibility.Collapsed : Visibility.Visible;
RestorePath.Visibility = isMaximized ? Visibility.Visible : Visibility.Collapsed;
}
// 标题栏拖动 - 需要与WinForms窗口通信
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
// 双击时触发最大化/还原
MaximizeClicked?.Invoke(this, EventArgs.Empty);
e.Handled = true;
}
else
{ // 开始拖动
BeginDragMove();
// 通过父窗体处理拖动
// 这部分需要额外的代码在WinForms端处理
}
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
MinimizeClicked?.Invoke(this, EventArgs.Empty);
}
private void MaximizeButton_Click(object sender, RoutedEventArgs e)
{
MaximizeClicked?.Invoke(this, EventArgs.Empty);
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
//MessageBoxResult result = System.Windows.MessageBox.Show("是否要关闭NeoScan?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning);
string YU = BLLCommon.config.Language;
if (YU == "English")
{
bool result = NeoAlertBox.Show("", "Close NeoScan?", AlertType.Warning, "NEO SCAN", true);
if (result)
{
CloseClicked?.Invoke(this, EventArgs.Empty);
}
}
else if (YU == "日语")
{
bool result = NeoAlertBox.Show("", "NeoScanを終了しますか?", AlertType.Warning, "NEO SCAN", true);
if (result)
{
CloseClicked?.Invoke(this, EventArgs.Empty);
}
}
else
{
bool result = NeoAlertBox.Show("", "是否关闭NeoScan?", AlertType.Warning, "NEO SCAN", true);
if (result)
{
CloseClicked?.Invoke(this, EventArgs.Empty);
}
}
}
private void LanguageSelector_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
// 处理语言更改
if (LanguageSelector.SelectedItem is ComboBoxItem selectedItem &&
selectedItem.Content is StackPanel panel &&
panel.Children[0] is System.Windows.Controls.TextBlock textBlock)
{
string language = textBlock.Text;
if (language== "简体中文")
{
mf_name.Text = "物料注册系统";
}
else if (language == "日语")
{
mf_name.Text = "材料登録システム";
}
else
{
mf_name.Text = "Material Registration System";
}
LanguageChanged?.Invoke(this, language);
}
}
}
}
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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace SmartScan.SetControl.WPF.Model
{
public class ExtensionControl
{
public UIElement Control { get; set; }
public string Key { get; set; }
public string LinkName { get; set; }
public bool CanClear { get; set; }
}
public class CurrentExtension
{
private List<ExtensionControl> extensions;
public void Load(List<ExtensionControl> extensions)
{
this.extensions = extensions;
}
// 获取控件值的方法
public string GetControlValue(string key)
{
var ext = extensions?.FirstOrDefault(e => e.Key == key);
if (ext?.Control is TextBox tb)
return tb.Text;
else if (ext?.Control is ComboBox cb)
return cb.Text;
return string.Empty;
}
// 设置控件值的方法
public void SetControlValue(string key, string value)
{
var ext = extensions?.FirstOrDefault(e => e.Key == key);
if (ext?.Control is TextBox tb)
tb.Text = value;
else if (ext?.Control is ComboBox cb)
cb.Text = value;
}
// 清除控件值的方法
public void ClearControlValue(string key)
{
SetControlValue(key, string.Empty);
}
}
}
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));
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.NS_KetRight"
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" MinHeight="400" Height="Auto"
Background="#121212">
<UserControl.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#E6E6E6"/>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
</Style>
<Style TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="#E6E6E6"/>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="#252525"/>
<Setter Property="Foreground" Value="#E6E6E6"/>
<Setter Property="BorderBrush" Value="#3F3F3F"/>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="#0078D7"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
<Setter Property="Padding" Value="10,5"/>
</Style>
</UserControl.Resources>
<Grid>
<!-- 内容区域 -->
<StackPanel>
<!-- 标题栏保持不变 -->
<Border Background="#0078D7" Height="40">
<TextBlock Text="元件信息"
Name="Wpf_right_name"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
FontSize="14" FontFamily="微软雅黑"
FontWeight="Bold"/>
</Border>
<!-- 字段区域添加单独的滚动条,并限制最大高度 -->
<ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="450">
<StackPanel x:Name="FieldsPanel" Margin="10,10,10,0">
<!-- 动态生成的字段会被添加到这里 -->
</StackPanel>
</ScrollViewer>
<!-- 按钮和识别结果区域保持在滚动区域外,确保始终可见 -->
<StackPanel Margin="10,0,10,10">
<!-- 操作按钮区域 -->
<StackPanel Name="ButtonsPanel" Margin="0,10,0,10">
<!-- 按钮会被添加到这里 -->
</StackPanel>
<!-- 识别结果区域 -->
<StackPanel Name="ResultPanel" Margin="0,10,0,0" Background="{x:Null}">
<Border Background="{x:Null}" CornerRadius="3">
<StackPanel>
<StackPanel x:Name="ResultItemsPanel">
<!-- 识别结果项目会被动态添加到这里 -->
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
<!-- 分割线 -->
<Separator Background="#3F3F3F" Height="1" Margin="0,5,0,15"/>
<!-- 图例说明 -->
<StackPanel>
<Grid Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Width="16" Height="16" Fill="#4CAF50" RadiusX="2" RadiusY="2"/>
<TextBlock Grid.Column="1" x:Name="lbl_Green" Text="绿色 - 完全正确" FontSize="14" FontFamily="微软雅黑" VerticalAlignment="Center" Margin="10,0,0,0"/>
</Grid>
<Grid Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Width="16" Height="16" Fill="#FFC107" RadiusX="2" RadiusY="2"/>
<TextBlock Grid.Column="1" x:Name="lbl_yellow" Text="黄色 - OCR识别结果,需要验证" FontSize="14" FontFamily="微软雅黑" VerticalAlignment="Center" Margin="10,0,0,0"/>
</Grid>
<Grid Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Width="16" Height="16" Fill="#F44336" RadiusX="2" RadiusY="2"/>
<TextBlock Grid.Column="1" x:Name="lbl_red" Text="红色 - 无法识别或有问题" FontSize="14" FontFamily="微软雅黑" VerticalAlignment="Center" Margin="10,0,0,0"/>
</Grid>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
using BLL;
using Model;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// UserControl1.xaml 的交互逻辑
/// </summary>
public partial class UserControl1 : UserControl
{
// 定义事件,用于外部处理按钮点击
public event RoutedEventHandler DecreaseValue_Click;
public event RoutedEventHandler IncreaseValue_Click;
public UserControl1()
{
InitializeComponent();
}
// 处理减少值按钮的点击,并触发事件
private void DecreaseButton_Click(object sender, RoutedEventArgs e)
{
DecreaseValue_Click?.Invoke(sender, e);
}
// 处理增加值按钮的点击,并触发事件
private void IncreaseButton_Click(object sender, RoutedEventArgs e)
{
IncreaseValue_Click?.Invoke(sender, e);
}
// 处理分割条码选项的勾选
private void ChkSplitBarcode_Checked(object sender, RoutedEventArgs e)
{
// 更新UI状态,启用相关控件
CboSplitChar.IsEnabled = true;
TxtSplitIndex.IsEnabled = true;
}
// 处理分割条码选项的取消勾选
private void ChkSplitBarcode_Unchecked(object sender, RoutedEventArgs e)
{
// 更新UI状态,禁用相关控件
CboSplitChar.IsEnabled = false;
TxtSplitIndex.IsEnabled = false;
}
// 处理分割字符选择变更
private void CboSplitChar_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理截取至结尾选项的勾选
private void ChkExtractToEnd_Checked(object sender, RoutedEventArgs e)
{
// 禁用截取长度控件
TxtSubstringLength.IsEnabled = false;
}
// 处理截取至结尾选项的取消勾选
private void ChkExtractToEnd_Unchecked(object sender, RoutedEventArgs e)
{
// 启用截取长度控件
TxtSubstringLength.IsEnabled = true;
}
// 处理必须为数字选项的勾选
private void ChkMustBeNumber_Checked(object sender, RoutedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理必须为数字选项的取消勾选
private void ChkMustBeNumber_Unchecked(object sender, RoutedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理最小长度选项的勾选
private void ChkMinLength_Checked(object sender, RoutedEventArgs e)
{
// 启用最小长度输入控件
TxtMinLength.IsEnabled = true;
}
// 处理最小长度选项的取消勾选
private void ChkMinLength_Unchecked(object sender, RoutedEventArgs e)
{
// 禁用最小长度输入控件
TxtMinLength.IsEnabled = false;
}
// 处理最大长度选项的勾选
private void ChkMaxLength_Checked(object sender, RoutedEventArgs e)
{
// 启用最大长度输入控件
TxtMaxLength.IsEnabled = true;
}
// 处理最大长度选项的取消勾选
private void ChkMaxLength_Unchecked(object sender, RoutedEventArgs e)
{
// 禁用最大长度输入控件
TxtMaxLength.IsEnabled = false;
}
// 处理关键字选择变更
private void CboKeyword_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 此事件主要由主窗口中处理
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
LanguageWwitchover.SetLanguage(this);
}
}
}
using BLL;
using Model;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// UsrPrintTemplatebottom.xaml 的交互逻辑
/// </summary>
public partial class UsrPrintTemplatebottom : UserControl
{
public UsrPrintTemplatebottom()
{
InitializeComponent();
}
// 公开重要控件
/// <summary>
/// 添加字段类型
/// </summary>
public void AddFieldType(string fieldType)
{
CboFieldType.Items.Add(fieldType);
}
/// <summary>
/// 设置字段类型
/// </summary>
public void SetFieldType(int index)
{
if (index >= 0 && index < CboFieldType.Items.Count)
{
CboFieldType.SelectedIndex = index;
}
}
/// <summary>
/// 设置显示关键字状态
/// </summary>
public void SetShowKeyState(bool isChecked)
{
UsrPrintTemplate_ChkFieldShowKey.IsChecked = isChecked;
}
/// <summary>
/// 清空字段类型下拉框
/// </summary>
public void ClearFieldTypes()
{
CboFieldType.Items.Clear();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
LanguageWwitchover.SetLanguage(this);
}
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.UsrPrintTemplateleft"
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"
Loaded="UserControl_Loaded"
mc:Ignorable="d" >
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="Button">
<Setter Property="Background" Value="#1c1c1c"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#0078d7"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="{TemplateBinding Padding}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#0078d7"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#005a9e"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<!-- 左侧面板 - 标签模板列表 -->
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="#1A1A1A" BorderBrush="#0078d7" BorderThickness="1" Padding="10,5">
<TextBlock Text="标签模板" Name="UsrPrintTemplate_pnlPrintTmpLst" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
</Border>
<ListView x:Name="LstLabel" Grid.Row="1"
Background="#1c1c1c"
BorderThickness="1"
BorderBrush="#0078d7"
Foreground="White"
SelectionChanged="LstLabel_SelectedIndexChanged"
SelectedIndex="-1"
HorizontalContentAlignment="Center">
<!-- 设置交替行数为2 -->
<ListView.AlternationCount>2</ListView.AlternationCount>
<!-- 自定义每个项的显示模板 -->
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="14" FontFamily="微软雅黑"/>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderThickness="0">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="Selector.IsSelectionActive" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="Border" Property="Background" Value="#005A9E"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- 交替行颜色 -->
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#353535"/>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#2a2a2a"/>
</Trigger>
<!-- 选中行颜色 - 只有在真正选中时才应用 -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="Selector.IsSelectionActive" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="#0061c8"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</MultiTrigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#464646"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<Border Grid.Row="2" Background="#1A1A1A" BorderBrush="#0078d7" BorderThickness="1" Padding="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontFamily="微软雅黑" FontSize="14" Name="UsrPrintTemplate_pnlPrintTmpLstOp" Text="标签模板操作" HorizontalAlignment="Center" Margin="0,0,0,10"/>
<UniformGrid Grid.Row="1" Rows="1" Columns="4" Margin="0,5">
<Button Margin="2" Click="BtnAddLabel_Click">
<StackPanel>
<TextBlock Text="+" FontSize="18" FontFamily="微软雅黑" HorizontalAlignment="Center"/>
<TextBlock x:Name="UsrPrintTemplate_BtnAddLabel" Text="新建标签" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
</StackPanel>
</Button>
<Button Margin="2" Click="BtnDelLabel_Click">
<StackPanel>
<TextBlock Text="-" FontSize="18" FontFamily="微软雅黑" HorizontalAlignment="Center"/>
<TextBlock Text="删除标签" x:Name="UsrPrintTemplate_BtnDelLabel" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
</StackPanel>
</Button>
<Button Margin="2" Click="BtnCopyLabel_Click">
<StackPanel>
<TextBlock Text="⎘" FontSize="18" HorizontalAlignment="Center"/>
<TextBlock x:Name="UsrPrintTemplate_BtnCopyLabel" Text="复制标签" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
</StackPanel>
</Button>
<Button Margin="2" Click="BtnRenameLabel_Click">
<StackPanel>
<TextBlock Text="✎" FontSize="18" HorizontalAlignment="Center"/>
<TextBlock x:Name="UsrPrintTemplate_BtnRenameLabel" Text="重命名" FontFamily="微软雅黑" FontSize="14" HorizontalAlignment="Center"/>
</StackPanel>
</Button>
</UniformGrid>
</Grid>
</Border>
</Grid>
</Grid>
</UserControl>
using Asa.FaceControl;
using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
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>
/// UsrPrintTemplateleft.xaml 的交互逻辑
/// </summary>
public partial class UsrPrintTemplateleft : System.Windows.Controls.UserControl
{// 在UsrPrintTemplateleft类中
// 定义事件参数类
public class LabelSelectionEventArgs : EventArgs
{
public int SelectedIndex { get; set; }
public string SelectedItem { get; set; }
}
// 定义事件来与WinForms通信
public event EventHandler<LabelSelectionEventArgs> LabelSelectionChanged;
// 按钮点击事件
public event EventHandler AddLabelRequested;
public event EventHandler DeleteLabelRequested;
public event EventHandler CopyLabelRequested;
public event EventHandler RenameLabelRequested;
public UsrPrintTemplateleft()
{
InitializeComponent();
}
// 清空标签列表
public void ClearLabelList()
{
LstLabel.Items.Clear();
}
private void LstLabel_SelectedIndexChanged(object sender, SelectionChangedEventArgs e)
{
if (LstLabel.SelectedIndex >= 0)
{
LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs
{
SelectedIndex = LstLabel.SelectedIndex,
SelectedItem = LstLabel.SelectedItem.ToString()
});
}
}
private readonly SizeF LABEL_ADD_DEFAULT = new(50, 60);
private void BtnAddLabel_Click(object sender, RoutedEventArgs e)
{
//string text = LanguageWwitchover.Dialog(LanguageDialogKey.PRINT_TEMPLATE_ADD);
//FaceInputBox input = new(BtnAddLabel.Text, text);
//DialogResult dr = input.ShowDialog();
//if (dr != DialogResult.OK) return;
//if (string.IsNullOrWhiteSpace(input.InputValue)) return;
////检查是否有已存在的名称
//var find = LstLabel.Items.Cast<string>().FirstOrDefault(name => name.Equals(input.InputValue));
//if (find != null)
//{
// string hint = Asa.FaceControl.Language.Dialog("KeyExists");
// hint = hint.Replace("[name]", input.InputValue);
// new Asa.FaceControl.FaceMessageBox("", hint, MessageBoxButtons.OK).ShowDialog();
// return;
//}
//var newTemplate = new PrintLabelTemplate
//{
// Name = input.InputValue,
// Size = LABEL_ADD_DEFAULT
//};
//newTemplate.State = TemplateState.Unsaved;
//// 添加到集合
//LstLabel.Items.Add(input.InputValue);
//// 选中最后一项
//LstLabel.SelectedIndex = LstLabel.Items.Count - 1;
// 触发事件通知WinForms处理添加标签
AddLabelRequested?.Invoke(this, e);
}
private void BtnDelLabel_Click(object sender, RoutedEventArgs e)
{
// 触发事件通知WinForms处理删除标签
DeleteLabelRequested?.Invoke(this, e);
}
private void BtnCopyLabel_Click(object sender, RoutedEventArgs e)
{
// 触发事件通知WinForms处理复制标签
CopyLabelRequested?.Invoke(this, e);
}
private void BtnRenameLabel_Click(object sender, RoutedEventArgs e)
{
// 触发事件通知WinForms处理重命名标签
RenameLabelRequested?.Invoke(this, e);
}
// 提供API来操作列表
public void AddLabelToList(string labelName)
{
LstLabel.Items.Add(labelName);
LstLabel.SelectedIndex = LstLabel.Items.Count - 1;
}
public void RemoveLabelFromList(int index)
{
if (index >= 0 && index < LstLabel.Items.Count)
{
LstLabel.Items.RemoveAt(index);
if (LstLabel.Items.Count > 0)
{
LstLabel.SelectedIndex = 0;
}
}
}
public void RenameLabelInList(int index, string newName)
{
if (index >= 0 && index < LstLabel.Items.Count)
{
LstLabel.Items[index] = newName;
}
}
public void ClearList()
{
LstLabel.Items.Clear();
}
public void PopulateList(string[] labelNames)
{
LstLabel.Items.Clear();
foreach (var name in labelNames)
{
LstLabel.Items.Add(name);
}
}
public string GetSelectedLabelName()
{
return LstLabel.SelectedItem as string;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
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
{
private readonly NS_Keyword _keywordControl; // 添加对NS_Keyword的引用
private readonly WPFWorkMode workMode;
private readonly WPF_MaterialTemplate _materialTemplate;
public UsrWpfPanel(UIElement ctl)
{
InitializeComponent();
if (ctl is NS_Keyword keyword)
{
_keywordControl = keyword;
}else if (ctl is WPFWorkMode workModes)
{
workMode = workModes;
}else if (ctl is WPF_MaterialTemplate wPF_MaterialTemplate)
{
_materialTemplate = wPF_MaterialTemplate;
}
else
{
throw new ArgumentException("必须传入NS_Keyword类型的控件");
}
elementHost = new ElementHost
{
Dock = DockStyle.Fill,
};
elementHost.Child = ctl;
}
ElementHost elementHost;
FacePanel ISetMenu.GetPanel()
{
facepnl.Controls.Add(elementHost);
return facepnl;
}
void ISetMenu.Save()
{
// 调用NS_Keyword的Save方法
if (_keywordControl != null)
{
_keywordControl.Save();
}
else if(workMode != null)
{
workMode.Save();
}else if (_materialTemplate!=null)
{
_materialTemplate.Save();
}
else
{
throw new InvalidOperationException("NS_Keyword实例未初始化");
}
}
}
}
<?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
using BLL;
using Model;
using SmartScan.SetControl.WPF.Model;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// WPF_Rule.xaml 的交互逻辑
/// </summary>
public partial class WPF_Rule : Window
{
// 新增事件,用于返回生成的关键字
public event EventHandler<string> KeywordGenerated;
// 添加数据结构保存配置
private int digitPlaces;
private bool fillZero;
private int resetStrategy;
public WPF_Rule()
{
InitializeComponent();
this.Loaded += (s, e) => {
if (logos is Image img)
{
// 将WinForms资源转换为WPF可用的BitmapSource
System.Drawing.Bitmap winFormsBitmap = global::SmartScan.Properties.Resources.App;
if (winFormsBitmap != null)
{
var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
winFormsBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
img.Source = bitmapSource;
}
}
};
// 从配置文件加载现有设置
LoadConfigSettings();
}
private void LoadConfigSettings()
{
// 加载配置到控件
NumReelIDPlaces.Text = BLLCommon.config.ReelIDPlaces.ToString();
ChkReelIDFillZero.IsChecked = BLLCommon.config.ReelIDFillZero;
CmbResetidBy.SelectedIndex = Config.REEL_ID_AutoResetStrategy;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
bool result = false;
if (YU == "English")
{
result = NeoAlertBox.Show("", "Save changes?", AlertType.Success, "NEO SCAN", true);
}else if (YU == "日语")
{
result = NeoAlertBox.Show("", "保存しますか?", AlertType.Success, "NEO SCAN", true);
}
else
{
result = NeoAlertBox.Show("", "是否保存", AlertType.Success, "NEO SCAN", true);
}
if (result)
{
// 保存配置
SaveSettings();
// 关闭窗口
DialogResult = true;
}
}
private void SaveSettings()
{
try
{
// 保存数字位数
if (int.TryParse(NumReelIDPlaces.Text, out digitPlaces))
{
BLLCommon.config.ReelIDPlaces = digitPlaces;
}
// 保存补零设置
BLLCommon.config.ReelIDFillZero = ChkReelIDFillZero.IsChecked ?? false;
// 保存重置策略
Config.REEL_ID_AutoResetStrategy = CmbResetidBy.SelectedIndex;
// 保存配置到文件
BLLCommon.config.Save();
}
catch (Exception ex)
{
MessageBox.Show("保存配置时出错:" + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void Generate_keywords_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrWhiteSpace(keyname.Text))
{
MessageBox.Show("请输入关键字内容", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 触发事件,传递关键字回主窗口
KeywordGenerated?.Invoke(this, keyname.Text);
// 清空输入
keyname.Clear();
keyname.Focus();
}
private void UsrMacro_btn_1_Click(object sender, RoutedEventArgs e)
{
int a = int.Parse(NumReelIDPlaces.Text.ToString());
if (a <= 0)
{
return;
}
else
{
a = a - 1;
NumReelIDPlaces.Text = a.ToString();
}
}
private void UsrMacro_btn_2_Click(object sender, RoutedEventArgs e)
{
int a = int.Parse(NumReelIDPlaces.Text.ToString());
a = a + 1;
NumReelIDPlaces.Text = a.ToString();
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void MaximizeRestoreButton_Click(object sender, RoutedEventArgs e)
{
if (this.WindowState == WindowState.Maximized)
this.WindowState = WindowState.Normal;
else
this.WindowState = WindowState.Maximized;
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
// 如果您想要支持通过点击标题栏拖动窗口
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
LanguageWwitchover.SetLanguage(this);
}
}
}
using BLL;
using Model;
using SmartScan.SetControl.WPF.Model;
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.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// WPF_Serialnumber.xaml 的交互逻辑
/// </summary>
public partial class WPF_Serialnumber : Window
{
// 新增事件,用于返回生成的关键字
public event EventHandler<string> KeywordGenerated;
public bool? DialogResult { get; set; }
// 添加数据结构保存配置
private int digitPlaces;
private bool fillZero;
private int resetStrategy;
public WPF_Serialnumber()
{
InitializeComponent();
this.Loaded += (s, e) => {
if (logos is Image img)
{
// 将WinForms资源转换为WPF可用的BitmapSource
System.Drawing.Bitmap winFormsBitmap = global::SmartScan.Properties.Resources.App;
if (winFormsBitmap != null)
{
var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
winFormsBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
img.Source = bitmapSource;
}
}
};
// 从配置文件加载现有设置
LoadConfigSettings();
}
private void LoadConfigSettings()
{
// 加载配置到控件
NumReelIDPlaces.Text = BLLCommon.config.ReelIDPlaces.ToString();
ChkReelIDFillZero.IsChecked = BLLCommon.config.ReelIDFillZero;
CmbResetidBy.SelectedIndex = Config.REEL_ID_AutoResetStrategy;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
bool result = false;
if (YU == "English")
{
result = NeoAlertBox.Show("", "Save changes?", AlertType.Success, "NEO SCAN", true);
}
else if (YU == "日语")
{
result = NeoAlertBox.Show("", "保存しますか?", AlertType.Success, "NEO SCAN", true);
}
else
{
result = NeoAlertBox.Show("", "是否保存", AlertType.Success, "NEO SCAN", true);
}
if (result)
{
// 保存配置
SaveSettings();
// 生成预览示例
string formattedExample = GetFormattedExample();
// 触发事件将信息传递给调用者
OnSerialNumberFormatSet?.Invoke("serialnumber", formattedExample,
BLLCommon.config.ReelIDPlaces, BLLCommon.config.ReelIDFillZero);
// 关闭窗口
DialogResult = true;
// 关闭窗口
Close();
}
}
// 添加一个方法用于获取格式化的示例
private string GetFormattedExample()
{
int places = int.Parse(NumReelIDPlaces.Text);
bool fillZero = ChkReelIDFillZero.IsChecked ?? false;
if (fillZero)
{
return string.Format("{0:D" + places + "}", 1); // 例如:"0000000001"
}
else
{
return "1"; // 不补零的情况
}
}
// 添加一个事件用于将流水号信息传回主窗口
public delegate void SerialNumberFormatHandler(string keyword, string formattedExample, int places, bool fillZero);
public event SerialNumberFormatHandler OnSerialNumberFormatSet;
private void SaveSettings()
{
try
{
// 保存数字位数
if (int.TryParse(NumReelIDPlaces.Text, out digitPlaces))
{
BLLCommon.config.ReelIDPlaces = digitPlaces;
}
// 保存补零设置
BLLCommon.config.ReelIDFillZero = ChkReelIDFillZero.IsChecked ?? false;
// 保存重置策略
Config.REEL_ID_AutoResetStrategy = CmbResetidBy.SelectedIndex;
// 保存配置到文件
BLLCommon.config.Save();
}
catch (Exception ex)
{
}
}
private void UsrMacro_btn_1_Click(object sender, RoutedEventArgs e)
{
int a = int.Parse(NumReelIDPlaces.Text.ToString());
if (a <= 0)
{
return;
}
else
{
a = a - 1;
NumReelIDPlaces.Text = a.ToString();
}
}
private void UsrMacro_btn_2_Click(object sender, RoutedEventArgs e)
{
int a = int.Parse(NumReelIDPlaces.Text.ToString());
a = a + 1;
NumReelIDPlaces.Text = a.ToString();
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void MaximizeRestoreButton_Click(object sender, RoutedEventArgs e)
{
if (this.WindowState == WindowState.Maximized)
this.WindowState = WindowState.Normal;
else
this.WindowState = WindowState.Maximized;
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
// 如果您想要支持通过点击标题栏拖动窗口
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
string YU = BLLCommon.config.Language;
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU);
LanguageWwitchover.SetLanguage(this);
}
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.image_text"
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"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:wfh="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" BorderThickness="0">
<UserControl.Resources>
<!-- 按钮样式 -->
<Style x:Key="ImageViewerButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="#3E3E3E"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Cursor" Value="Hand"/>
</Style>
</UserControl.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="#1E1E1E" >
<wfh:WindowsFormsHost Name="imageViewer" Background="Aqua"></wfh:WindowsFormsHost>
<!-- 叠加在ImageViewer上的Canvas用于绘制中心点 -->
<Canvas x:Name="centerPointsCanvas"
IsHitTestVisible="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Transparent"
/>
</Grid>
<!-- 控制按钮区域 -->
<Border Grid.Row="1" Background="#2D2D30">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8,0,8">
<!-- 放大按钮 -->
<Button x:Name="zoomInButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="ZoomInButton_Click"
ToolTip="放大">
<TextBlock Text="+" FontSize="16" FontWeight="Bold"/>
</Button>
<!-- 缩小按钮 -->
<Button x:Name="zoomOutButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="ZoomOutButton_Click"
ToolTip="缩小">
<TextBlock Text="-" FontSize="16" FontWeight="Bold"/>
</Button>
<!-- 适应屏幕按钮 -->
<Button x:Name="fitToScreenButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="FitToScreenButton_Click"
ToolTip="适应屏幕">
<Viewbox Width="16" Height="16">
<Path Data="M21,15H23V17H21V15M21,11H23V13H21V11M23,19H21V21C22.1,21 23,20.1 23,19M13,3H15V5H13V3M21,7H23V9H21V7M21,3V5H23C23,3.9 22.1,3 21,3M1,7H3V9H1V7M17,3H19V5H17V3M17,19H19V21H17V19M3,3C1.9,3 1,3.9 1,5H3V3M9,3H11V5H9V3M5,3H7V5H5V3M1,11H3V13H1V11M3,21V19H1C1,20.1 1.9,21 3,21M3,15H1V17H3V15M9,19H11V21H9V19M13,19H15V21H13V19M5,19H7V21H5V19Z"
Fill="White"
Stretch="Uniform" />
</Viewbox>
</Button>
<!-- 旋转按钮 -->
<Button x:Name="rotateButton"
Style="{StaticResource ImageViewerButtonStyle}"
Width="40"
Margin="5,0"
Click="RotateButton_Click"
ToolTip="旋转90度">
<Viewbox Width="16" Height="16">
<Path Data="M16.89,15.5L18.31,16.89C19.21,15.73 19.76,14.39 19.93,13H17.91C17.77,13.87 17.43,14.72 16.89,15.5M13,17.9V19.92C14.39,19.75 15.74,19.21 16.9,18.31L15.46,16.87C14.71,17.41 13.87,17.76 13,17.9M19.93,11C19.76,9.61 19.21,8.27 18.31,7.11L16.89,8.53C17.43,9.28 17.77,10.13 17.91,11M15.55,5.55L11,1V4.07C7.06,4.56 4,7.92 4,12C4,16.08 7.05,19.44 11,19.93V17.91C8.16,17.43 6,14.97 6,12C6,9.03 8.16,6.57 11,6.09V10L15.55,5.55Z"
Fill="White"
Stretch="Uniform" />
</Viewbox>
</Button>
</StackPanel>
</Border>
</Grid>
</UserControl>
......@@ -91,7 +91,8 @@ namespace SmartScan
// 保存图像到文件
SaveBitmapToFile(bmp, filePath);
LogNet.log.Info("ocr存图成功");
content = PaddleOCRHelper.StartCplusOcr(filePath);
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialTemplateMatching"), 5);//模版匹配...
content = PaddleOCRHelper.StartCplusOcr(filePath);
LogNet.log.Info("content ocr识别结果:"+content);
}
catch (Exception)
......@@ -111,8 +112,8 @@ namespace SmartScan
public WebResultCamera GetPrintAiing(string a)
{
BLLCommon.extension.Clear();
scanWork.workCodeInfo = new();
//BLLCommon.extension.Clear();
//scanWork.workCodeInfo = new();
//string[] parts = a.Split(';');
//if (a.StartsWith("[") && a.EndsWith("]"))
//{
......@@ -127,144 +128,70 @@ namespace SmartScan
aaa[key] = ""; // or aaa.Add(key, null);
}
try
{
// 解析 JSON 字符串
aaa = JsonConvert.DeserializeObject<Dictionary<string, string>>(a);
// 将解析结果赋值给 aaa 字典
//foreach (var key in aaa.Keys)
//{
// if (jsonObject.ContainsKey(key))
// {
// aaa[key] = jsonObject[key];
// }
//}
{ // 解析JSON字符串
Dictionary<string, string> jsonData = JsonConvert.DeserializeObject<Dictionary<string, string>>(a);
// 解析 JSON 字符串反序列化
//aaa = JsonConvert.DeserializeObject<Dictionary<string, string>>(a);
// 将解析结果映射到目标字典
if (jsonData != null)
{
foreach (var key in aa)
{
if (jsonData.ContainsKey(key))
{
aaa[key] = jsonData[key];
}
}
}
}
catch (JsonException ex)
{
Console.WriteLine($"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>();
// 如果JSON解析失败,尝试其他格式
LogNet.log.Info("JSON解析失败,尝试其他格式解析");
//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
if (a.Contains(":") && (a.Contains("[") || a.Contains("{")))
{
// 移除可能的括号和引号
string cleaned = a.Trim().Trim('[', ']', '{', '}');
//// 4. 添加到workCodeInfo
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text1 });
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text2 });
// 处理可能的换行
cleaned = Regex.Replace(cleaned, @"\r\n|\n|\r", ",");
// 2. Create the required text entries
//var text1 = $"{cleanedArticle}";
//var text2 = $"{vpn};{lot};{qty};{coo.Split(' ').FirstOrDefault()}";
// 移除多余的逗号
cleaned = Regex.Replace(cleaned, @",+", ",");
// 3. Add to workCodeInfo
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text1 });
//scanWork.workCodeInfo.Add(new CameraVisionLib.Model.BarcodeInfo { Text = text2 });
// 分割成键值对
string[] entries = cleaned.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var entry in entries)
{
if (entry.Contains(":"))
{
string[] keyValue = entry.Split(new[] { ':' }, 2);
if (keyValue.Length == 2)
{
string key = keyValue[0].Trim().Trim('"', '\'');
string value = keyValue[1].Trim().Trim('"', '\'');
// 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;
// }
// }
//}
if (aaa.ContainsKey(key))
{
aaa[key] = value;
}
}
}
}
LogNet.log.Info("使用类JSON格式成功解析数据");
}
}
try
{
bool hasMatch = scanWork.MatchingTemplate();
BLLCommon.extension.SetKey(scanWork.originalCodeText, aaa, hasMatch, out _);
BLLCommon.extension.Print(hasMatch, aaa);
//bool hasMatch = scanWork.MatchingTemplate();
BLLCommon.extension.SetKey(scanWork.originalCodeText, aaa, true, out _);
BLLCommon.extension.Print(true, aaa);
}
catch (Exception ex)
{
......
......@@ -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="Extended.Wpf.Toolkit" version="4.7.25104.5739" targetFramework="net472" />
<package id="HandyControl" version="3.5.1" 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
......@@ -85,7 +85,7 @@ namespace paddleOCR
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}
}
private NotifyIcon notify;
......
......@@ -135,6 +135,7 @@
<Compile Include="VisionAPI.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!