diff --git a/SuperCom/AvalonEdit/SearchPanel/SearchPanel.xaml b/SuperCom/AvalonEdit/SearchPanel/SearchPanel.xaml index c3a7ed9..2c6280c 100644 --- a/SuperCom/AvalonEdit/SearchPanel/SearchPanel.xaml +++ b/SuperCom/AvalonEdit/SearchPanel/SearchPanel.xaml @@ -255,7 +255,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M610.218667 505.6l398.08-387.413333a49.664 49.664 0 0 0 0-71.338667l-2.133334-2.133333a52.992 52.992 0 0 0-73.301333 0L534.784 432.64 136.704 44.373333a52.992 52.992 0 0 0-73.386667 0L61.269333 46.592a48.810667 48.810667 0 0 0 0 71.338667l398.165334 387.669333-398.165334 387.498667a49.664 49.664 0 0 0 0 71.253333l2.218667 2.133333c20.48 19.626667 52.821333 19.626667 73.301333 0l398.08-387.413333 398.08 387.413333c20.48 19.626667 52.906667 19.626667 73.386667 0l2.048-2.133333a49.664 49.664 0 0 0 0-71.253333l-398.08-387.413334z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> diff --git a/SuperCom/Config/UrlManager.cs b/SuperCom/Config/UrlManager.cs index 3034f22..95ffca6 100644 --- a/SuperCom/Config/UrlManager.cs +++ b/SuperCom/Config/UrlManager.cs @@ -16,6 +16,7 @@ public static class UrlManager public static Dictionary UpgradeSourceDict = new Dictionary() { {"Github",new UpgradeSource("https://superstudio.github.io/","https://github.com/SuperStudio/SuperCom/releases","SuperCom-Upgrade") }, + {"StormGit加速",new UpgradeSource("https://venomplum-54uhej.stormkit.dev/","https://github.com/SuperStudio/SuperCom/releases","") }, {"Github加速",new UpgradeSource("https://cdn.jsdelivr.net/gh/SuperStudio/","https://gitee.com/SuperStudio/SuperCom/releases","SuperCom-Upgrade") }, }; diff --git a/SuperCom/Config/WindowConfig/Main.cs b/SuperCom/Config/WindowConfig/Main.cs index d649dc6..0293e61 100644 --- a/SuperCom/Config/WindowConfig/Main.cs +++ b/SuperCom/Config/WindowConfig/Main.cs @@ -63,6 +63,16 @@ public bool ShowRightPanel #region "AvalonText 相关配置" + private bool _AutoWrap = false; + public bool AutoWrap + { + get { return _AutoWrap; } + set + { + _AutoWrap = value; + RaisePropertyChanged(); + } + } private bool _ShowEndOfLine = false; public bool ShowEndOfLine { diff --git a/SuperCom/Entity/CustomSerialPort.cs b/SuperCom/Entity/CustomSerialPort.cs index b459b51..7c6ba4b 100644 --- a/SuperCom/Entity/CustomSerialPort.cs +++ b/SuperCom/Entity/CustomSerialPort.cs @@ -12,6 +12,9 @@ namespace SuperCom.Entity { public class CustomSerialPort : SerialPort, INotifyPropertyChanged { + + public const int CLOSE_TIME_OUT = 5; + public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged([CallerMemberName] string name = null) { diff --git a/SuperCom/MainWindow.xaml b/SuperCom/MainWindow.xaml index a54840d..e6b9f79 100644 --- a/SuperCom/MainWindow.xaml +++ b/SuperCom/MainWindow.xaml @@ -129,9 +129,14 @@ Style="{StaticResource TitleButton}"> + - + IsChecked="{Binding ShowRightPanel, Source={x:Static config:ConfigManager.Main}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />--> @@ -301,7 +306,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M585.246075 875.340272l408.227201-447.966132c57.440818-63.040395 12.824837-164.374669-72.613865-164.374669H104.224378c-85.25807 0-130.054683 101.334274-72.613865 164.374669l408.407832 447.7855c39.016405 42.809667 106.211325 42.809667 145.22773 0.180632z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> @@ -560,7 +565,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M758.35 121.71H704.7c-14.19 0-27.88 6.14-37.04 17.11-27.48 32.81-106.09 54.05-155.61 54.05s-128.13-21.24-155.61-54.05c-9.26-10.98-22.85-17.11-37.04-17.11h-53.75c-13.08 0-25.57 5.23-34.83 14.7L52.56 317.69c-11.48 11.67-11.48 30.5 0 42.17l108.7 110.62c11.48 11.68 30 11.68 41.47 0l3.62-3.62c3.93-3.93 10.57-1.21 10.57 4.43V856.9c0 25.06 19.93 45.39 44.59 45.39h500.95c24.66 0 44.59-20.33 44.59-45.39V471.19c0-5.64 6.64-8.46 10.57-4.43l3.62 3.63c11.48 11.67 30 11.67 41.47 0l108.7-110.62c11.48-11.67 11.48-30.5 0-42.17L793.18 136.31c-9.26-9.36-21.84-14.6-34.83-14.6z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> @@ -581,7 +586,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M512 0h6144c307.2 0 512 204.8 512 512s-204.8 512-512 512H512c-307.2 0-512-204.8-512-512s204.8-512 512-512z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> @@ -664,7 +669,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M848.738462 608.137846c-8.467692 178.097231-155.963077 319.881846-336.659693 319.881846-186.171077 0-337.132308-150.449231-337.132307-336.068923 0-180.145231 142.178462-327.168 320.787692-335.675077v159.82277l353.122461-192.039385L495.734154 0v160.098462C263.995077 168.684308 78.769231 358.754462 78.769231 591.872 78.769231 830.542769 272.777846 1024 512.157538 1024 746.062769 1024 936.644923 839.286154 945.230769 608.137846h-96.492307z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> @@ -684,7 +689,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16z m-52 268H212V212h200v200z m452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16z m-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16z m-52 268H212V612h200v200z m452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16z m-52 268H612V612h200v200z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> + Fill="{DynamicResource Window.Foreground}" /> @@ -850,7 +855,7 @@ Click="OpenDonate" Header="为我充电" Icon="/Resources/Pictures/donate.png" - Visibility="{Binding ShowDonate, Converter={StaticResource bool2VisibilityConverter}}" /> + Visibility="Collapsed" /> @@ -866,7 +871,7 @@ Width="20" Height="auto" VerticalAlignment="Center"> - + @@ -1095,7 +1100,7 @@ Width="15" Height="auto" VerticalAlignment="Center"> - + @@ -1222,7 +1227,7 @@ Width="15" Height="auto" VerticalAlignment="Center"> - + @@ -1432,7 +1437,7 @@ - + @@ -1471,7 +1476,7 @@ ScrollViewer.VerticalScrollBarVisibility="Auto" SyntaxHighlighting="ComLog" TextChanged="TextBox_TextChanged" - WordWrap="True"> + WordWrap="{Binding AutoWrap, Source={x:Static config:ConfigManager.Main}, Mode=OneWay}"> @@ -1494,7 +1499,8 @@ Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top" - Visibility="{Binding ShowRightPanel, Source={x:Static config:ConfigManager.Main}, Mode=OneWay, Converter={StaticResource bool2VisibilityConverter}}"> + Visibility="Collapsed"> + + Fill="{DynamicResource Window.Foreground}" /> @@ -1811,7 +1817,7 @@ VerticalAlignment="Center"> @@ -1890,7 +1896,7 @@ Width="20" Height="auto" VerticalAlignment="Center"> - + @@ -1999,7 +2005,8 @@ + HorizontalAlignment="Right" + Visibility="Collapsed"> @@ -2404,19 +2411,42 @@ - + + + + + + + + + + + - + diff --git a/SuperCom/MainWindow.xaml.cs b/SuperCom/MainWindow.xaml.cs index a6c02be..ce17f64 100644 --- a/SuperCom/MainWindow.xaml.cs +++ b/SuperCom/MainWindow.xaml.cs @@ -284,13 +284,13 @@ private void CloseTabItem(object sender, RoutedEventArgs e) Border border = grid.Parent as Border; string portName = border.Tag.ToString(); if (string.IsNullOrEmpty(portName) || vieModel.PortTabItems?.Count <= 0) return; - RemovePortTabItem(portName); + RemovePortTabItem(portName, button); // 默认选中 0 if (vieModel.PortTabItems.Count > 0) SetPortTabSelected(vieModel.PortTabItems[0].Name); } - private async void RemovePortTabItem(string portName) + private async void RemovePortTabItem(string portName, Button button = null) { if (vieModel.PortTabItems == null || string.IsNullOrEmpty(portName)) return; SaveComSettings(); @@ -307,8 +307,11 @@ private async void RemovePortTabItem(string portName) } if (idx >= 0 && idx < vieModel.PortTabItems.Count) { - await ClosePort(portName); - vieModel.PortTabItems.RemoveAt(idx); + if (button != null) button.IsEnabled = false; + bool success = await ClosePort(portName); + if (success) + vieModel.PortTabItems.RemoveAt(idx); + if (button != null) button.IsEnabled = true; } } catch (Exception ex) @@ -485,20 +488,45 @@ private async Task ClosePort(string portName) CustomSerialPort serialPort = portTabItem.SerialPort; if (serialPort != null && serialPort.IsOpen) { - try + bool success = await AsynClosePort(serialPort); + if (success) { - serialPort.Close(); - serialPort.Dispose(); portTabItem.StopFilterTask(); portTabItem.StopMonitorTask(); + return SetPortConnectStatus(portName, false); } - catch (Exception ex) + else { - MessageNotify.Error(ex.Message); + MessageNotify.Error($"{serialPort.PortName} 关闭串口超时"); + return false; } } - await Task.Delay(1); - return SetPortConnectStatus(portName, false); + else + { + return true; + } + } + + public async Task AsynClosePort(CustomSerialPort serialPort) + { + try + { + return await Task.Run(() => + { + serialPort.Close(); + serialPort.Dispose(); + return true; + }).TimeoutAfter(TimeSpan.FromSeconds(CustomSerialPort.CLOSE_TIME_OUT)); + } + catch (TimeoutException ex) + { + Console.WriteLine(ex.Message); + } + catch (Exception ex) + { + MessageNotify.Error(ex.Message); + } + return false; } @@ -656,7 +684,6 @@ private void TextBox_TextChanged(object sender, EventArgs e) private void ShowAbout(object sender, RoutedEventArgs e) { - //new CustomWindows.About(this).ShowDialog(); Dialog_About about = new Dialog_About(); string local = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); local = local.Substring(0, local.Length - ".0.0".Length); @@ -1613,7 +1640,7 @@ private void SendTextBox_PreviewKeyDown(object sender, KeyEventArgs e) TextBox textBox = sender as TextBox; - Grid grid = (textBox.Parent as Border).Parent as Grid; + Grid grid = ((textBox.Parent as Grid).Parent as Border).Parent as Grid; string text = textBox.Text.Trim(); List list = vieModel.SendHistory.Where(arg => arg.ToLower().IndexOf(text.ToLower()) >= 0).ToList(); Popup popup = grid.Children.OfType().FirstOrDefault(); @@ -2856,6 +2883,13 @@ private void MenuItem_SubmenuOpened(object sender, RoutedEventArgs e) private void OnShowRightPanel(object sender, RoutedEventArgs e) { ConfigManager.Main.ShowRightPanel = false; + StackPanel panel = (sender as Button).Parent as StackPanel; + Grid grid = panel.Parent as Grid; + Grid rootGrid = grid.Parent as Grid; + Grid monitorGrid = rootGrid.FindName("monitorGrid") as Grid; + monitorGrid.Visibility = Visibility.Collapsed; + ToggleButton toggleButton = panel.Children.OfType().FirstOrDefault(); + toggleButton.IsChecked = false; } private void AddNewVarMonitor(object sender, RoutedEventArgs e) @@ -2947,5 +2981,21 @@ private void SaveVarMonitor(object sender, RoutedEventArgs e) } } } + + private void ToggleButton_Click(object sender, RoutedEventArgs e) + { + ToggleButton toggleButton = sender as ToggleButton; + Grid grid = toggleButton.Parent as Grid; + TextBox textBox = grid.Children.OfType().FirstOrDefault(); + if ((bool)toggleButton.IsChecked) + { + textBox.TextWrapping = TextWrapping.Wrap; + + } + else + { + textBox.TextWrapping = TextWrapping.NoWrap; + } + } } } diff --git a/SuperCom/Properties/AssemblyInfo.cs b/SuperCom/Properties/AssemblyInfo.cs index 3b40826..de2a252 100644 --- a/SuperCom/Properties/AssemblyInfo.cs +++ b/SuperCom/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.8.0.0")] -[assembly: AssemblyFileVersion("2.8.0.0")] +[assembly: AssemblyVersion("2.9.0.0")] +[assembly: AssemblyFileVersion("2.9.0.0")] diff --git a/SuperCom/References/ICSharpCode.AvalonEdit.dll b/SuperCom/References/ICSharpCode.AvalonEdit.dll index fa7c447..e2a4f39 100644 Binary files a/SuperCom/References/ICSharpCode.AvalonEdit.dll and b/SuperCom/References/ICSharpCode.AvalonEdit.dll differ diff --git a/SuperCom/References/Newtonsoft.Json.dll b/SuperCom/References/Newtonsoft.Json.dll index b57b61a..85c394c 100644 Binary files a/SuperCom/References/Newtonsoft.Json.dll and b/SuperCom/References/Newtonsoft.Json.dll differ diff --git a/SuperCom/References/SuperControls.Style.dll b/SuperCom/References/SuperControls.Style.dll index fed11df..53ac61d 100644 Binary files a/SuperCom/References/SuperControls.Style.dll and b/SuperCom/References/SuperControls.Style.dll differ diff --git a/SuperCom/References/SuperUtils.dll b/SuperCom/References/SuperUtils.dll index ddbbf22..92c289f 100644 Binary files a/SuperCom/References/SuperUtils.dll and b/SuperCom/References/SuperUtils.dll differ diff --git a/SuperCom/SuperCom.csproj b/SuperCom/SuperCom.csproj index cfd3714..458fd70 100644 --- a/SuperCom/SuperCom.csproj +++ b/SuperCom/SuperCom.csproj @@ -299,6 +299,12 @@ XCOPY "$(ProjectDir)Files\app_config.json" "$(ProjectDir)bin\Release" /E /Y XCOPY "D:\SuperStudio\Newtonsoft.Json\Src\Newtonsoft.Json\bin\Release\net472\Newtonsoft.Json.dll" "$(ProjectDir)References" /E /Y /i XCOPY "D:\SuperStudio\SuperUtils\SuperUtils\bin\Debug\SuperUtils.dll" "$(ProjectDir)References" /E /Y /i -XCOPY "D:\SuperStudio\SuperControls\SuperControls.Style\bin\Debug\SuperControls.Style.dll" "$(ProjectDir)References" /E /Y /i +XCOPY "D:\SuperStudio\SuperControls\SuperControls.Style\bin\Debug\SuperControls.Style.dll" "$(ProjectDir)References" /E /Y /i +XCOPY "D:\SuperStudio\AvalonEdit\ICSharpCode.AvalonEdit\bin\Release\net462\ICSharpCode.AvalonEdit.dll" "$(ProjectDir)References" /E /Y /i + + + + + \ No newline at end of file diff --git a/SuperCom/ViewModel/VieModel_AdvancedSend.cs b/SuperCom/ViewModel/VieModel_AdvancedSend.cs index 297018b..95eafe6 100644 --- a/SuperCom/ViewModel/VieModel_AdvancedSend.cs +++ b/SuperCom/ViewModel/VieModel_AdvancedSend.cs @@ -23,11 +23,14 @@ public class VieModel_AdvancedSend : ViewModelBase public Action OnRunCommand { get; set; } private static SqliteMapper mapper { get; set; } - private ObservableCollection _Projects; - public ObservableCollection Projects + + public List AllProjects { get; set; } + + private ObservableCollection _CurrentProjects; + public ObservableCollection CurrentProjects { - get { return _Projects; } - set { _Projects = value; RaisePropertyChanged(); } + get { return _CurrentProjects; } + set { _CurrentProjects = value; RaisePropertyChanged(); } } private ObservableCollection _SendCommands; @@ -175,15 +178,16 @@ static VieModel_AdvancedSend() private void Init() { - Projects = new ObservableCollection(); + CurrentProjects = new ObservableCollection(); SendCommands = new ObservableCollection(); + AllProjects = new List(); // ݿжȡ if (mapper != null) { - List advancedSends = mapper.SelectList(); - foreach (var item in advancedSends) + AllProjects = mapper.SelectList(); + foreach (var item in AllProjects) { - Projects.Add(item); + CurrentProjects.Add(item); } } foreach (Window window in App.Current.Windows) @@ -197,6 +201,30 @@ private void Init() LoadSideComports(); } + public void SearchProject(string name) + { + CurrentProjects = new ObservableCollection(); + if (string.IsNullOrEmpty(name)) + { + AllProjects = mapper.SelectList(); + foreach (var item in AllProjects) + CurrentProjects.Add(item); + } + else + { + foreach (var item in AllProjects.Where(arg => arg.ProjectName + .ToLower().IndexOf(name.ToLower()) >= 0)) + { + CurrentProjects.Add(item); + } + } + } + + public void LoadAllProject() + { + AllProjects = mapper.SelectList(); + } + @@ -254,7 +282,10 @@ public void AddProject(string projectName) send.ProjectName = projectName; bool success = mapper.Insert(send); if (success) - Projects.Add(send); + { + CurrentProjects.Add(send); + AllProjects.Add(send); + } } public void SetCurrentSendCommands() diff --git a/SuperCom/Windows/Window_AdvancedSend.xaml b/SuperCom/Windows/Window_AdvancedSend.xaml index 4216085..2ad1682 100644 --- a/SuperCom/Windows/Window_AdvancedSend.xaml +++ b/SuperCom/Windows/Window_AdvancedSend.xaml @@ -126,6 +126,7 @@ + @@ -140,21 +141,32 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Data="M925.696 384q19.456 0 37.376 7.68t30.72 20.48 20.48 30.72 7.68 37.376q0 20.48-7.68 37.888t-20.48 30.208-30.72 20.48-37.376 7.68l-287.744 0 0 287.744q0 20.48-7.68 37.888t-20.48 30.208-30.72 20.48-37.376 7.68q-20.48 0-37.888-7.68t-30.208-20.48-20.48-30.208-7.68-37.888l0-287.744-287.744 0q-20.48 0-37.888-7.68t-30.208-20.48-20.48-30.208-7.68-37.888q0-19.456 7.68-37.376t20.48-30.72 30.208-20.48 37.888-7.68l287.744 0 0-287.744q0-19.456 7.68-37.376t20.48-30.72 30.208-20.48 37.888-7.68q39.936 0 68.096 28.16t28.16 68.096l0 287.744 287.744 0z" - Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" /> + Fill="{DynamicResource Window.Foreground}" /> + + @@ -164,6 +176,7 @@ @@ -236,6 +249,7 @@ + + +