Skip to content

Commit

Permalink
自定义波特率
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuuu committed Oct 21, 2021
1 parent d996f05 commit 536c152
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion changlog/autoUpdate.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.6.7</version>
<version>1.0.6.8</version>
<url>https://llcom.papapoi.com/llcom.zip</url>
<changelog>https://llcom.papapoi.com/changelog.html</changelog>
<mandatory mode="1">true</mandatory>
Expand Down
7 changes: 7 additions & 0 deletions changlog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

> 欢迎加入交流群:`931546484`

## LLCOM 1.0.6.8

- 增加:记住上次窗口位置与大小
- 增加:自定义波特率功能

---

## LLCOM 1.0.6.7

- 增加:RTS和DTR勾选框
Expand Down
1 change: 1 addition & 0 deletions llcom/View/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<ComboBoxItem Content="1500000"/>
<ComboBoxItem Content="2000000"/>
<ComboBoxItem Content="3000000"/>
<ComboBoxItem Content="{DynamicResource OtherRate}"/>
</ComboBox>
</StatusBarItem>
<Separator Grid.Column="8" />
Expand Down
33 changes: 31 additions & 2 deletions llcom/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,37 @@ private void BaudRateComboBox_SelectionChanged(object sender, SelectionChangedEv
{
if (baudRateComboBox.SelectedItem != null)
{
Tools.Global.setting.baudRate =
int.Parse((baudRateComboBox.SelectedItem as ComboBoxItem).Content.ToString());
if ((baudRateComboBox.SelectedItem as ComboBoxItem).Content.ToString() ==
(TryFindResource("OtherRate") as string ?? "?!"))
{
int br = 0;
Tuple<bool, string> ret = Tools.InputDialog.OpenDialog(TryFindResource("ShowBaudRate") as string ?? "?!",
"115200", TryFindResource("OtherRate") as string ?? "?!");
if (!ret.Item1 || !int.TryParse(ret.Item2,out br))//啥都没选
{
MessageBox.Show(TryFindResource("OtherRateFail") as string ?? "?!");
Task.Run(() =>
{
this.Dispatcher.Invoke(new Action(delegate {
baudRateComboBox.Text = Tools.Global.setting.baudRate.ToString();
}));
});
return;
}
Tools.Global.setting.baudRate = br;
if(Tools.Global.setting.baudRate != br)//说明设置失败了
Task.Run(() =>
{
this.Dispatcher.Invoke(new Action(delegate {
baudRateComboBox.Text = Tools.Global.setting.baudRate.ToString();
}));
});
}
else
{
Tools.Global.setting.baudRate =
int.Parse((baudRateComboBox.SelectedItem as ComboBoxItem).Content.ToString());
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions llcom/languages/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<system:String x:Key="RefreshPortButton">Refresh List</system:String>
<system:String x:Key="ShowPorts">Serial Ports:</system:String>
<system:String x:Key="ShowBaudRate">Baud Rate:</system:String>
<system:String x:Key="OtherRate">Custom</system:String>
<system:String x:Key="OtherRateFail">Custom baud rate set fail.</system:String>
<system:String x:Key="ShowStatus">Status:</system:String>
<system:String x:Key="SentCount">Data sent:</system:String>
<system:String x:Key="ReceivedCount">Data received:</system:String>
Expand Down
2 changes: 2 additions & 0 deletions llcom/languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<system:String x:Key="RefreshPortButton">刷新串口</system:String>
<system:String x:Key="ShowPorts">串口:</system:String>
<system:String x:Key="ShowBaudRate">波特率:</system:String>
<system:String x:Key="OtherRate">自定义</system:String>
<system:String x:Key="OtherRateFail">自定义波特率设置失败</system:String>
<system:String x:Key="ShowStatus">状态:</system:String>
<system:String x:Key="SentCount">已发送字节:</system:String>
<system:String x:Key="ReceivedCount">已接收字节:</system:String>
Expand Down

0 comments on commit 536c152

Please sign in to comment.