diff --git a/llcom/View/MainWindow.xaml b/llcom/View/MainWindow.xaml
index 12fb7de0..204a6172 100644
--- a/llcom/View/MainWindow.xaml
+++ b/llcom/View/MainWindow.xaml
@@ -210,7 +210,7 @@
-
+
diff --git a/llcom/View/MainWindow.xaml.cs b/llcom/View/MainWindow.xaml.cs
index 1dfa1f6c..f6f61c97 100644
--- a/llcom/View/MainWindow.xaml.cs
+++ b/llcom/View/MainWindow.xaml.cs
@@ -100,8 +100,8 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
else
{
lastBaudRateSelectedIndex = baudRateComboBox.Items.Count - 1;//防止弹窗提示
- baudRateComboBox.Items[baudRateComboBox.Items.Count - 1] = br;
- baudRateComboBox.Text = br;
+ SetBaudRateCustomItemText(br);
+ baudRateComboBox.Text = GetBaudRateCustomLabel(br);
}
// 绑定事件监听,用于监听HID设备插拔
@@ -712,12 +712,32 @@ private void ClearLogButton_Click(object sender, RoutedEventArgs e)
}
private int lastBaudRateSelectedIndex = -1;
+ private bool baudRateCustomItemClicked = false;
+ private void BaudRateCustomItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ baudRateCustomItemClicked = true;
+ }
+ private string GetBaudRateCustomLabel(string value)
+ {
+ var baseLabel = TryFindResource("OtherRate") as string ?? "?!";
+ return string.IsNullOrEmpty(value) ? baseLabel : baseLabel + ":" + value;
+ }
+ private void SetBaudRateCustomItemText(string value)
+ {
+ string label = GetBaudRateCustomLabel(value);
+ int last = baudRateComboBox.Items.Count - 1;
+ var item = baudRateComboBox.Items[last] as ComboBoxItem;
+ if (item != null) item.Content = label;
+ else baudRateComboBox.Items[last] = label;
+ }
private void BaudRateComboBox_Changed(object sender, EventArgs e)
{
//选的没变
- if(lastBaudRateSelectedIndex == baudRateComboBox.SelectedIndex)
+ if(lastBaudRateSelectedIndex == baudRateComboBox.SelectedIndex && !baudRateCustomItemClicked)
return;
+ baudRateCustomItemClicked = false;
+
if (baudRateComboBox.SelectedItem != null)
{
lastBaudRateSelectedIndex = baudRateComboBox.SelectedIndex;
@@ -735,8 +755,8 @@ private void BaudRateComboBox_Changed(object sender, EventArgs e)
{
this.Dispatcher.Invoke(new Action(delegate {
var text = Tools.Global.setting.baudRate.ToString();
- baudRateComboBox.Items[baudRateComboBox.Items.Count - 1] = text;
- baudRateComboBox.Text = text;
+ SetBaudRateCustomItemText(text);
+ baudRateComboBox.Text = GetBaudRateCustomLabel(text);
}));
});
}
@@ -744,7 +764,7 @@ private void BaudRateComboBox_Changed(object sender, EventArgs e)
{
Tools.Global.setting.baudRate =
int.Parse((baudRateComboBox.SelectedItem as ComboBoxItem).Content.ToString());
- baudRateComboBox.Items[baudRateComboBox.Items.Count - 1] = TryFindResource("OtherRate") as string ?? "?!";
+ SetBaudRateCustomItemText("");
}
}
}