Commit 515ecb2f 王海洋

修改刘工提出的问题(除语言外)

1 个父辈 7f410429
......@@ -51,6 +51,12 @@ namespace Model
public int SubstringLength { get; set; } = 1;
public int SplitPart { get; set; } = 1;
public bool MatchISNumber { get; set; } = false;
/// <summary>
/// 只取数据
/// kmon
/// 2025-6-24
/// </summary>
public bool OnlyTakeBeNumber { get; set; } = false;
/// <summary>
/// 特征条码
......
......@@ -38,9 +38,16 @@ namespace SmartScan
public ImageViewerControl imageViewer;
public image_text Imagetest;
private MainWindow_Top MF_top;
//定义成静态变量供子窗体调用
//kmon
//2025-6-24
public static FrmMain mon_frmMain;
public FrmMain()
{
//成静态变量赋值为本窗体
//kmon
//2025-6-24
mon_frmMain = this;
InitializeComponent();
// 初始化导航栏
InitializeMFTop();
......@@ -455,7 +462,11 @@ namespace SmartScan
InitializeWpfControl();
}
//private General generals;
private void InitializeWpfControl()
//private修改为public
//kmon
//2025-6-24
public void InitializeWpfControl()
{
// 创建 WPF 控件实例
wpfControl = new NS_KetRight();
......
......@@ -79,7 +79,10 @@ namespace SmartScan
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
DialogResult = DialogResult.OK;
//点击后,刷新主界面参数控件
//kmon
//2025-6-24
FrmMain.mon_frmMain.InitializeWpfControl();
}
private void BtnCancel_Click(object sender, EventArgs e)
......
......@@ -59,7 +59,7 @@ namespace SmartScan
this.but_StartService.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.but_StartService.Location = new System.Drawing.Point(3, 3);
this.but_StartService.Name = "but_StartService";
this.but_StartService.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.but_StartService.Padding = new System.Windows.Forms.Padding(3);
this.but_StartService.ShowText = false;
this.but_StartService.Size = new System.Drawing.Size(1113, 773);
this.but_StartService.TabIndex = 1;
......@@ -90,7 +90,7 @@ namespace SmartScan
this.ChkRecursive.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.ChkRecursive.Location = new System.Drawing.Point(760, 23);
this.ChkRecursive.Name = "ChkRecursive";
this.ChkRecursive.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.ChkRecursive.Padding = new System.Windows.Forms.Padding(3);
this.ChkRecursive.Size = new System.Drawing.Size(322, 45);
this.ChkRecursive.TabIndex = 23;
this.ChkRecursive.Text = "遍历同目录";
......@@ -132,7 +132,7 @@ namespace SmartScan
this.BtnSelectFile.HoldPress = false;
this.BtnSelectFile.Location = new System.Drawing.Point(542, 23);
this.BtnSelectFile.Name = "BtnSelectFile";
this.BtnSelectFile.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.BtnSelectFile.Padding = new System.Windows.Forms.Padding(3);
this.BtnSelectFile.Size = new System.Drawing.Size(212, 45);
this.BtnSelectFile.TabIndex = 1;
this.BtnSelectFile.Text = "选择文件";
......@@ -146,7 +146,7 @@ namespace SmartScan
this.faceLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.faceLabel2.Location = new System.Drawing.Point(18, 228);
this.faceLabel2.Name = "faceLabel2";
this.faceLabel2.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.faceLabel2.Padding = new System.Windows.Forms.Padding(3);
this.faceLabel2.Size = new System.Drawing.Size(396, 45);
this.faceLabel2.TabIndex = 21;
this.faceLabel2.Text = "关键字匹配数据标题";
......@@ -160,7 +160,7 @@ namespace SmartScan
this.faceLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.faceLabel1.Location = new System.Drawing.Point(18, 115);
this.faceLabel1.Name = "faceLabel1";
this.faceLabel1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.faceLabel1.Padding = new System.Windows.Forms.Padding(3);
this.faceLabel1.Size = new System.Drawing.Size(396, 45);
this.faceLabel1.TabIndex = 21;
this.faceLabel1.Text = "识别关键词";
......@@ -174,7 +174,7 @@ namespace SmartScan
this.LblFilestatus.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LblFilestatus.Location = new System.Drawing.Point(18, 74);
this.LblFilestatus.Name = "LblFilestatus";
this.LblFilestatus.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.LblFilestatus.Padding = new System.Windows.Forms.Padding(3);
this.LblFilestatus.Size = new System.Drawing.Size(518, 35);
this.LblFilestatus.TabIndex = 21;
this.LblFilestatus.Text = "文件状态:";
......@@ -188,7 +188,7 @@ namespace SmartScan
this.CboDataTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.CboDataTitle.Location = new System.Drawing.Point(18, 279);
this.CboDataTitle.Name = "CboDataTitle";
this.CboDataTitle.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.CboDataTitle.Padding = new System.Windows.Forms.Padding(3);
this.CboDataTitle.SelectedIndex = -1;
this.CboDataTitle.SelectedText = "";
this.CboDataTitle.Size = new System.Drawing.Size(396, 45);
......@@ -203,7 +203,7 @@ namespace SmartScan
this.CboDataKey.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.CboDataKey.Location = new System.Drawing.Point(18, 166);
this.CboDataKey.Name = "CboDataKey";
this.CboDataKey.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.CboDataKey.Padding = new System.Windows.Forms.Padding(3);
this.CboDataKey.SelectedIndex = -1;
this.CboDataKey.SelectedText = "";
this.CboDataKey.Size = new System.Drawing.Size(396, 45);
......@@ -218,7 +218,7 @@ namespace SmartScan
this.TxtDataSource.Location = new System.Drawing.Point(18, 23);
this.TxtDataSource.MaxLength = 32767;
this.TxtDataSource.Name = "TxtDataSource";
this.TxtDataSource.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.TxtDataSource.Padding = new System.Windows.Forms.Padding(3);
this.TxtDataSource.SelectedText = "";
this.TxtDataSource.SelectionLength = 0;
this.TxtDataSource.SelectionStart = 0;
......@@ -237,7 +237,7 @@ namespace SmartScan
this.LblContent.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LblContent.Location = new System.Drawing.Point(24, 6);
this.LblContent.Name = "LblContent";
this.LblContent.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.LblContent.Padding = new System.Windows.Forms.Padding(3);
this.LblContent.Size = new System.Drawing.Size(396, 45);
this.LblContent.TabIndex = 21;
this.LblContent.Text = "标签数据源";
......@@ -251,13 +251,14 @@ namespace SmartScan
this.CboDataType.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.CboDataType.Location = new System.Drawing.Point(24, 57);
this.CboDataType.Name = "CboDataType";
this.CboDataType.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.CboDataType.Padding = new System.Windows.Forms.Padding(3);
this.CboDataType.SelectedIndex = -1;
this.CboDataType.SelectedText = "";
this.CboDataType.Size = new System.Drawing.Size(192, 45);
this.CboDataType.TabIndex = 0;
this.CboDataType.Tag = "not";
this.CboDataType.Text = "CboDataType";
this.CboDataType.TextChanged += new System.EventHandler(this.CboDataType_TextChanged);
//
// UsrDataSource
//
......
......@@ -29,7 +29,11 @@ namespace SmartScan
private void TxtDataSource_TextChanged(object sender, EventArgs e)
{
if (CboDataType.SelectedText == "None") return;
var filestring = TxtDataSource.Text.Trim();
if (string.IsNullOrEmpty(filestring)) {
LblFilestatus.Text = Language.Dialog("selectdatasource","请选择数据文件");
}
......@@ -130,6 +134,24 @@ namespace SmartScan
}
TxtDataSource.Text = fileDialog.FileName;
}
}
private void CboDataType_TextChanged(object sender, EventArgs e)
{
if (CboDataType.SelectedText == "None")
{
TxtDataSource.Text = "";
ChkRecursive.Checked = true;
}
else
{
TxtDataSource.Text = Config.DataSource_FilePath;
ChkRecursive.Checked = Config.DataSource_Recursive;
}
}
}
}
......@@ -652,7 +652,8 @@ Visibility="Collapsed"/>
<Grid Grid.Row="2">
<TextBlock Background="#C1C1C1" Margin="0,13,0,40" Height="0.3" Grid.ColumnSpan="2"></TextBlock>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0 0 10 10">
<Button Content="上移" Foreground="White" Style="{DynamicResource buttonStyle}" FontFamily="微软雅黑" Name="MoveUpKey" Height="50" Width="150" FontSize="14" Margin="5" Background="#4B78D0" Click="MoveUpKey_Click"></Button>
<Button Content="下移" Foreground="White" Style="{DynamicResource buttonStyle}" FontFamily="微软雅黑" Name="MoveDownKey" Height="50" Width="150" FontSize="14" Margin="5" Background="#4B78D0" Click="MoveDownKey_Click"></Button>
<Button Content="删除" Foreground="White" Style="{DynamicResource buttonStyle}" FontFamily="微软雅黑" Name="BtnDelKey" Height="50" Width="150" FontSize="14" Margin="5" Background="#4B78D0" Click="BtnDelKey_Click"></Button>
<Button Content="保存" Foreground="White" Style="{DynamicResource buttonStyle}" FontFamily="微软雅黑" Name="FrmSet_BtnOK" Height="50" Width="150" FontSize="14" Margin="5" Background="#4B78D0" Click="BtnUpdateKey_Click"></Button>
......
......@@ -64,8 +64,8 @@ namespace SmartScan.SetControl.WPF
public bool IsEditing { get; set; } // 新增编辑状态属性
}
private readonly List<string> keyCopy;
private readonly List<string> keyCopyValue;
private List<string> keyCopy;
private List<string> keyCopyValue;
private List<KeywordItem> selectedKeywords=new List<KeywordItem>(); // 用于跟踪已选关键词
public string ButtonContent => LanguageWwitchover.GetText("ButtonContentKey");
public string TextBlockContent => LanguageWwitchover.GetText("TextBlockContentKey");
......@@ -74,6 +74,16 @@ namespace SmartScan.SetControl.WPF
{
InitializeComponent();
initKey();
}
/// <summary>
/// 原构造函数封闭一个单独的方法
/// kmon
/// 2025-6-24
/// </summary>
void initKey()
{
// 设置DataContext为当前实例,以支持绑定
this.DataContext = this;
......@@ -99,7 +109,7 @@ namespace SmartScan.SetControl.WPF
{
if (BLLCommon.macroKey.Count > 0)
{
BLLCommon.macroKeyValue.AddRange(BLLCommon.macroKey.Select(s=>s+"\t\tfalse"));
BLLCommon.macroKeyValue.AddRange(BLLCommon.macroKey.Select(s => s + "\t\tfalse"));
}
else
LogNet.log.Debug("关键字文件路径不存在");
......@@ -424,13 +434,12 @@ namespace SmartScan.SetControl.WPF
// 上移关键词
private void MoveKeywordUp(int index)
{
if (index > 0 && index < selectedKeywords.Count)
{
var keyword = selectedKeywords[index];
selectedKeywords.RemoveAt(index);
selectedKeywords.Insert(index - 1, keyword);
UpdateSelectedKeywordsUI();
}
}
// 下移关键词
......@@ -685,6 +694,41 @@ namespace SmartScan.SetControl.WPF
}
}
//上移事件
//kmon
//2025-6-24
private void MoveUpKey_Click(object sender, RoutedEventArgs e)
{
int selectIndex = LstKey.SelectedIndex;
if (selectIndex == 0) return;
string[] lines = System.IO.File.ReadAllLines(FilePath.CONFIG_MACRO_KEY);
string startKey = lines[selectIndex];
string endKey= lines[selectIndex - 1];
lines[selectIndex - 1] = startKey;
lines[selectIndex] = endKey;
System.IO.File.WriteAllLines(FilePath.CONFIG_MACRO_KEY, lines);
initKey();
}
//下移事件
//kmon
//2025-6-24
private void MoveDownKey_Click(Object sender, RoutedEventArgs e)
{
int selectIndex = LstKey.SelectedIndex;
if (selectIndex >LstKey.Items.Count-1) return;
string[] lines = System.IO.File.ReadAllLines(FilePath.CONFIG_MACRO_KEY);
string startKey = lines[selectIndex];
string endKey = lines[selectIndex + 1];
lines[selectIndex + 1] = startKey;
lines[selectIndex] = endKey;
System.IO.File.WriteAllLines(FilePath.CONFIG_MACRO_KEY, lines);
initKey();
}
void setRIkey()
{
// 创建一个新的显示列表
......
......@@ -293,7 +293,7 @@
<!-- 标题 -->
<TextBlock Grid.Row="0" Text="提取设置" Name="WPF_Set" Style="{StaticResource SectionTitleStyle}"/>
<!-- 提取设置内容 -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="10">
......@@ -378,16 +378,22 @@
</StackPanel>
</Grid>
<!-- 必须为数字 & 截取至结尾 -->
<Grid Margin="0,8">
<!-- 必须为数字 &只取数字& 截取至结尾 -->
<Grid Margin="0,8" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="ChkMustBeNumber" FontFamily="微软雅黑" FontSize="14" Content="必须为数字" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="0" Checked="ChkMustBeNumber_Checked" Unchecked="ChkMustBeNumber_Unchecked"/>
<CheckBox x:Name="OnlyTakeBeNumber" FontFamily="微软雅黑" FontSize="14" Content="只取数字" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="1" Checked="OnlyTakeBeNumber_Checked" Unchecked="OnlyTakeBeNumber_Unchecked"/>
<CheckBox x:Name="ChkExtractToEnd" FontFamily="微软雅黑" FontSize="14" Content="截取至结尾" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="1" IsChecked="True" Checked="ChkExtractToEnd_Checked" Unchecked="ChkExtractToEnd_Unchecked"/>
Grid.Column="2" IsChecked="True" Checked="ChkExtractToEnd_Checked" Unchecked="ChkExtractToEnd_Unchecked"/>
</Grid>
<Separator Style="{StaticResource DarkSeparatorStyle}"/>
......
......@@ -76,11 +76,22 @@ namespace SmartScan.SetControl.WPF
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理必须为数字选项的勾选
private void OnlyTakeBeNumber_Checked(object sender, RoutedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理必须为数字选项的取消勾选
private void ChkMustBeNumber_Unchecked(object sender, RoutedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理必须为数字选项的取消勾选
private void OnlyTakeBeNumber_Unchecked(object sender, RoutedEventArgs e)
{
// 这里可以留空,因为主窗口会处理匹配检查
}
// 处理最小长度选项的勾选
private void ChkMinLength_Checked(object sender, RoutedEventArgs e)
......
......@@ -198,6 +198,10 @@ namespace SmartScan.SetControl.WPF
match.MinLength = int.Parse(userControl.TxtMinLength.Text);
match.MatchMaxLength = userControl.ChkMaxLength.IsChecked == true;
match.MaxLength = int.Parse(userControl.TxtMaxLength.Text);
//新加属性
//kmon
//2025-6-24
match.OnlyTakeBeNumber = userControl.OnlyTakeBeNumber.IsChecked == true;
}
}
}
......@@ -278,6 +282,10 @@ namespace SmartScan.SetControl.WPF
userControl.TxtMinLength.Text = match.MinLength.ToString();
userControl.ChkMaxLength.IsChecked = match.MatchMaxLength;
userControl.TxtMaxLength.Text = match.MaxLength.ToString();
//加属性
//kmon
//2025-6-24
userControl.OnlyTakeBeNumber.IsChecked = match.OnlyTakeBeNumber;
// 设置解析结果
CheckMatchForUserControl(match, userControl);
......@@ -295,6 +303,11 @@ namespace SmartScan.SetControl.WPF
userControl.ChkMaxLength.Checked += (s, e) => userControl_SettingChanged(userControl, match);
userControl.ChkMaxLength.Unchecked += (s, e) => userControl_SettingChanged(userControl, match);
//添加是否只有数字
//kmon
//2025-6-24
userControl.OnlyTakeBeNumber.Checked += (s, e) => userControl_SettingChanged(userControl, match);
userControl.OnlyTakeBeNumber.Unchecked += (s, e) => userControl_SettingChanged(userControl, match);
// 事件挂接
SetupUserControlEvents(userControl, match);
}
......@@ -705,6 +718,16 @@ namespace SmartScan.SetControl.WPF
return "NG";
}
}
//只为数字
//kmon
//2025-6-24
if (userControl.OnlyTakeBeNumber.IsChecked == true)
{
if (!result.All(char.IsDigit))
{
return "NG";
}
}
return result;
}
......
......@@ -15,7 +15,7 @@
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
......
......@@ -32,7 +32,7 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
......@@ -41,6 +41,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!