Skip to content

Commit

Permalink
【一、新增功能】
Browse files Browse the repository at this point in the history
新增过滤器
新增日志分片
支持虚拟串口功能
编辑菜单新增以下功能
 *自动换行
 *修改字体
 *修改默认字体颜色
 *显示换行符
 *显示空格
 *显示Tab
 *显示行号
 *高亮选中行

【二、优化修复】
项目支持搜索
重构部分代码
发送栏自动换行
异步关闭串口
  • Loading branch information
SuperStudio committed Feb 1, 2023
1 parent 19f5eb9 commit 4a4338d
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 90 deletions.
2 changes: 1 addition & 1 deletion SuperCom/AvalonEdit/SearchPanel/SearchPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" />
</Viewbox>
</Button>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions SuperCom/Config/UrlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class UrlManager
public static Dictionary<string, UpgradeSource> UpgradeSourceDict = new Dictionary<string, UpgradeSource>()
{
{"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") },
};

Expand Down
10 changes: 10 additions & 0 deletions SuperCom/Config/WindowConfig/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions SuperCom/Entity/CustomSerialPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
102 changes: 66 additions & 36 deletions SuperCom/MainWindow.xaml

Large diffs are not rendered by default.

76 changes: 63 additions & 13 deletions SuperCom/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -485,20 +488,45 @@ private async Task<bool> 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<bool> 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;
}


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<string> list = vieModel.SendHistory.Where(arg => arg.ToLower().IndexOf(text.ToLower()) >= 0).ToList();
Popup popup = grid.Children.OfType<Popup>().FirstOrDefault();
Expand Down Expand Up @@ -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<ToggleButton>().FirstOrDefault();
toggleButton.IsChecked = false;
}

private void AddNewVarMonitor(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -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<TextBox>().FirstOrDefault();
if ((bool)toggleButton.IsChecked)
{
textBox.TextWrapping = TextWrapping.Wrap;

}
else
{
textBox.TextWrapping = TextWrapping.NoWrap;
}
}
}
}
4 changes: 2 additions & 2 deletions SuperCom/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Binary file modified SuperCom/References/ICSharpCode.AvalonEdit.dll
Binary file not shown.
Binary file modified SuperCom/References/Newtonsoft.Json.dll
Binary file not shown.
Binary file modified SuperCom/References/SuperControls.Style.dll
Binary file not shown.
Binary file modified SuperCom/References/SuperUtils.dll
Binary file not shown.
8 changes: 7 additions & 1 deletion SuperCom/SuperCom.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ XCOPY "$(ProjectDir)Files\app_config.json" "$(ProjectDir)bin\Release" /E /Y
<PropertyGroup>
<PreBuildEvent>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</PreBuildEvent>
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




</PreBuildEvent>
</PropertyGroup>
</Project>
49 changes: 40 additions & 9 deletions SuperCom/ViewModel/VieModel_AdvancedSend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ public class VieModel_AdvancedSend : ViewModelBase
public Action<bool> OnRunCommand { get; set; }
private static SqliteMapper<AdvancedSend> mapper { get; set; }

private ObservableCollection<AdvancedSend> _Projects;
public ObservableCollection<AdvancedSend> Projects

public List<AdvancedSend> AllProjects { get; set; }

private ObservableCollection<AdvancedSend> _CurrentProjects;
public ObservableCollection<AdvancedSend> CurrentProjects
{
get { return _Projects; }
set { _Projects = value; RaisePropertyChanged(); }
get { return _CurrentProjects; }
set { _CurrentProjects = value; RaisePropertyChanged(); }
}

private ObservableCollection<SendCommand> _SendCommands;
Expand Down Expand Up @@ -175,15 +178,16 @@ static VieModel_AdvancedSend()

private void Init()
{
Projects = new ObservableCollection<AdvancedSend>();
CurrentProjects = new ObservableCollection<AdvancedSend>();
SendCommands = new ObservableCollection<SendCommand>();
AllProjects = new List<AdvancedSend>();
// 从数据库中读取
if (mapper != null)
{
List<AdvancedSend> 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)
Expand All @@ -197,6 +201,30 @@ private void Init()
LoadSideComports();
}

public void SearchProject(string name)
{
CurrentProjects = new ObservableCollection<AdvancedSend>();
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();
}




Expand Down Expand Up @@ -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()
Expand Down
30 changes: 27 additions & 3 deletions SuperCom/Windows/Window_AdvancedSend.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@

<Grid Background="{DynamicResource Window.Side.Background}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
Expand All @@ -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}" />
</Viewbox>
</Border>
</StackPanel>
<!-- SelectedIndex="{Binding Path=SideIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" -->

<super:SearchBox
x:Name="projectSearchBox"
Grid.Row="1"
Margin="0,5,0,10"
Background="{DynamicResource Window.Title.Background}"
Search="SearchProjectByName"
SearchOnTextChanged="True"
ShowSearchButton="False"
Style="{StaticResource SearchBoxStyle}" />
<ListBox
Name="sideListBox"
Grid.Row="1"
Grid.Row="2"
Margin="0,0,1,0"
VerticalAlignment="Top"
HorizontalContentAlignment="Stretch"
d:ItemsSource="{d:SampleData ItemCount=5}"
Background="Transparent"
IsEnabled="{Binding DataContext.RunningCommands, Converter={StaticResource OppositeBooleanConverter}, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
ItemContainerStyle="{StaticResource NormalListBoxItem}"
ItemsSource="{Binding Projects}"
ItemsSource="{Binding CurrentProjects}"
SelectionChanged="ListBox_SelectionChanged"
Style="{StaticResource NormalListBox}">
<ListBox.ItemTemplate>
Expand All @@ -164,6 +176,7 @@
<ContextMenu>
<MenuItem Click="RenameProject" Header="重命名" />
<MenuItem
super:CommonExt.HoverBackground="{DynamicResource Menu.Hover.Deep.Background}"
Click="DeleteProjectInMenuItem"
Header="删除"
Tag="{Binding ProjectID}" />
Expand Down Expand Up @@ -236,6 +249,7 @@
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>

<Border
Expand Down Expand Up @@ -724,6 +738,16 @@


</DataGrid>

<Button
Grid.Row="3"
MinWidth="100"
Margin="10"
HorizontalAlignment="Right"
Click="SaveChanges"
Content="保存"
Style="{StaticResource ButtonSuccess}"
Visibility="Collapsed" />
</Grid>
</Grid>
</super:BaseWindow>
Loading

0 comments on commit 4a4338d

Please sign in to comment.