Commit ee2815f3 刘韬

下拉框支持动态帅选内容

1 个父辈 402a8ef0
......@@ -106,6 +106,7 @@
<Compile Include="Camera.cs" />
<Compile Include="Config.cs" />
<Compile Include="ConvertBarcode.cs" />
<Compile Include="DebounceHelper.cs" />
<Compile Include="Extension.cs" />
<Compile Include="Extension\Item_Alcoelectro.cs" />
<Compile Include="Extension\EventGroup.cs" />
......
using System;
using System.Windows.Forms;
public class DebounceHelper<T1,T2>
{
private Timer timer;
public event EventHandler<T2> DebouncedTextChanged;
T1 Object;
T2 Value;
public DebounceHelper(int debounceInterval)
{
timer = new Timer();
timer.Interval = debounceInterval;
timer.Tick += Timer_Tick;
}
public void HandleTextChanged(T1 obj,T2 value)
{
Object = obj;
Value=value;
timer.Stop();
timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
DebouncedTextChanged?.Invoke(Object, Value);
}
}
\ No newline at end of file
......@@ -151,6 +151,13 @@ namespace BLL
}
}
};
if (type == "ComboBox") {
//(new ComboBox).TextChanged
R.Add("Event", new Dictionary<string, object>()
{
{ "TextChanged", "ComboBoxTextChanged"}
});
}
listrow.Add(new object[] { L, R });
}
Dictionary<string, object> A = new()
......
......@@ -41,13 +41,34 @@ namespace BLL
macroKey.AddRange(lines);
}
}
private DebounceHelper<FaceComboBox,string> debounceHelper;
public General(Config config)
{
this.config = config;
ReadMacro();
debounceHelper = new DebounceHelper<FaceComboBox,string>(500); // 设置抗抖动的间隔,单位为毫秒
debounceHelper.DebouncedTextChanged += DebounceHelper_DebouncedTextChanged; ;
}
private void DebounceHelper_DebouncedTextChanged(object sender, string e)
{
var s = sender as Asa.FaceControl.FaceComboBox;
//if (s.Text == e)
// return;
s.Items.Clear();
var data = ExtraFileData.DataTitle
.Where(a => a.Contains(e))
.Distinct()
.OrderBy(tit => tit)
.ToArray();
s.Items.AddRange(data);
//s.SelectedIndex = -1;
//s.Enabled = true;
//s.Text = e;
}
public void Clear()
{
LogNet.log.Info("Clear()");
......@@ -341,6 +362,12 @@ namespace BLL
{
updatereelid(lastkey, out _);
}
private void ComboBoxTextChanged(object sender, EventArgs e)
{
var txt = ((FaceComboBox)sender).Text;
debounceHelper.HandleTextChanged((FaceComboBox)sender,txt);
}
private void PrintLabel(object sender, EventArgs e)
{
LogNet.log.Info("Enter PrintLabel Method");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!