Commit 27ad3e76 王海洋

why修改

1 个父辈 ade252a8
......@@ -173,7 +173,7 @@ namespace BLL
if (!File.Exists(filename))
return titles;
LogNet.log.Info("filename:"+ filename);
XLWorkbook wb = new XLWorkbook(filename);
IXLWorksheet ws = wb.Worksheet(1);
for (int i = 1; i < 50; i++)
......
......@@ -35,6 +35,8 @@ namespace BLL
public MessageboxNeo(string headerText, string descriptionText, string title = "NEO SCAN", bool showCancelButton = true)
{
InitializeComponent();
this.TopMost = true; // 添加这一行,使窗体总是在最前面
this.StartPosition = FormStartPosition.CenterScreen; // 改为CenterScreen以相对于整个屏幕居中
titleLabel.Text = title;
headerLabel.Text = headerText;
descriptionLabel.Text = descriptionText;
......
......@@ -256,7 +256,7 @@ namespace BLL
public class Operation
{
public string cid;
public string type = "NEOSCAN"; //COUNTING
public string type = "NS100"; //COUNTING
public StoreStatus status;
public int seq;
public int op;
......
......@@ -26,6 +26,7 @@ namespace Model
public static readonly string CONFIG_EXTENSION = Environment.CurrentDirectory + "\\Config\\Extension.json";
public static readonly string CONFIG_REELID = Environment.CurrentDirectory + "\\Config\\ReelID";
public static readonly string CONFIG_DATABASE = Environment.CurrentDirectory + "\\Config\\Database.db3";
public static readonly string CONFIG_AUTOGENRULES = Environment.CurrentDirectory + "\\Config\\AutoGenRules.json";
public static readonly string CONFIG_AUTOGENRULES = Environment.CurrentDirectory + "\\Config\\AutoGenRules.json";
public static readonly string CONFIG_Code_Value = Environment.CurrentDirectory + "\\Config\\CodeValue.txt";
}
}
using Asa.FaceControl;
using BLL;
using DocumentFormat.OpenXml.Bibliography;
using HandyControl.Properties.Langs;
using HandyControl.Tools.Extension;
using Model;
using Newtonsoft.Json;
......@@ -57,6 +58,7 @@ namespace SmartScan
InitializeImageControls();
// 添加窗体大小调整事件
this.Resize += YourWinFormClass_Resize;
}
private void YourWinFormClass_Resize(object sender, EventArgs e)
{
......@@ -186,6 +188,7 @@ namespace SmartScan
// 调用新的UpdateLanguage方法,而不仅仅是UpdateRight
wpfControl.UpdateLanguage();
}
}
// 当窗口状态改变时,通知WPF控件
......@@ -415,6 +418,8 @@ namespace SmartScan
// 确保它位于Z顺序的顶部
host.BringToFront();
}
......@@ -474,12 +479,109 @@ namespace SmartScan
PnlExtension.Left = Width - PnlExtension.Width - 12;
PnlExtension.BackColor = System.Drawing.Color.FromArgb(20, 20, 20);
wpfControl.UpdateMultipleRecognitionData(BLLCommon.macroKeyValue);
if (BLLCommon.config.CheckFunction)
{
Extension_Checks("2");
}
}
private void WpfControl_Cherkfun(object sender, EventArgs e)
{
if (BLLCommon.config.Language.Equals("English"))
{
bool result = MessageboxNeo.Show("", "Whether to skip this operation?", "NEO SCAN", true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
else if (BLLCommon.config.Language.Equals("日语"))
{
bool result = MessageboxNeo.Show("",
"この操作をスキップしますか?",
"NEO SCAN",
true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
else
{
bool result = MessageboxNeo.Show("", "是否跳过此操作?", "NEO SCAN", true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
extension.CheckClears();
}
......@@ -780,16 +882,32 @@ namespace SmartScan
// }
//}
string aa = "";
try
{
foreach (string key in content.Keys)
{// 提取简写键(保留原键的层级结构)
string shortKey = key.Split('/').First(); // 输出 "RID" 或 "QTY"
str += string.Format("({0}:{1})", shortKey, content[key]);
aa += string.Format("({0}:{1})", shortKey, content[key]);
}
try
{
// 确保目录存在
string directory = Path.GetDirectoryName(FilePath.CONFIG_Code_Value);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
// 覆盖文件内容(只保留最新日志)
File.WriteAllText(FilePath.CONFIG_Code_Value, $"{aa}");
}
catch (Exception ex)
{
LogNet.log.Error($"写入文件失败: {ex.Message}");
}
LogNet.log.Info(str);
SaveResult(content);
//Bitmap labelBmp = Common.labelEdit.PrintImage(Common.config.DefaultPrintLabel, content, out _);
......@@ -842,6 +960,7 @@ namespace SmartScan
scanWork.generals = new General(BLLCommon.config);
BLLCommon.extension.KeySets += OnBllKeySet;
BLLCommon.extension.Checks += Extension_Checks; ;
scanWork.Check2s += Extension_Checks;
LblVersion.Text = BLLCommon.config.SoftVersion;
LblUserName.Text = BLLCommon.config.UserName;
......@@ -894,17 +1013,35 @@ namespace SmartScan
private void Extension_Checks(string text)
{
if (text=="OK")
if (this.InvokeRequired)
{
wpfControl.SetResultOK();
}else if (text == "等待中" || text == "Waiting"||text== "待機中")
this.Invoke(new Action(() => Extension_Checks(text)));
return;
}
if (text == "1")
{
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
wpfControl.SetSkipButtonVisibility(true);
return;
}
else
if (text == "2")
{
wpfControl.SetResultNG(); // 显示NG
wpfControl.SetSkipButtonVisibility(false);
return;
}
if (text == "OK")
{
wpfControl.SetResultOK();
}
else if (text == "等待中" || text == "Waiting" || text == "待機中")
{
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
else
{
wpfControl.SetResultNG(); // 显示NG
}
}
private void OnBllKeySet(string[] originalCode, Dictionary<string, string> key, bool hasMatch)
......
......@@ -138,6 +138,30 @@ namespace SmartScan.SetControl.WPF
// 更新识别结果
UpdateRecognitionResults(ResultItemsPanel);
}
public void ClearFieldContents()
{
foreach (var kvp in fieldControls)
{
kvp.Value.Text = string.Empty;
// 同时更新数据字典
if (recognizedData.ContainsKey(kvp.Key))
{
recognizedData[kvp.Key] = string.Empty;
fieldValidStatus[kvp.Key] = false;
}
}
// 更新结果显示
UpdateRecognitionResults(ResultItemsPanel);
// 触发数据更新事件
DataUpdated?.Invoke(this, "clear");
// 触发ISPrint事件(如果适用)
ISPrint?.Invoke(this, null);
}
private TextBlock txtResults;
public NS_KetRight()
{
......@@ -263,7 +287,7 @@ namespace SmartScan.SetControl.WPF
TextBlock resultTextBlock = new TextBlock
{
Name = "txtResults",
Text = "NG", // 初始为空,稍后会根据结果设置为"OK"或"NG"
Text = "", // 初始为空,稍后会根据结果设置为"OK"或"NG"
Margin = new Thickness(8, 0, 0, 0),
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f0f0f0")),
FontSize = 14,
......@@ -361,6 +385,18 @@ namespace SmartScan.SetControl.WPF
//ButtonsPanel.Children.Add(printButton);
}
/// <summary>
/// 设置跳过按钮的可见性
/// </summary>
/// <param name="isVisible">true 显示按钮,false 隐藏按钮</param>
public void SetSkipButtonVisibility(bool isVisible)
{
if (skipButton != null)
{
skipButton.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
}
}
/// <summary>
/// 更新界面语言
/// </summary>
......
......@@ -617,7 +617,7 @@ Visibility="Collapsed"/>
<!-- 已选关键词(按显示顺序排列) -->
<TextBlock Text="已选关键词(按显示顺序排列)" Name="xianshi" Style="{StaticResource LabelStyle}" Margin="0,15,0,5"/>
<Border Background="#222222" CornerRadius="5" Margin="0,0,0,15">
<ScrollViewer MaxHeight="200" Margin="5">
<ScrollViewer MaxHeight="200" Margin="5" >
<StackPanel x:Name="SelectedKeywordsPanel" >
<!-- 已选关键词将在此动态添加 -->
</StackPanel>
......
......@@ -60,7 +60,8 @@ namespace SmartScan.SetControl.WPF
// 新增属性用于流水号
public bool IsSerialNumber { get; set; } // 是否为流水号
public string SerialExample { get; set; } // 流水号示例
public bool IsEditing { get; set; } // 新增编辑状态属性
}
private readonly List<string> keyCopy;
private readonly List<string> keyCopyValue;
......@@ -305,16 +306,65 @@ namespace SmartScan.SetControl.WPF
}
};
Grid.SetColumn(numberBorder, 0);
StackPanel contentPanel = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal };
// 关键词文本 - 这里已经支持显示流水号预览格式
System.Windows.Controls.TextBlock keywordText = new System.Windows.Controls.TextBlock
{
Text = keyword.DisplayText ?? keyword.Text,
Visibility = keyword.IsEditing ? Visibility.Collapsed : Visibility.Visible,
Foreground = Brushes.White,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(10, 0, 0, 0),
FontSize = 14,
FontFamily = new System.Windows.Media.FontFamily("微软雅黑"),
};
// 可编辑的TextBox
System.Windows.Controls.TextBox editTextBox = new System.Windows.Controls.TextBox
{
Text = keyword.Text,
Visibility = keyword.IsEditing ? Visibility.Visible : Visibility.Collapsed,
MinWidth = 100,
Margin = new Thickness(10, 0, 0, 0),
FontSize = 14,
FontFamily = new FontFamily("微软雅黑"),
Foreground = Brushes.White,
Background = Brushes.Transparent,
BorderThickness = new Thickness(1),
BorderBrush = Brushes.White
};
// 添加键盘事件处理
editTextBox.KeyDown += (s, e) => {
if (e.Key == Key.Enter)
{
keyword.Text = editTextBox.Text;
keyword.DisplayText = editTextBox.Text;
keyword.IsEditing = false;
UpdateSelectedKeywordsUI();
}
};
// 失去焦点时保存
editTextBox.LostFocus += (s, e) => {
keyword.Text = editTextBox.Text;
keyword.DisplayText = editTextBox.Text;
keyword.IsEditing = false;
UpdateSelectedKeywordsUI();
};
contentPanel.Children.Add(keywordText);
contentPanel.Children.Add(editTextBox);
// 双击事件处理
itemGrid.MouseDown += (s, e) => {
if (e.ClickCount == 2 && !keyword.IsEditing)
{
keyword.IsEditing = true;
UpdateSelectedKeywordsUI();
// 设置焦点到TextBox
Dispatcher.BeginInvoke((Action)(() => {
editTextBox.Focus();
editTextBox.SelectAll();
}), System.Windows.Threading.DispatcherPriority.Render);
}
};
Grid.SetColumn(keywordText, 1);
// 上移按钮
Button upButton = new Button
......@@ -351,11 +401,14 @@ namespace SmartScan.SetControl.WPF
Grid.SetColumn(removeButton, 4);
// 添加所有元素到网格
itemGrid.Children.Add(numberBorder);
itemGrid.Children.Add(keywordText);
//itemGrid.Children.Add(keywordText);
itemGrid.Children.Add(upButton);
itemGrid.Children.Add(downButton);
itemGrid.Children.Add(removeButton);
// 将网格添加到面板
Grid.SetColumn(contentPanel, 1);
itemGrid.Children.Add(contentPanel);
SelectedKeywordsPanel.Children.Add(itemGrid);
}
// 更新预览
......@@ -940,5 +993,8 @@ namespace SmartScan.SetControl.WPF
string keywordsStr = string.Join(",", keywords);
BLLCommon.config.CharacterTypeKeywords = keywordsStr;
}
}
}
<UserControl x:Class="SmartScan.SetControl.WPF.UserControl2"
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="650" d:DesignWidth="500">
<Grid>
<ListView x:Name="data3" Background="#1c1c1c" BorderThickness="1" BorderBrush="Gray" Foreground="White" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionChanged="data3_SelectionChanged">
<!-- 设置交替行数为2 -->
<ListView.AlternationCount>2</ListView.AlternationCount>
<!-- 自定义每个项的显示模板 -->
<ListView.ItemTemplate>
<DataTemplate>
<ContentControl Content="{Binding Converter={StaticResource OcrTextHighlighter}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" FontSize="14" FontFamily="微软雅黑"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Converter={StaticResource WidthMinusMarginConverter}}"/>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="MinHeight" Value="25"/>
<Setter Property="Padding" Value="5,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderThickness="0">
<ContentPresenter HorizontalAlignment="Left"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="#005A9E"/>
</Trigger>
</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>
<!-- 选中行颜色 -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#0061c8"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#464646"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</UserControl>
using System;
using System.Collections;
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>
/// UserControl2.xaml 的交互逻辑
/// </summary>
public partial class UserControl2 : UserControl
{
public UserControl2()
{
InitializeComponent();
}
// 公开获取data3控件的方法
public ListView GetListView()
{
return data3;
}
// 提供设置ItemsSource的方法
public void SetItemsSource(IEnumerable source)
{
data3.ItemsSource = source;
}
// 暴露选中索引改变的事件
public event SelectionChangedEventHandler SelectionChanged;
private void data3_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 触发外部事件
SelectionChanged?.Invoke(sender, e);
}
}
}
......@@ -44,7 +44,14 @@ namespace SmartScan.SetControl.WPF
public UsrPrintTemplateleft()
{
InitializeComponent();
if (LstLabel.SelectedIndex >= 0)
{
LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs
{
SelectedIndex = 0,
SelectedItem = LstLabel.SelectedItem.ToString()
});
}
}
// 清空标签列表
public void ClearLabelList()
......@@ -53,6 +60,7 @@ namespace SmartScan.SetControl.WPF
}
private void LstLabel_SelectedIndexChanged(object sender, SelectionChangedEventArgs e)
{
if (LstLabel.SelectedIndex == -1) return;
if (LstLabel.SelectedIndex >= 0)
{
LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs
......@@ -61,6 +69,8 @@ namespace SmartScan.SetControl.WPF
SelectedItem = LstLabel.SelectedItem.ToString()
});
}
// 重置选中状态
LstLabel.SelectedIndex = -1;
}
private readonly SizeF LABEL_ADD_DEFAULT = new(50, 60);
......
......@@ -128,7 +128,7 @@
</Button.Tag>
</Button>
<Button Content="AI" Name="BtnAI" Style="{StaticResource MenuButtonStyle}" Click="BtnAI_Click">
<Button Content="AI" Name="BtnAI" Style="{StaticResource MenuButtonStyle}" Visibility="Collapsed" Click="BtnAI_Click">
<Button.Tag>
<Image Source="/Resources/AI.png" Width="18" Height="18" />
</Button.Tag>
......
......@@ -477,7 +477,7 @@
</Grid>
</Border>
<Grid Grid.Row="1">
<Frame x:Name="aa"></Frame>
<ContentControl x:Name="aa"></ContentControl>
</Grid>
</Grid>
......
......@@ -382,6 +382,7 @@ namespace SmartScan.SetControl.WPF
{
if (userControls.TryGetValue(clickedButton, out UserControl1 userControl))
{
//aa.NavigationService?.RemoveBackEntry();
// 清空Frame内容
aa.Content = null;
......
......@@ -463,7 +463,7 @@
<StackPanel Grid.Row="6">
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExport" Click="FrmRetrospect_BtnExport_Click" Content="导出" Margin="0,5,0,5"/>
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExportAll" Click="FrmRetrospect_BtnExportAll_Click" Content="导出所有" Margin="0,5,0,5"/>
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_butt_startserver" Click="FrmRetrospect_butt_startserver_Click" Content="启动服务" Margin="0,5,0,5"/>
<Button Style="{StaticResource buttonStyle}" Visibility="Collapsed" Name="FrmRetrospect_butt_startserver" Click="FrmRetrospect_butt_startserver_Click" Content="启动服务" Margin="0,5,0,5"/>
<!-- 结果显示区域 -->
<TextBlock Text="" Name="FrmRetrospect_faceLabel1" Foreground="White" Margin="0,15,0,5"/>
......
......@@ -252,6 +252,9 @@
<Compile Include="SetControl\WPF\UserControl1.xaml.cs">
<DependentUpon>UserControl1.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UserControl2.xaml.cs">
<DependentUpon>UserControl2.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UsrPrintTemplatebottom.xaml.cs">
<DependentUpon>UsrPrintTemplatebottom.xaml</DependentUpon>
</Compile>
......@@ -598,6 +601,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\UserControl2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\UsrPrintTemplatebottom.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!