From f99a02d09686a0362474259a05318c3282c63c88 Mon Sep 17 00:00:00 2001 From: SuperStudio Date: Wed, 3 May 2023 20:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=B8=80=E3=80=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=91=20=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【二、优化修复】 统一 const 变量 --- SuperCom.Test/SuperCom.Test.csproj | 8 +- SuperCom.Test/UnitTest1.cs | 14 -- .../UnitTests/Comparers/ComPortComparer.cs | 25 ++++ SuperCom/App.xaml.cs | 14 +- SuperCom/Config/CommonSettings.cs | 3 +- SuperCom/Config/ConfigManager.cs | 4 + SuperCom/Config/UrlManager.cs | 2 + SuperCom/Converters/ColorToBrushConverter.cs | 6 +- SuperCom/Entity/AdvancedSend.cs | 36 +++-- SuperCom/Entity/ComSettings.cs | 20 ++- SuperCom/Entity/HighLightRule.cs | 52 +++---- SuperCom/Entity/PortSetting.cs | 48 ++++-- SuperCom/Entity/PortTabItem.cs | 107 +++++-------- .../{CustomSerialPort.cs => SerialPortEx.cs} | 128 ++++++++-------- SuperCom/Entity/ShortCutBinding.cs | 16 +- SuperCom/Entity/SideComPort.cs | 7 - SuperCom/Entity/VarMonitor.cs | 29 ++-- SuperCom/Entity/VirtualPort.cs | 6 +- SuperCom/Lang/LangManager.cs | 2 +- SuperCom/Logger/Logger.cs | 4 +- SuperCom/MainWindow.xaml.cs | 141 ++++-------------- SuperCom/References/SuperUtils.dll | Bin 178176 -> 178176 bytes SuperCom/SuperCom.csproj | 2 +- SuperCom/Upgrade/UpgradeHelper.cs | 45 +++--- SuperCom/ViewModel/VieModel_AdvancedSend.cs | 62 ++++---- SuperCom/ViewModel/VieModel_Main.cs | 102 ++++++------- SuperCom/ViewModel/VieModel_Setting.cs | 42 +++--- SuperCom/WatchDog/AbstractDog.cs | 3 - SuperCom/Windows/Window_AdvancedSend.xaml.cs | 10 +- SuperCom/Windows/Window_Setting.xaml.cs | 22 +-- SuperCom/Windows/Window_ShortCut.xaml.cs | 40 ++--- SuperCom/Windows/Window_VirtualPort.xaml.cs | 37 ++--- 32 files changed, 467 insertions(+), 570 deletions(-) delete mode 100644 SuperCom.Test/UnitTest1.cs create mode 100644 SuperCom.Test/UnitTests/Comparers/ComPortComparer.cs rename SuperCom/Entity/{CustomSerialPort.cs => SerialPortEx.cs} (79%) diff --git a/SuperCom.Test/SuperCom.Test.csproj b/SuperCom.Test/SuperCom.Test.csproj index 1c68ff3..ef1db8f 100644 --- a/SuperCom.Test/SuperCom.Test.csproj +++ b/SuperCom.Test/SuperCom.Test.csproj @@ -49,13 +49,19 @@ - + + + + {7782F9E2-0821-4C05-8DA5-04367CD670FD} + SuperCom + + diff --git a/SuperCom.Test/UnitTest1.cs b/SuperCom.Test/UnitTest1.cs deleted file mode 100644 index a7aadbf..0000000 --- a/SuperCom.Test/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; - -namespace SuperCom.Test -{ - [TestClass] - public class UnitTest1 - { - [TestMethod] - public void TestMethod1() - { - } - } -} diff --git a/SuperCom.Test/UnitTests/Comparers/ComPortComparer.cs b/SuperCom.Test/UnitTests/Comparers/ComPortComparer.cs new file mode 100644 index 0000000..286b8a5 --- /dev/null +++ b/SuperCom.Test/UnitTests/Comparers/ComPortComparer.cs @@ -0,0 +1,25 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Linq; + +namespace SuperCom.Test +{ + [TestClass] + public class ComPortComparer + { + [TestMethod] + public void ComPortComparerTest() + { + List comList = new List() + { + "COM1","COM11","COM111","COM2","COM20","COM99" + }; + List sorted = new List() + { + "COM1","COM2","COM11","COM20","COM99","COM111" + }; + List list = comList.OrderBy(arg => arg, new SuperCom.Comparers.ComPortComparer()).ToList(); + CollectionAssert.AreEqual(list, sorted); + } + } +} diff --git a/SuperCom/App.xaml.cs b/SuperCom/App.xaml.cs index 93f8a6c..e82c153 100644 --- a/SuperCom/App.xaml.cs +++ b/SuperCom/App.xaml.cs @@ -4,9 +4,7 @@ using SuperUtils.Framework.Logger; using SuperUtils.IO; using System; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Threading; namespace SuperCom { @@ -18,19 +16,19 @@ namespace SuperCom public partial class App : Application { public static AbstractLogger Logger = Log.Logger.Instance; - private static MemoryDog memoryDog { get; set; } + private static MemoryDog MemoryDog { get; set; } public static Action OnMemoryDog; public static Action OnMemoryChanged; static App() { - memoryDog = new MemoryDog(); - memoryDog.OnNotFeed += () => + MemoryDog = new MemoryDog(); + MemoryDog.OnNotFeed += () => { OnMemoryDog?.Invoke(); }; - memoryDog.OnMemoryChanged += (memory) => + MemoryDog.OnMemoryChanged += (memory) => { OnMemoryChanged?.Invoke(memory); }; @@ -43,7 +41,7 @@ static App() { Logger.Error(str); }; - Logger.Info("APP 初始化"); + Logger.Info("app init"); } protected override void OnStartup(StartupEventArgs e) @@ -63,7 +61,7 @@ protected override void OnStartup(StartupEventArgs e) Logger.Info("异常后处理启动"); #endif // 看门狗 - memoryDog.Watch(); + MemoryDog.Watch(); base.OnStartup(e); } diff --git a/SuperCom/Config/CommonSettings.cs b/SuperCom/Config/CommonSettings.cs index 6858657..cfe6416 100644 --- a/SuperCom/Config/CommonSettings.cs +++ b/SuperCom/Config/CommonSettings.cs @@ -11,7 +11,8 @@ namespace SuperCom.Config.WindowConfig public class CommonSettings : AbstractConfig { - public static string DEFAULT_LOGNAMEFORMAT = "[%C] %Y-%M-%D %h-%m-%s.%f"; + public const string DEFAULT_LOGNAMEFORMAT = "[%C] %Y-%M-%D %h-%m-%s.%f"; + public static string DEFAULT_LOG_SAVE_DIR = System.IO.Path.Combine(Environment.CurrentDirectory, "logs", "%Y-%M-%D"); public static List SUPPORT_FORMAT = new List() { diff --git a/SuperCom/Config/ConfigManager.cs b/SuperCom/Config/ConfigManager.cs index d17358f..93ad696 100644 --- a/SuperCom/Config/ConfigManager.cs +++ b/SuperCom/Config/ConfigManager.cs @@ -9,6 +9,10 @@ public static class ConfigManager public const string SQLITE_DATA_PATH = "user_data.sqlite"; public const string RELEASE_DATE = "2023-04-23"; + public const string LICENSE = "GPL-3.0"; + public const string AUTHOR = "chao"; + public const string APP_NAME = "SuperCom"; + public const string APP_SUB_NAME = "超级串口工具"; public static Main Main { get; set; } public static CommonSettings CommonSettings { get; set; } public static Settings Settings { get; set; } diff --git a/SuperCom/Config/UrlManager.cs b/SuperCom/Config/UrlManager.cs index fc990bf..551e8de 100644 --- a/SuperCom/Config/UrlManager.cs +++ b/SuperCom/Config/UrlManager.cs @@ -27,10 +27,12 @@ public static class UrlManager private static string DonateJsonBasePath = "SuperSudio-Donate"; private static string PluginBasePath = "SuperPlugins"; + public const string GITHUB_URL = "https://github.com/SuperStudio/SuperCom"; public static string FeedbackUrl = "https://github.com/SuperStudio/SuperCom/issues"; public static string HelpUrl = "https://github.com/SuperStudio/SuperCom/wiki"; public const string NOTICE_URL = "https://superstudio.github.io/SuperCom-Upgrade/notice.json"; + public static List REFERENCE_DATAS = new List() { new ReferenceData("Serial and UART Tutorial", diff --git a/SuperCom/Converters/ColorToBrushConverter.cs b/SuperCom/Converters/ColorToBrushConverter.cs index 5115e58..c4f779d 100644 --- a/SuperCom/Converters/ColorToBrushConverter.cs +++ b/SuperCom/Converters/ColorToBrushConverter.cs @@ -12,8 +12,10 @@ public class ColorToBrushConverter : IValueConverter { public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { - if (value == null) return Brushes.Black; - SolidColorBrush solidColorBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString())); + if (value == null) + return Brushes.Black; + SolidColorBrush solidColorBrush = + new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString())); return solidColorBrush; } diff --git a/SuperCom/Entity/AdvancedSend.cs b/SuperCom/Entity/AdvancedSend.cs index 0ae2e92..6c5eab1 100644 --- a/SuperCom/Entity/AdvancedSend.cs +++ b/SuperCom/Entity/AdvancedSend.cs @@ -1,21 +1,8 @@ using SuperCom.Config; using SuperUtils.Framework.ORM.Attributes; using SuperUtils.Framework.ORM.Mapper; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ICSharpCode.AvalonEdit; -using SuperUtils.Time; -using System; -using System.ComponentModel; -using System.IO; -using System.Runtime.CompilerServices; -using System.Text; -using System.Windows.Controls; -using System.Windows.Threading; using SuperUtils.WPF.VieModel; +using System.Collections.Generic; namespace SuperCom.Entity { @@ -32,8 +19,11 @@ public enum RunningStatus public class SendCommand : ViewModelBase { + public const int DEFAULT_DELAY = 200; + public const int DEFAULT_TIMEOUT = 5000; - private static Dictionary RunningStatusToString = new Dictionary() { + private static readonly Dictionary RUN_STATUS_TABLE = + new Dictionary() { { RunningStatus.WaitingToRun,"就绪" }, { RunningStatus.WaitingDelay,"等待中" }, { RunningStatus.Running,"运行中" }, @@ -42,8 +32,7 @@ public class SendCommand : ViewModelBase { RunningStatus.Failed,"失败" }, }; - public static int DEFAULT_DELAY = 200; - public static int DEFAULT_TIMEOUT = 5000; + public long CommandID { get; set; } public string Name { get; set; } @@ -63,7 +52,7 @@ public RunningStatus Status set { _Status = value; RaisePropertyChanged(); - StatusText = RunningStatusToString[value]; + StatusText = RUN_STATUS_TABLE[value]; } } private string _StatusText = "就绪"; @@ -133,7 +122,16 @@ public static class SqliteTable { public static Dictionary Table = new Dictionary() { - {"advanced_send","create table if not exists advanced_send( ProjectID INTEGER PRIMARY KEY autoincrement, ProjectName VARCHAR(200), Commands TEXT, CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) );" } + { + "advanced_send", + "create table if not exists advanced_send( " + + "ProjectID INTEGER PRIMARY KEY autoincrement, " + + "ProjectName VARCHAR(200), " + + "Commands TEXT, " + + "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) " + + ");" + } }; } diff --git a/SuperCom/Entity/ComSettings.cs b/SuperCom/Entity/ComSettings.cs index d316332..2b6d136 100644 --- a/SuperCom/Entity/ComSettings.cs +++ b/SuperCom/Entity/ComSettings.cs @@ -58,12 +58,26 @@ public static class SqliteTable { public static Dictionary Table = new Dictionary() { - {"com_settings","create table if not exists com_settings( Id INTEGER PRIMARY KEY autoincrement, PortName VARCHAR(50), Connected INT DEFAULT 0, AddTimeStamp INT DEFAULT 0, AddNewLineWhenWrite INT DEFAULT 0, PortSetting VARCHAR(1000), WriteData VARCHAR(5000), CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), unique(PortName) );" } + { + "com_settings", + "create table if not exists com_settings( " + + "Id INTEGER PRIMARY KEY autoincrement, " + + "PortName VARCHAR(50), " + + "Connected INT DEFAULT 0, " + + "AddTimeStamp INT DEFAULT 0, " + + "AddNewLineWhenWrite INT DEFAULT 0, " + + "PortSetting VARCHAR(1000), " + + "WriteData VARCHAR(5000), " + + "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "unique(PortName) " + + ");" + } }; } - public static string[] SqlCommands = { + public static string[] SQL_EXTRA_CMDS = { "ALTER TABLE com_settings ADD COLUMN EnabledFilter INT DEFAULT 0;", "ALTER TABLE com_settings ADD COLUMN EnabledMonitor INT DEFAULT 0;", "ALTER TABLE com_settings ADD COLUMN SendHex INT DEFAULT 0;", @@ -82,7 +96,7 @@ public static void InitSqlite() } // 新增列 - foreach (string sql in SqlCommands) + foreach (string sql in SQL_EXTRA_CMDS) { try { diff --git a/SuperCom/Entity/HighLightRule.cs b/SuperCom/Entity/HighLightRule.cs index 1243b52..4c56dc4 100644 --- a/SuperCom/Entity/HighLightRule.cs +++ b/SuperCom/Entity/HighLightRule.cs @@ -1,34 +1,20 @@ using SuperCom.Config; +using SuperUtils.Common; using SuperUtils.Framework.ORM.Attributes; using SuperUtils.Framework.ORM.Mapper; +using SuperUtils.IO; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ICSharpCode.AvalonEdit; -using SuperUtils.Time; -using System; -using System.ComponentModel; using System.IO; -using System.Runtime.CompilerServices; using System.Text; -using System.Windows.Controls; -using System.Windows.Threading; -using SuperUtils.IO; -using SuperUtils.Common; -using SuperUtils.WPF.VieModel; namespace SuperCom.Entity { [Table(tableName: "highlight_rule")] public class HighLightRule { - public static List AllRules = new List(); - public static List AllName = new List(); - - - + public static List AllRules { get; set; } + public static List AllName { get; set; } [TableId(IdType.AUTO)] public long RuleID { get; set; } @@ -55,6 +41,19 @@ public HighLightRule() } + public HighLightRule(int RuleID, string RuleName, string FileName) + { + this.RuleID = RuleID; + this.RuleName = RuleName; + this.FileName = FileName; + } + + static HighLightRule() + { + AllRules = new List(); + AllName = new List(); + } + public void SetFileName() { FileName = $"{RuleID}_{RuleName.ToProperFileName()}.xshd"; @@ -124,12 +123,6 @@ private string GetRuleString(RuleSet rule) } - public HighLightRule(int RuleID, string RuleName, string FileName) - { - this.RuleID = RuleID; - this.RuleName = RuleName; - this.FileName = FileName; - } public static class SqliteTable { @@ -137,7 +130,16 @@ public static class SqliteTable { { "highlight_rule", - "create table if not exists highlight_rule( RuleID INTEGER PRIMARY KEY autoincrement, RuleName VARCHAR(200), FileName TEXT, RuleSetString TEXT,PreviewText TEXT,Extra TEXT, CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) );" } + "create table if not exists highlight_rule( " + + "RuleID INTEGER PRIMARY KEY autoincrement, " + + "RuleName VARCHAR(200), " + + "FileName TEXT, " + + "RuleSetString TEXT," + + "PreviewText TEXT," + + "Extra TEXT, " + + "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')) " + + ");" } }; } diff --git a/SuperCom/Entity/PortSetting.cs b/SuperCom/Entity/PortSetting.cs index 6e8dee3..fb3c410 100644 --- a/SuperCom/Entity/PortSetting.cs +++ b/SuperCom/Entity/PortSetting.cs @@ -1,19 +1,13 @@  using SuperCom.Config; -using SuperControls.Style; using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO.Ports; using System.Linq; -using System.Runtime.CompilerServices; using System.Text; -using System.Threading.Tasks; namespace SuperCom.Entity { - - public enum FlowControls { None, @@ -24,6 +18,31 @@ public enum FlowControls public class PortSetting { + public const int CLOSE_TIME_OUT = 5; + public const double DEFAULT_FONTSIZE = 15; + public const int DEFAULT_WRITE_TIME_OUT = 1000; + public const int DEFAULT_READ_TIME_OUT = 2000; + public const int MIN_TIME_OUT = 0; + public const int MAX_TIME_OUT = 60 * 60 * 1000; + public const bool DEFAULT_DTR = false; + public const bool DEFAULT_RTS = false; + public const bool DEFAULT_DISCARDNULL = false; + + public const double MAX_FONTSIZE = 25; + public const double MIN_FONTSIZE = 5; + + + public const int DEFAULT_BAUDRATE = 115200; + public const int DEFAULT_DATABITS = 8; + public const string DEFAULT_ENCODING_STRING = "UTF8"; + public static Encoding DEFAULT_ENCODING = System.Text.Encoding.UTF8; + + public static StopBits DEFAULT_STOPBITS = StopBits.One; + public static Parity DEFAULT_PARITY = Parity.None; + public static FlowControls DEFAULT_FLOWCONTROLS = FlowControls.None; + public static Handshake DEFAULT_HANDSHAKE = Handshake.None; + public static List DEFAULT_HANDSHAKES = Enum.GetNames(typeof(System.IO.Ports.Handshake)).ToList(); + public static List DEFAULT_BAUDRATES = new List() { 9600,19200,115200,1500000 @@ -34,6 +53,11 @@ public class PortSetting 5,6,7,8 }; + + /// + /// 更多编码支持参考: + /// microsoft + /// public static List DEFAULT_ENCODINGS = new List() { "UTF8","US-ASCII","GB2312","ISO-8859-1" @@ -49,14 +73,8 @@ public class PortSetting "One","Two","OnePointFive" }; - public static List DEFAULT_HANDSHAKES = Enum.GetNames(typeof(System.IO.Ports.Handshake)).ToList(); - public static int DEFAULT_BAUDRATE = 115200; - public static int DEFAULT_DATABITS = 8; - public static StopBits DEFAULT_STOPBITS = StopBits.One; - public static Parity DEFAULT_PARITY = Parity.None; - public static FlowControls DEFAULT_FLOWCONTROLS = FlowControls.None; - public static string DEFAULT_ENCODING = "UTF8"; + public int BaudRate { get; set; } public int DataBits { get; set; } @@ -73,7 +91,7 @@ public static List GetAllBaudRates() List list = new List(); if (ConfigManager.Main.UseDefaultBaudRate) { - foreach (var item in PortSetting.DEFAULT_BAUDRATES) + foreach (var item in DEFAULT_BAUDRATES) { list.Add(item.ToString()); } @@ -93,7 +111,7 @@ public static PortSetting GetDefaultSetting() portSetting.StopBits = DEFAULT_STOPBITS; portSetting.Parity = DEFAULT_PARITY; portSetting.FlowControls = DEFAULT_FLOWCONTROLS; - portSetting.Encoding = DEFAULT_ENCODING; + portSetting.Encoding = DEFAULT_ENCODING_STRING; return portSetting; } } diff --git a/SuperCom/Entity/PortTabItem.cs b/SuperCom/Entity/PortTabItem.cs index c633f2e..13cb557 100644 --- a/SuperCom/Entity/PortTabItem.cs +++ b/SuperCom/Entity/PortTabItem.cs @@ -1,11 +1,8 @@  using ICSharpCode.AvalonEdit; -using ICSharpCode.AvalonEdit.Highlighting; -using Newtonsoft.Json.Linq; using SuperCom.Config; using SuperCom.Config.WindowConfig; using SuperUtils.Common; -using SuperUtils.Framework.ORM.Mapper; using SuperUtils.IO; using SuperUtils.Time; using SuperUtils.WPF.VieModel; @@ -13,28 +10,36 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Data; using System.IO; using System.IO.Ports; using System.Linq; -using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Threading; using static SuperCom.Entity.HighLightRule; namespace SuperCom.Entity { public class PortTabItem : ViewModelBase { + private const int MAX_READ_LENGTH = 10240; + private const int READ_INTERVAL = 50; + private const int NOT_RECV_HEX_SLEEP_INTERVAL = 2000; + + private AutoResetEvent ResetEvent { get; set; } + + public TextEditor TextEditor { get; set; } + + public double CurrentCharSize { get; set; } + public bool RunningCommands { get; set; } + public Queue ResultChecks { get; set; } + public string SaveFileName { get; set; } + public int FragCount { get; set; } private string _Name; public string Name @@ -53,26 +58,6 @@ public bool Connected } } - - private EventWaitHandle WaitHandle { get; set; } - - - - - - private bool _TaskRunning; - private bool TaskRunning - { - get { return _TaskRunning; } - set - { - _TaskRunning = value; - RaisePropertyChanged(); - App.Logger?.Debug($"TaskRunning = {value}"); - } - } - - private bool _Selected; public bool Selected { @@ -87,6 +72,8 @@ public string Data get { return _Data; } set { _Data = value; RaisePropertyChanged(); } } + + private PortSetting _Setting; public PortSetting Setting { @@ -97,18 +84,14 @@ public PortSetting Setting RaisePropertyChanged(); } } - private CustomSerialPort _SerialPort; - public CustomSerialPort SerialPort + + private SerialPortEx _SerialPort; + public SerialPortEx SerialPort { get { return _SerialPort; } set { _SerialPort = value; RaisePropertyChanged(); } } - private bool _ScrollToEnd; - public bool ScrollToEnd - { - get { return _ScrollToEnd; } - set { _ScrollToEnd = value; RaisePropertyChanged(); } - } + private bool _AddNewLineWhenWrite = true; public bool AddNewLineWhenWrite { @@ -120,6 +103,7 @@ public bool AddNewLineWhenWrite RefreshSendHexValue(WriteData); } } + private bool _SendHex; public bool SendHex { @@ -132,6 +116,7 @@ public bool SendHex RefreshSendHexValue(WriteData); } } + private bool _RecvShowHex; public bool RecvShowHex { @@ -161,7 +146,7 @@ public string WriteData } } - public TextEditor TextEditor { get; set; } + private bool _AddTimeStamp = true; public bool AddTimeStamp @@ -169,6 +154,8 @@ public bool AddTimeStamp get { return _AddTimeStamp; } set { _AddTimeStamp = value; RaisePropertyChanged(); } } + + private bool _EnabledMonitor = true; public bool EnabledMonitor { @@ -188,8 +175,6 @@ public bool EnabledMonitor } - public double CurrentCharSize { get; set; } - private long _RX = 0L; public long RX { @@ -203,14 +188,18 @@ public long TX set { _TX = value; RaisePropertyChanged(); } } - // 备注 private string _Remark = ""; + + /// + /// 备注 + /// public string Remark { get { return _Remark; } set { _Remark = value; RaisePropertyChanged(); } } + private bool _EnabledFilter; public bool EnabledFilter { @@ -257,6 +246,7 @@ public bool Pinned get { return _Pinned; } set { _Pinned = value; RaisePropertyChanged(); } } + private bool _FixedText; public bool FixedText { @@ -282,29 +272,19 @@ public void TextBox_TextChanged(object sender, EventArgs e) textEditor?.ScrollToEnd(); } - public bool RunningCommands { get; set; } - - public Queue ResultChecks { get; set; } public void ClearData() { FirstSaveData = true; } - - public string SaveFileName { get; set; } - - - void ProcessLine(CustomSerialPort serialPort, string line) + void ProcessLine(SerialPortEx serialPort, string line) { if (string.IsNullOrEmpty(line)) return; string portName = serialPort.PortName; - //if (!line.EndsWith("\r\n")) - // line += "\r\n"; try { - // 异步存储 App.Current.Dispatcher.Invoke(() => { SaveData(line); @@ -313,7 +293,6 @@ void ProcessLine(CustomSerialPort serialPort, string line) catch (Exception ex) { App.Logger.Error(ex.Message); - } } @@ -322,7 +301,7 @@ void ProcessLine(CustomSerialPort serialPort, string line) /// 参考:stackoverflow /// /// - private void HandleStrReceived(CustomSerialPort serialPort) + private void HandleStrReceived(SerialPortEx serialPort) { string line = ""; try @@ -338,18 +317,13 @@ private void HandleStrReceived(CustomSerialPort serialPort) private void OnRevievedStr(object sender, SerialDataReceivedEventArgs e) { - CustomSerialPort serialPort = sender as CustomSerialPort; + SerialPortEx serialPort = sender as SerialPortEx; HandleStrReceived(serialPort); } #region "HEX 收数据处理" - private AutoResetEvent ResetEvent { get; set; } - - private const int MAX_READ_LENGTH = 10240; - private const int READ_INTERVAL = 50; - private void OnRevievedHEX(object sender, SerialDataReceivedEventArgs e) { ResetEvent.Set(); @@ -364,7 +338,7 @@ private void OnRevievedHEX(object sender, SerialDataReceivedEventArgs e) /// 参考2:microsoft /// 参考3:deal-with-c-sharp-serialport-read /// - public void ReadTask() + public void ReadHexTask() { ResetEvent.Reset(); List allData = new List(); @@ -421,13 +395,10 @@ public void SetDataReceivedType() SerialPort.DataReceived -= OnRevievedStr; SerialPort.DataReceived -= OnRevievedHEX; SerialPort.DataReceived += OnRevievedHEX; - //if (Connected) - // StartHexRecvTask(); } else { // STR 模式 - TaskRunning = false; SerialPort.DataReceived -= OnRevievedHEX; SerialPort.DataReceived -= OnRevievedStr; SerialPort.DataReceived += OnRevievedStr; @@ -562,9 +533,6 @@ public string GetSaveFileName() return Path.Combine(logDir, name + ".log"); } - public int FragCount { get; set; } - - private StringBuilder Buffer = new StringBuilder(); public void FilterLine(string value) { @@ -592,7 +560,7 @@ public void FilterLine(string value) - private ConcurrentQueue FilterQueue = new ConcurrentQueue(); + private readonly ConcurrentQueue FilterQueue = new ConcurrentQueue(); private bool StopFilter = false; private bool FilterRunning = false; @@ -902,7 +870,10 @@ public PortTabItem(string name, bool connected) { while (true) { - ReadTask(); + if (RecvShowHex) + ReadHexTask(); + else + Thread.Sleep(NOT_RECV_HEX_SLEEP_INTERVAL); } }); } diff --git a/SuperCom/Entity/CustomSerialPort.cs b/SuperCom/Entity/SerialPortEx.cs similarity index 79% rename from SuperCom/Entity/CustomSerialPort.cs rename to SuperCom/Entity/SerialPortEx.cs index 8c4f4f9..b866c11 100644 --- a/SuperCom/Entity/CustomSerialPort.cs +++ b/SuperCom/Entity/SerialPortEx.cs @@ -14,12 +14,17 @@ namespace SuperCom.Entity { - public class CustomSerialPort : SerialPort, INotifyPropertyChanged + public class SerialPortEx : SerialPort, INotifyPropertyChanged { + private const Parity defaultParity = Parity.None; + private static readonly string DEFAULT_STOPBITS = StopBits.One.ToString(); + private static readonly string DEFAULT_PARITY = Parity.None.ToString(); + + private const Handshake defaultHandshake = Handshake.None; + + - public const int CLOSE_TIME_OUT = 5; - public static Encoding DEFAULT_ENCODING = System.Text.Encoding.UTF8; public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged([CallerMemberName] string name = null) @@ -27,13 +32,6 @@ protected void RaisePropertyChanged([CallerMemberName] string name = null) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } - private const int DEFAULT_WRITE_TIME_OUT = 1000; - private const int DEFAULT_READ_TIME_OUT = 2000; - private const int MIN_TIME_OUT = 0; - private const int MAX_TIME_OUT = 60 * 60 * 1000; - - public bool HandledDataReceived { get; set; } - public PortSetting _Setting = PortSetting.GetDefaultSetting(); public PortSetting Setting @@ -41,21 +39,32 @@ public PortSetting Setting get { return _Setting; } set { _Setting = value; } } - public CustomSerialPort(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) - : base(portName, baudRate, parity, dataBits, stopBits) + + + public SerialPortEx() { + } - public static double DEFAULT_FONTSIZE = 15; + public SerialPortEx(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) + : base(portName, baudRate, parity, dataBits, stopBits) + { + Init(); + } - public CustomSerialPort(string portName) + public SerialPortEx(string portName) : this() { this.PortName = portName; RefreshSetting(); } + public void Init() + { + Remark = ""; + } + /// - /// 仅可以有 COM 加 数字 + /// 仅有 COM[NUMBER] /// /// public static string[] GetAllPorts() @@ -64,7 +73,7 @@ public static string[] GetAllPorts() string[] ports = GetPortNames(); foreach (var item in ports) { - if (int.TryParse(item.ToUpper().Replace("COM", ""), out int portNumber)) + if (int.TryParse(item.ToUpper().Replace("COM", ""), out _)) result.Add(item); } return result.ToArray(); @@ -102,9 +111,9 @@ public static string[] GetUsbSerDevices() return ports.ToArray(); } - public string Remark = ""; - public bool Pinned = false; - public bool Hide = false; + public string Remark { get; set; } + public bool Pinned { get; set; } + public bool Hide { get; set; } public void SaveRemark(string remark) { @@ -125,8 +134,6 @@ public void SaveHide(bool hide) public void SaveProperties() { - //this.BaudRate = Setting.BaudRate; - //this.DataBits = Setting.DataBits; this.Encoding = GetEncoding(); this.StopBits = GetStopBits(); this.Parity = GetParity(); @@ -149,14 +156,25 @@ public void RefreshSetting() public string PortSettingToJson() { - Dictionary dic = new Dictionary(); - dic.Add("BaudRate", this.BaudRate); - dic.Add("DataBits", this.DataBits); - dic.Add("Encoding", this.Encoding.HeaderName); - dic.Add("StopBits", this.StopBitsString); - dic.Add("Parity", this.ParityString); - dic.Add("DTR", this.DtrEnable); - dic.Add("Handshake", this.Handshake); + Dictionary dic = + new Dictionary + { + { "BaudRate", this.BaudRate }, + { "DataBits", this.DataBits }, + { "Encoding", this.Encoding.HeaderName }, + { "StopBits", this.StopBitsString }, + { "Parity", this.ParityString }, + { "DTR", this.DtrEnable }, + { "Handshake", this.Handshake }, + { "ReadTimeout", this.ReadTimeoutValue }, + { "WriteTimeout", this.WriteTimeoutValue }, + { "DiscardNull", this.DiscardNull }, + { "Remark", this.Remark }, + { "Pinned", this.Pinned }, + { "Hide", this.Hide }, + { "TextFontSize", this.TextFontSize }, + { "HighLightIndex", this.HighLightIndex }, + }; if (this.Handshake == Handshake.RequestToSend || this.Handshake == Handshake.RequestToSendXOnXOff) { // Handshake 设置为 RequestToSend 或 RequestToSendXOnXOff,则无法访问 RtsEnable @@ -166,18 +184,6 @@ public string PortSettingToJson() dic.Add("RTS", this.RtsEnable); } //dic.Add("BreakState", this.BreakState); - dic.Add("ReadTimeout", this.ReadTimeoutValue); - dic.Add("WriteTimeout", this.WriteTimeoutValue); - - dic.Add("DiscardNull", this.DiscardNull); - - - - dic.Add("Remark", this.Remark); - dic.Add("Pinned", this.Pinned); - dic.Add("Hide", this.Hide); - dic.Add("TextFontSize", this.TextFontSize); - dic.Add("HighLightIndex", this.HighLightIndex); return JsonUtils.TrySerializeObject(dic); } @@ -196,7 +202,7 @@ public void SetPortSettingByJson(string json) if (dict.ContainsKey("TextFontSize")) { - double fontSize = CustomSerialPort.DEFAULT_FONTSIZE; + double fontSize = PortSetting.DEFAULT_FONTSIZE; double.TryParse(dict["TextFontSize"].ToString(), out fontSize); this.TextFontSize = fontSize; } @@ -268,7 +274,7 @@ public static bool GetPinned(string json) if (dict.ContainsKey("Pinned")) status = dict["Pinned"].ToString(); } - return status.ToLower().Equals("true") ? true : false; + return status.ToLower().Equals("true"); } @@ -299,7 +305,7 @@ public Parity GetParity() return result; } - private string _PortEncoding = "UTF8"; + private string _PortEncoding = PortSetting.DEFAULT_ENCODING_STRING; public string PortEncoding { get { return _PortEncoding; } @@ -310,7 +316,7 @@ public string PortEncoding RefreshSetting(); } } - private string _StopBitsString = "One"; + private string _StopBitsString = DEFAULT_STOPBITS; public string StopBitsString { get { return _StopBitsString; } @@ -321,7 +327,7 @@ public string StopBitsString RefreshSetting(); } } - private string _ParityString = "One"; + private string _ParityString = DEFAULT_PARITY; public string ParityString { get { return _ParityString; } @@ -332,7 +338,7 @@ public string ParityString RefreshSetting(); } } - private double _TextFontSize = DEFAULT_FONTSIZE; + private double _TextFontSize = PortSetting.DEFAULT_FONTSIZE; public double TextFontSize { get { return _TextFontSize; } @@ -350,7 +356,7 @@ public long FilterSelectedIndex get { return _FilterSelectedIndex; } set { _FilterSelectedIndex = value; RaisePropertyChanged(); } } - private long _ReadTimeoutValue = DEFAULT_READ_TIME_OUT; + private long _ReadTimeoutValue = PortSetting.DEFAULT_READ_TIME_OUT; public long ReadTimeoutValue { get { return _ReadTimeoutValue; } @@ -358,12 +364,12 @@ public long ReadTimeoutValue { _ReadTimeoutValue = value; RaisePropertyChanged(); - if (value >= MIN_TIME_OUT && value <= MAX_TIME_OUT) + if (value >= PortSetting.MIN_TIME_OUT && value <= PortSetting.MAX_TIME_OUT) this.ReadTimeout = (int)value; } } - private long _WriteTimeoutValue = DEFAULT_WRITE_TIME_OUT; + private long _WriteTimeoutValue = PortSetting.DEFAULT_WRITE_TIME_OUT; public long WriteTimeoutValue { get { return _WriteTimeoutValue; } @@ -371,7 +377,7 @@ public long WriteTimeoutValue { _WriteTimeoutValue = value; RaisePropertyChanged(); - if (value >= MIN_TIME_OUT && value <= MAX_TIME_OUT) + if (value >= PortSetting.MIN_TIME_OUT && value <= PortSetting.MAX_TIME_OUT) this.WriteTimeout = (int)value; } } @@ -385,7 +391,7 @@ public void PrintSetting() public override bool Equals(object obj) { - if (obj != null && obj is CustomSerialPort serialPort) + if (obj != null && obj is SerialPortEx serialPort) { return serialPort.PortName.Equals(PortName); } @@ -399,15 +405,15 @@ public override int GetHashCode() public void RestoreDefault() { - this.DtrEnable = false; - this.RtsEnable = false; - this.DiscardNull = false; - this.ReadTimeout = DEFAULT_READ_TIME_OUT; - this.WriteTimeout = DEFAULT_WRITE_TIME_OUT; - this.Handshake = Handshake.None; - this.StopBits = StopBits.One; - this.Parity = Parity.None; - this.Encoding = DEFAULT_ENCODING; + this.DtrEnable = PortSetting.DEFAULT_DTR; + this.RtsEnable = PortSetting.DEFAULT_RTS; + this.DiscardNull = PortSetting.DEFAULT_DISCARDNULL; + this.ReadTimeout = PortSetting.DEFAULT_READ_TIME_OUT; + this.WriteTimeout = PortSetting.DEFAULT_WRITE_TIME_OUT; + this.Handshake = PortSetting.DEFAULT_HANDSHAKE; + this.StopBits = PortSetting.DEFAULT_STOPBITS; + this.Parity = PortSetting.DEFAULT_PARITY; + this.Encoding = PortSetting.DEFAULT_ENCODING; } } } diff --git a/SuperCom/Entity/ShortCutBinding.cs b/SuperCom/Entity/ShortCutBinding.cs index eaf0bfa..81fcdf8 100644 --- a/SuperCom/Entity/ShortCutBinding.cs +++ b/SuperCom/Entity/ShortCutBinding.cs @@ -112,15 +112,15 @@ public static class SqliteTable { { "short_cut", - "create table if not exists short_cut( " + - "_ID INTEGER PRIMARY KEY autoincrement, " + - "KeyID INTEGER, " + - "KeyName VARCHAR(200), " + - "Keys TEXT, " + - "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + - "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime'))," + - "unique(KeyID));" + "_ID INTEGER PRIMARY KEY autoincrement, " + + "KeyID INTEGER, " + + "KeyName VARCHAR(200), " + + "Keys TEXT, " + + "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime'))," + + "unique(KeyID)" + + ");" } }; diff --git a/SuperCom/Entity/SideComPort.cs b/SuperCom/Entity/SideComPort.cs index dd50a71..751ca7f 100644 --- a/SuperCom/Entity/SideComPort.cs +++ b/SuperCom/Entity/SideComPort.cs @@ -1,12 +1,5 @@  using SuperUtils.WPF.VieModel; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; namespace SuperCom.Entity { diff --git a/SuperCom/Entity/VarMonitor.cs b/SuperCom/Entity/VarMonitor.cs index 9d1bc88..ab28826 100644 --- a/SuperCom/Entity/VarMonitor.cs +++ b/SuperCom/Entity/VarMonitor.cs @@ -1,13 +1,9 @@ using SuperCom.Config; using SuperUtils.Framework.ORM.Attributes; using SuperUtils.Framework.ORM.Mapper; -using System; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; namespace SuperCom.Entity { @@ -109,18 +105,19 @@ public static class SqliteTable "var_monitor", "BEGIN;" + - "create table if not exists var_monitor( " + - "MonitorID INTEGER PRIMARY KEY autoincrement, " + - "PortName VARCHAR(20), " + - "Enabled INT DEFAULT 1, " + - "SortOrder INT DEFAULT 0, " + - "VarType INT DEFAULT 0, " + - "Name VARCHAR(50), " + - "RegexPattern VARCHAR(200), " + - "DataFileName VARCHAR(200), " + - "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + - "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + - "unique(PortName,Name));" + + "create table if not exists var_monitor( " + + "MonitorID INTEGER PRIMARY KEY autoincrement, " + + "PortName VARCHAR(20), " + + "Enabled INT DEFAULT 1, " + + "SortOrder INT DEFAULT 0, " + + "VarType INT DEFAULT 0, " + + "Name VARCHAR(50), " + + "RegexPattern VARCHAR(200), " + + "DataFileName VARCHAR(200), " + + "CreateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "UpdateDate VARCHAR(30) DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW', 'localtime')), " + + "unique(PortName,Name)" + + ");" + "CREATE INDEX var_monitor_idx_PortName ON var_monitor (PortName);" + "CREATE INDEX var_monitor_idx_PortName_Name ON var_monitor (PortName,Name);" + "COMMIT;" diff --git a/SuperCom/Entity/VirtualPort.cs b/SuperCom/Entity/VirtualPort.cs index 54e4c57..5bd6ddf 100644 --- a/SuperCom/Entity/VirtualPort.cs +++ b/SuperCom/Entity/VirtualPort.cs @@ -15,13 +15,13 @@ namespace SuperCom.Entity { public static class VirtualPortManager { - private static string AppPath = ""; - public const string COM_0_COM_PROGRAM_NAME = "Null-modem emulator (com0com)"; public const string COM_0_COM_PROGRAM_EXE_NAME = "setupc.exe"; public const int CMD_RUN_TIME_OUT = 5000; - private static string AppDir; + private static string AppDir { get; set; } + private static string AppPath { get; set; } + public static void Init(string appPath) { AppPath = appPath; diff --git a/SuperCom/Lang/LangManager.cs b/SuperCom/Lang/LangManager.cs index c4f74c0..8da3865 100644 --- a/SuperCom/Lang/LangManager.cs +++ b/SuperCom/Lang/LangManager.cs @@ -13,7 +13,7 @@ public static bool SetLang(string lang) { if (!SuperControls.Style.LangManager.SupportLanguages.Contains(lang)) { - Console.WriteLine("不支持的语言:" + lang); + App.Logger.Error($"Language not support: {lang}"); return false; } diff --git a/SuperCom/Logger/Logger.cs b/SuperCom/Logger/Logger.cs index 5f3c33b..6e97b30 100644 --- a/SuperCom/Logger/Logger.cs +++ b/SuperCom/Logger/Logger.cs @@ -9,7 +9,9 @@ namespace SuperCom.Log public class Logger : AbstractLogger { public static string LOG_DIR = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "app_logs"); - private Logger() { } + private Logger() + { + } public static Logger Instance { get; } diff --git a/SuperCom/MainWindow.xaml.cs b/SuperCom/MainWindow.xaml.cs index e16b113..3e8fbed 100644 --- a/SuperCom/MainWindow.xaml.cs +++ b/SuperCom/MainWindow.xaml.cs @@ -141,8 +141,8 @@ public void ReadConfig() ComSettings comSettings = vieModel.ComSettingList.Where(arg => arg.PortName.Equals(item.Name)).FirstOrDefault(); if (comSettings != null && !string.IsNullOrEmpty(comSettings.PortSetting)) { - item.Remark = CustomSerialPort.GetRemark(comSettings.PortSetting); - item.Hide = CustomSerialPort.GetHide(comSettings.PortSetting); + item.Remark = SerialPortEx.GetRemark(comSettings.PortSetting); + item.Hide = SerialPortEx.GetHide(comSettings.PortSetting); } } //textWrapMenuItem.IsChecked = vieModel.AutoTextWrap; @@ -435,8 +435,8 @@ private void RetainSidePortValue(List sideComPorts) ComSettings comSettings = vieModel.ComSettingList.FirstOrDefault(arg => portName.Equals(arg.PortName)); if (comSettings != null && !string.IsNullOrEmpty(comSettings.PortSetting)) { - vieModel.SideComPorts[i].Remark = CustomSerialPort.GetRemark(comSettings.PortSetting); - vieModel.SideComPorts[i].Hide = CustomSerialPort.GetHide(comSettings.PortSetting); + vieModel.SideComPorts[i].Remark = SerialPortEx.GetRemark(comSettings.PortSetting); + vieModel.SideComPorts[i].Hide = SerialPortEx.GetHide(comSettings.PortSetting); } } } @@ -510,7 +510,7 @@ await Task.Run(() => { try { - CustomSerialPort serialPort = portTabItem.SerialPort; + SerialPortEx serialPort = portTabItem.SerialPort; if (!serialPort.IsOpen) { //serialPort.WriteTimeout = CustomSerialPort.WRITE_TIME_OUT; @@ -604,7 +604,7 @@ private async Task ClosePort(string portName) PortTabItem portTabItem = vieModel.PortTabItems.FirstOrDefault(arg => arg.Name.Equals(portName)); if (portTabItem == null) return false; - CustomSerialPort serialPort = portTabItem.SerialPort; + SerialPortEx serialPort = portTabItem.SerialPort; if (serialPort != null) { bool success = await AsynClosePort(serialPort); @@ -626,7 +626,7 @@ private async Task ClosePort(string portName) } } - public async Task AsynClosePort(CustomSerialPort serialPort) + public async Task AsynClosePort(SerialPortEx serialPort) { try { @@ -635,7 +635,7 @@ public async Task AsynClosePort(CustomSerialPort serialPort) serialPort.Close(); serialPort.Dispose(); return true; - }).TimeoutAfter(TimeSpan.FromSeconds(CustomSerialPort.CLOSE_TIME_OUT)); + }).TimeoutAfter(TimeSpan.FromSeconds(PortSetting.CLOSE_TIME_OUT)); } catch (TimeoutException ex) { @@ -648,9 +648,6 @@ public async Task AsynClosePort(CustomSerialPort serialPort) return false; } - - private Queue recievedData = new Queue(); - private bool SetPortConnectStatus(string portName, bool status) { try @@ -715,10 +712,10 @@ private async Task OpenPortTabItem(string portName, bool connect) PortTabItem portTabItem = new PortTabItem(portName, connect); portTabItem.Setting = PortSetting.GetDefaultSetting(); - CustomSerialPort serialPort; + SerialPortEx serialPort; if (portTabItem.SerialPort == null) { - serialPort = new CustomSerialPort(portName); + serialPort = new SerialPortEx(portName); portTabItem.SerialPort = serialPort; } @@ -777,16 +774,17 @@ private void ShowAbout(object sender, RoutedEventArgs e) Dialog_About about = new Dialog_About(); string local = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); local = local.Substring(0, local.Length - ".0.0".Length); - about.AppName = "SuperCom"; - about.AppSubName = "超级串口工具"; + about.AppName = ConfigManager.APP_NAME; + about.AppSubName = ConfigManager.APP_SUB_NAME; about.Version = local; about.ReleaseDate = ConfigManager.RELEASE_DATE; - about.Author = "Chao"; - about.License = "GPL-3.0"; - about.GithubUrl = "https://github.com/SuperStudio/SuperCom"; - about.WebUrl = "https://github.com/SuperStudio/SuperCom"; - about.JoinGroupUrl = "https://github.com/SuperStudio/SuperCom"; - about.Image = SuperUtils.Media.ImageHelper.ImageFromUri("pack://application:,,,/SuperCom;Component/Resources/Ico/ICON_256.png"); + about.Author = ConfigManager.AUTHOR; + about.License = ConfigManager.LICENSE; + about.GithubUrl = UrlManager.GITHUB_URL; + about.WebUrl = UrlManager.GITHUB_URL; + about.JoinGroupUrl = UrlManager.GITHUB_URL; + about.Image = SuperUtils.Media.ImageHelper + .ImageFromUri("pack://application:,,,/SuperCom;Component/Resources/Ico/ICON_256.png"); about.ShowDialog(); } @@ -797,8 +795,7 @@ private void OpenContextMenu(object sender, RoutedEventArgs e) return; button.ContextMenu.IsOpen = true; } - private static double MAX_FONTSIZE = 25; - private static double MIN_FONTSIZE = 5; + private void Border_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { @@ -815,8 +812,8 @@ private void Border_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { fontSize--; } - if (fontSize > MAX_FONTSIZE) fontSize = MAX_FONTSIZE; - if (fontSize < MIN_FONTSIZE) fontSize = MIN_FONTSIZE; + if (fontSize > PortSetting.MAX_FONTSIZE) fontSize = PortSetting.MAX_FONTSIZE; + if (fontSize < PortSetting.MIN_FONTSIZE) fontSize = PortSetting.MIN_FONTSIZE; textEditor.FontSize = fontSize; e.Handled = true; @@ -824,23 +821,6 @@ private void Border_PreviewMouseWheel(object sender, MouseWheelEventArgs e) } - private void SetTextBoxScroll(object sender, RoutedEventArgs e) - { - //ToggleButton toggleButton = sender as ToggleButton; - //bool fix = (bool)toggleButton.IsChecked; - //PortTabItem portTabItem = GetPortItem(sender as FrameworkElement); - //if (portTabItem != null && portTabItem.TextEditor != null) - //{ - // if (fix) - // portTabItem.TextEditor.TextChanged -= TextBox_TextChanged; - // else - // { - // portTabItem.TextEditor.TextChanged -= TextBox_TextChanged; - // portTabItem.TextEditor.TextChanged += TextBox_TextChanged; - // } - //} - } - private TextEditor FindTextBox(Grid rootGrid) { if (rootGrid == null) return null; @@ -906,11 +886,6 @@ private void ClearData(object sender, RoutedEventArgs e) } } - - - - - private void OpenPath(object sender, RoutedEventArgs e) { PortTabItem portTabItem = GetPortItem(sender as FrameworkElement); @@ -980,9 +955,6 @@ private void SendCommand(object sender, RoutedEventArgs e) return (toggleButton, firstBorder.Child as TextEditor); } - - - public void SendCommand(string portName) { SideComPort serialComPort = vieModel.SideComPorts.Where(arg => arg.Name.Equals(portName)).FirstOrDefault(); @@ -1066,16 +1038,6 @@ public bool SendCommand(SerialPort port, PortTabItem portTabItem, string value, } } - private void OnMaxCurrentWindow(object sender, MouseButtonEventArgs e) - { - // //if (e.ClickCount > 1) - // //{ - // // MaxWindow(sender, new RoutedEventArgs()); - // //} - // base.DragMoveWindow(sender, e); - } - - private string GetPortName(FrameworkElement element) { if (element == null) return null; @@ -1107,20 +1069,6 @@ private async void SaveToNewFile(object sender, RoutedEventArgs e) (sender as FrameworkElement).IsEnabled = true; } - - - private string GetPortName(ComboBox comboBox) - { - if (comboBox != null && comboBox.Tag != null) - { - return comboBox.Tag.ToString(); - } - return null; - } - - - - private void ShowSettingsPopup(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) @@ -1134,11 +1082,6 @@ private void ShowSettingsPopup(object sender, MouseButtonEventArgs e) e.Handled = true; } - private void ShowSplitPopup(object sender, RoutedEventArgs e) - { - //panelSplitPopup.IsOpen = true; - } - private void ShowContextMenu(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) @@ -1247,7 +1190,6 @@ private void mainWindow_Closing(object sender, System.ComponentModel.CancelEvent { App.Logger.Error(ex.Message); } - } @@ -1465,7 +1407,7 @@ private void RestorePortSetting(object sender, RoutedEventArgs e) return; if (vieModel.PortTabItems != null && vieModel.PortTabItems.FirstOrDefault(arg => arg.Name.Equals(name)) is PortTabItem tabItem && - tabItem.SerialPort is CustomSerialPort port) + tabItem.SerialPort is SerialPortEx port) { port.RestoreDefault(); port.PrintSetting(); @@ -1513,11 +1455,6 @@ private async void mainWindow_ContentRendered(object sender, EventArgs e) ReadXshdList();// 自定义语法高亮 LoadDonateConfig(); await BackupData(); // 备份文件 - //new Window_AdvancedSend().Show(); - //Window_Setting setting = new Window_Setting(); - //setting.Owner = this; - //setting.ShowDialog(); - //OpenShortCut(null, null); LoadFontFamily(); InitUpgrade(); //CommonSettings.InitLogDir(); @@ -1624,7 +1561,7 @@ public void SetFontFamily(string name) public void InitUpgrade() { - UpgradeHelper.Init(this); + UpgradeHelper.Init(); UpgradeHelper.OnBeforeCopyFile += () => { CloseAllPorts(null, null); @@ -1687,12 +1624,6 @@ public void InitThemeSelector() ThemeSelectorDefault.InitThemes(); } - - - - public string longText = ""; - - private async void OpenBeforePorts() { if (string.IsNullOrEmpty(ConfigManager.Main.OpeningPorts)) return; @@ -1939,11 +1870,6 @@ private void OpenSendPanel(object sender, RoutedEventArgs e) //} } - - FoldingManager foldingManager; - object foldingStrategy; - - private void HideSide(object sender, RoutedEventArgs e) { MenuItem menuItem = sender as MenuItem; @@ -2345,7 +2271,7 @@ private void BuadRate_SelectionChanged(object sender, SelectionChangedEventArgs if (e.AddedItems == null || e.AddedItems.Count <= 0) return; string text = e.AddedItems[0].ToString(); - if ("新增".Equals(text)) + if (VieModel_Main.DEFAULT_ADD_TEXT.Equals(text)) { // 记录原来的下标 int index = 0; @@ -2361,7 +2287,7 @@ private void BuadRate_SelectionChanged(object sender, SelectionChangedEventArgs } } } - DialogInput dialogInput = new DialogInput("请输入波特率"); + DialogInput dialogInput = new DialogInput(Window_Setting.INPUT_NOTICE_TEXT); bool success = false; if ((bool)dialogInput.ShowDialog(this)) { @@ -2372,7 +2298,7 @@ private void BuadRate_SelectionChanged(object sender, SelectionChangedEventArgs vieModel.BaudRates.RemoveAt(vieModel.BaudRates.Count - 1); vieModel.BaudRates.Add(baudrate.ToString()); - vieModel.BaudRates.Add("新增"); + vieModel.BaudRates.Add(VieModel_Main.DEFAULT_ADD_TEXT); success = true; (sender as ComboBox).SelectedIndex = vieModel.BaudRates.Count - 2; // 保存当前项目 @@ -2980,17 +2906,6 @@ private void SetTextViewLineNumber(object sender, RoutedEventArgs e) } - private void SetTextForeground(object sender, RoutedEventArgs e) - { - //StackPanel stackPanel = (sender as Button).Parent as StackPanel; - //ColorPicker colorPicker = stackPanel.Children.OfType().FirstOrDefault(); - //SolidColorBrush brush = new SolidColorBrush(colorPicker.SelectedColor); - //SetTextPropOption("Foreground", brush); - //ConfigManager.Main.TextForeground = brush.ToString(); - //if (stackPanel.Tag != null && stackPanel.Tag is ContextMenu contextMenu) - // contextMenu.IsOpen = false; - } - private void colorPicker_SelectedColorChanged(object sender, EventArgs e) { ColorPicker colorPicker = sender as ColorPicker; @@ -3602,7 +3517,7 @@ private void PortSettingChanged(object sender) !string.IsNullOrEmpty(portName) && vieModel.PortTabItems != null && vieModel.PortTabItems.FirstOrDefault(arg => arg.Name.Equals(portName)) is PortTabItem portTabItem && - portTabItem.SerialPort is CustomSerialPort port) + portTabItem.SerialPort is SerialPortEx port) { port.PrintSetting(); }; diff --git a/SuperCom/References/SuperUtils.dll b/SuperCom/References/SuperUtils.dll index 25630f26ebb38aa40603e8f75d888e599197395a..cc7140d986a529634950221a4b5b9382ae6b19c5 100644 GIT binary patch delta 19714 zcmb8130zcV`}gnr+-KknAgdq<12ZhL%&-i&fa@Tj;J&Y@pt#@?F1Tdc3~J_6){|Kr zP0JzeDa#%;HMLxZGMB_$Qq#1Aw8b>jw8hkVuj@Le$=?6_em?K(=fih?zw5g0^(@SW zuA6?Yn|{wNlV7ua(Xe8944=GW9#Bx_!B-_g2 z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eux zw|O4jUU`t$3H#`%Z}}VW*cX-PeG{H;o**tm1lYFQ=UlJ=cTMqFeKx@|@Rp<)u73NBG}*`3TalFL03|@#KD8b7jDdGc&vi|L2Q-UvRR4`%3e0?&dW(Vi(h?(@9w&J=~VUDW~q0G zkN)3@VWR}prbcr(4_A9_kq)VjEmE!;@V2zjNdF@j)@*NlTk6MQyp!)p)8JVx+9u_} W(}UZjr= - + Component diff --git a/SuperCom/Upgrade/UpgradeHelper.cs b/SuperCom/Upgrade/UpgradeHelper.cs index a16237e..ce70fe2 100644 --- a/SuperCom/Upgrade/UpgradeHelper.cs +++ b/SuperCom/Upgrade/UpgradeHelper.cs @@ -13,29 +13,39 @@ namespace SuperCom.Upgrade { public static class UpgradeHelper { - public static Action OnBeforeCopyFile { get; set; } public static int AUTO_CHECK_UPGRADE_DELAY = 60 * 1000; - public static void Init(Window parent) + + private const string DEFAULT_LANG = "zh-CN"; + private const string DEFAULT_UPDATEFILEDIR = "TEMP"; + private const string DEFAULT_APP_NAME = "SuperCom.exe"; + private const int DEFAULT_BEFORE_UPDATE_DELAY = 5; + private const int DEFAULT_AFTER_UPDATE_DELAY = 1; + public static Action OnBeforeCopyFile { get; set; } + private static bool WindowClosed { get; set; } + + private static SuperUpgrader Upgrader { get; set; } + private static Dialog_Upgrade Dialog_Upgrade { get; set; } + + public static void Init() { Upgrader = new SuperUpgrader(); Upgrader.UpgradeSourceDict = UrlManager.UpgradeSourceDict; Upgrader.UpgradeSourceIndex = UrlManager.GetRemoteIndex(); - Upgrader.Language = "zh-CN"; + Upgrader.Language = DEFAULT_LANG; Upgrader.Header = new CrawlerHeader(SuperWebProxy.SystemWebProxy).Default; - Upgrader.Logger = null;//todo - Upgrader.BeforeUpdateDelay = 5; - Upgrader.AfterUpdateDelay = 1; - Upgrader.UpDateFileDir = "TEMP"; - Upgrader.AppName = "SuperCom.exe"; - Window = parent; + Upgrader.Logger = null; // todo + Upgrader.BeforeUpdateDelay = DEFAULT_BEFORE_UPDATE_DELAY; + Upgrader.AfterUpdateDelay = DEFAULT_AFTER_UPDATE_DELAY; + Upgrader.UpDateFileDir = DEFAULT_UPDATEFILEDIR; + Upgrader.AppName = DEFAULT_APP_NAME; CreateDialog_Upgrade(); } public static void CreateDialog_Upgrade() { - dialog_Upgrade = new Dialog_Upgrade(Upgrader); - dialog_Upgrade.LocalVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - dialog_Upgrade.OnSourceChanged += (s, e) => + Dialog_Upgrade = new Dialog_Upgrade(Upgrader); + Dialog_Upgrade.LocalVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + Dialog_Upgrade.OnSourceChanged += (s, e) => { // 保存当前选择的地址 int index = e.NewValue; @@ -43,25 +53,24 @@ public static void CreateDialog_Upgrade() ConfigManager.Settings.RemoteIndex = index; ConfigManager.Settings.Save(); }; - dialog_Upgrade.Closed += (s, e) => + Dialog_Upgrade.Closed += (s, e) => { WindowClosed = true; }; - dialog_Upgrade.OnExitApp += () => + Dialog_Upgrade.OnExitApp += () => { OnBeforeCopyFile?.Invoke(); }; WindowClosed = false; } - private static bool WindowClosed { get; set; } - private static Window Window { get; set; } + public static void OpenWindow(Window window = null) { if (WindowClosed) CreateDialog_Upgrade(); - dialog_Upgrade?.ShowDialog(window); + Dialog_Upgrade?.ShowDialog(window); } @@ -71,8 +80,6 @@ public static void OpenWindow(Window window = null) return await Upgrader.GetUpgardeInfo(); } - private static SuperUpgrader Upgrader { get; set; } - private static Dialog_Upgrade dialog_Upgrade { get; set; } } } diff --git a/SuperCom/ViewModel/VieModel_AdvancedSend.cs b/SuperCom/ViewModel/VieModel_AdvancedSend.cs index 581dfc5..721e5b1 100644 --- a/SuperCom/ViewModel/VieModel_AdvancedSend.cs +++ b/SuperCom/ViewModel/VieModel_AdvancedSend.cs @@ -5,23 +5,34 @@ using SuperUtils.Common; using SuperUtils.Framework.ORM.Mapper; using SuperUtils.WPF.VieModel; -using SuperUtils.WPF.VisualTools; using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.IO.Ports; using System.Linq; using System.Windows; +using static SuperCom.App; namespace SuperCom.ViewModel { public class VieModel_AdvancedSend : ViewModelBase { + public MainWindow Main { get; set; } + + private static SqliteMapper Mapper { get; set; } + + public VieModel_AdvancedSend() + { + Init(); + } + + static VieModel_AdvancedSend() + { + Mapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + } - public Action OnRunCommand { get; set; } - private static SqliteMapper mapper { get; set; } + public Action OnRunCommand { get; set; } public List AllProjects { get; set; } @@ -55,10 +66,6 @@ public long CurrentProjectID } } - - - - private bool _ShowCurrentSendCommand; public bool ShowCurrentSendCommand @@ -162,17 +169,6 @@ public double LogOpacity } } - public MainWindow Main { get; set; } - - public VieModel_AdvancedSend() - { - Init(); - } - - static VieModel_AdvancedSend() - { - mapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); - } private void Init() @@ -181,9 +177,9 @@ private void Init() SendCommands = new ObservableCollection(); AllProjects = new List(); // 从数据库中读取 - if (mapper != null) + if (Mapper != null) { - AllProjects = mapper.SelectList(); + AllProjects = Mapper.SelectList(); foreach (var item in AllProjects) { CurrentProjects.Add(item); @@ -205,7 +201,7 @@ public void SearchProject(string name) CurrentProjects = new ObservableCollection(); if (string.IsNullOrEmpty(name)) { - AllProjects = mapper.SelectList(); + AllProjects = Mapper.SelectList(); foreach (var item in AllProjects) CurrentProjects.Add(item); } @@ -221,7 +217,7 @@ public void SearchProject(string name) public void LoadAllProject() { - AllProjects = mapper.SelectList(); + AllProjects = Mapper.SelectList(); } @@ -245,28 +241,28 @@ private void LoadSideComports() public void UpdateProject(AdvancedSend send) { - int count = mapper.UpdateById(send); + int count = Mapper.UpdateById(send); if (count <= 0) { - Console.WriteLine($"插入 {send.ProjectName} 失败"); + Logger.Error($"insert error: {send.ProjectName}"); } } public void RenameProject(AdvancedSend send) { - bool result = mapper.UpdateFieldById("ProjectName", send.ProjectName, send.ProjectID); + bool result = Mapper.UpdateFieldById("ProjectName", send.ProjectName, send.ProjectID); if (!result) { - Console.WriteLine($"更新 {send.ProjectName} 失败"); + Logger.Error($"update error {send.ProjectName}"); } } public void DeleteProject(AdvancedSend send) { - int count = mapper.DeleteById(send.ProjectID); + int count = Mapper.DeleteById(send.ProjectID); if (count <= 0) { - Console.WriteLine($"删除 {send.ProjectName} 失败"); + Logger.Error($"delete error {send.ProjectName}"); } else { @@ -279,18 +275,12 @@ public void AddProject(string projectName) if (string.IsNullOrEmpty(projectName)) return; AdvancedSend send = new AdvancedSend(); send.ProjectName = projectName; - bool success = mapper.Insert(send); + bool success = Mapper.Insert(send); if (success) { CurrentProjects.Add(send); AllProjects.Add(send); } } - - public void SetCurrentSendCommands() - { - - } - } } \ No newline at end of file diff --git a/SuperCom/ViewModel/VieModel_Main.cs b/SuperCom/ViewModel/VieModel_Main.cs index a91b67a..9200c3e 100644 --- a/SuperCom/ViewModel/VieModel_Main.cs +++ b/SuperCom/ViewModel/VieModel_Main.cs @@ -7,24 +7,42 @@ using SuperUtils.Framework.ORM.Mapper; using SuperUtils.Framework.ORM.Wrapper; using SuperUtils.WPF.VieModel; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.IO.Ports; using System.Linq; -using System; +using static SuperCom.App; namespace SuperCom.ViewModel { public class VieModel_Main : ViewModelBase { + public const string DEFAULT_ADD_TEXT = "新增"; + + private const string DEFAULT_STATUS_TEXT = "就绪"; + + + + + static VieModel_Main() + { + + } + + public VieModel_Main() + { + Init(); + } + + public Action> OnBaudRatesChanged; - private static SqliteMapper mapper { get; set; } - private static SqliteMapper comMapper { get; set; } - private static SqliteMapper shortCutMapper { get; set; } - private static SqliteMapper ruleMapper { get; set; } - private static SqliteMapper monitorMapper { get; set; } + private static SqliteMapper Mapper { get; set; } + private static SqliteMapper ComMapper { get; set; } + private static SqliteMapper ShortCutMapper { get; set; } + private static SqliteMapper RuleMapper { get; set; } + private static SqliteMapper MonitorMapper { get; set; } public HashSet SendHistory { get; set; } public HashSet ComSettingList { get; set; } public List ShortCutBindings { get; set; } @@ -84,7 +102,7 @@ public ObservableCollection SideComPorts get { return _SideComPorts; } set { _SideComPorts = value; RaisePropertyChanged(); } } - private string _StatusText = "就绪"; + private string _StatusText = DEFAULT_STATUS_TEXT; public string StatusText { get { return _StatusText; } @@ -104,7 +122,7 @@ public double SideGridWidth - private int _SendHistorySelectedIndex = 0; + private int _SendHistorySelectedIndex; public int SendHistorySelectedIndex { @@ -202,16 +220,6 @@ public bool ShowSoft public AdvancedSend CurrentAdvancedSend { get; set; } - static VieModel_Main() - { - - } - - public VieModel_Main() - { - Init(); - } - public void Init() { PortTabItems = new ObservableCollection(); @@ -239,7 +247,7 @@ public void Init() LoadShortCut(); LoadHandshake(); LoadHighLightRule(); - comMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + ComMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); } @@ -290,7 +298,7 @@ public void LoadBaudRates() foreach (var item in PortTabItems) { PortTabItem portTabItem = new PortTabItem(item.Name, item.Connected); - portTabItem.SerialPort = new CustomSerialPort(item.Name, item.SerialPort.BaudRate, item.SerialPort.Parity, item.SerialPort.DataBits, item.SerialPort.StopBits); + portTabItem.SerialPort = new SerialPortEx(item.Name, item.SerialPort.BaudRate, item.SerialPort.Parity, item.SerialPort.DataBits, item.SerialPort.StopBits); beforePortTabItems.Add(portTabItem); } @@ -313,15 +321,15 @@ public void LoadBaudRates() } ConfigManager.Main.CustomBaudRates = JsonUtils.TrySerializeObject(BaudRates); ConfigManager.Main.Save(); - BaudRates.Add("新增"); + BaudRates.Add(DEFAULT_ADD_TEXT); OnBaudRatesChanged?.Invoke(beforePortTabItems); } public void LoadSendCommands() { SendCommandProjects = new ObservableCollection(); - if (mapper == null) mapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); - List advancedSends = mapper.SelectList(); + if (Mapper == null) Mapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + List advancedSends = Mapper.SelectList(); foreach (var item in advancedSends) { SendCommandProjects.Add(item); @@ -331,10 +339,10 @@ public void LoadSendCommands() public void UpdateProject(AdvancedSend send) { - int count = mapper.UpdateById(send); + int count = Mapper.UpdateById(send); if (count <= 0) { - Console.WriteLine($"插入 {send.ProjectName} 失败"); + Logger.Error($"insert error: {send.ProjectName}"); } } @@ -351,17 +359,9 @@ public void LoadHighlightingDefinitions() } - - - public void SaveSendHistory() - { - //ConfigManager.Main.SendHistory = JsonUtils.TrySerializeObject(SendHistory); - //ConfigManager.Main.Save(); - } - public void InitPortData(ComPortSortType sortType = ComPortSortType.AddTime, bool desc = true) { - string[] ports = CustomSerialPort.GetAllPorts(); + string[] ports = SerialPortEx.GetAllPorts(); List portNames = new List(); switch (sortType) @@ -396,7 +396,7 @@ public void SaveBaudRate() List baudrates = new List(); for (int i = 0; i < BaudRates.Count; i++) { - if (!"新增".Equals(BaudRates[i])) + if (!DEFAULT_ADD_TEXT.Equals(BaudRates[i])) { baudrates.Add(BaudRates[i]); } @@ -417,16 +417,16 @@ public void SaveBaudRate(string portName, string baudRate) if (value <= 0) return; portTabItem.SerialPort.BaudRate = value; comSettings.PortSetting = portTabItem.SerialPort.PortSettingToJson(); - comMapper.UpdateFieldById("PortSetting", comSettings.PortSetting, comSettings.Id); + ComMapper.UpdateFieldById("PortSetting", comSettings.PortSetting, comSettings.Id); } } public void LoadShortCut() { - if (shortCutMapper == null) - shortCutMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + if (ShortCutMapper == null) + ShortCutMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); ShortCutBindings = new List(); - List shortCutBindings = shortCutMapper.SelectList(); + List shortCutBindings = ShortCutMapper.SelectList(); foreach (var item in shortCutBindings) { item.RefreshKeyList(); @@ -436,21 +436,21 @@ public void LoadShortCut() } public void LoadHighLightRule() { - if (ruleMapper == null) - ruleMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); - HighLightRule.AllRules = ruleMapper.SelectList(); + if (RuleMapper == null) + RuleMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + HighLightRule.AllRules = RuleMapper.SelectList(); } #region "变量监视器" public List GetVarMonitorByPortName(string portName) { - if (monitorMapper == null) - monitorMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + if (MonitorMapper == null) + MonitorMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); SelectWrapper wrapper = new SelectWrapper(); wrapper.Eq("PortName", portName); - List> data = monitorMapper.Select(wrapper); - List list = monitorMapper.ToEntity(data, typeof(VarMonitor).GetProperties()); + List> data = MonitorMapper.Select(wrapper); + List list = MonitorMapper.ToEntity(data, typeof(VarMonitor).GetProperties()); return list.OrderBy(arg => arg.SortOrder).ToList(); } @@ -466,14 +466,14 @@ public void NewVarMonitor(PortTabItem portTabItem, string portName) else maxOrder++; VarMonitor varMonitor = new VarMonitor(maxOrder, portName); - monitorMapper.InsertAndGetID(varMonitor); + MonitorMapper.InsertAndGetID(varMonitor); portTabItem.VarMonitors.Add(varMonitor); } public void DeleteVarMonitor(PortTabItem portTabItem, long id) { if (portTabItem.VarMonitors == null || portTabItem.VarMonitors.Count == 0 || id <= 0) return; - monitorMapper.DeleteById(id); + MonitorMapper.DeleteById(id); int idx = -1; @@ -496,7 +496,7 @@ public void SaveMonitor(PortTabItem portTabItem) List toUpdate = new List(); - List allData = monitorMapper.SelectList(); + List allData = MonitorMapper.SelectList(); foreach (var item in portTabItem.VarMonitors) { VarMonitor varMonitor = allData.FirstOrDefault(arg => arg.MonitorID == item.MonitorID); @@ -513,7 +513,7 @@ public void SaveMonitor(PortTabItem portTabItem) else { foreach (var item in toUpdate) - monitorMapper.UpdateById(item); + MonitorMapper.UpdateById(item); MessageNotify.Success("保存成功"); portTabItem.VarMonitors = new ObservableCollection(); diff --git a/SuperCom/ViewModel/VieModel_Setting.cs b/SuperCom/ViewModel/VieModel_Setting.cs index fdd39d3..7e94af7 100644 --- a/SuperCom/ViewModel/VieModel_Setting.cs +++ b/SuperCom/ViewModel/VieModel_Setting.cs @@ -5,23 +5,27 @@ using SuperUtils.Framework.ORM.Mapper; using SuperUtils.IO; using SuperUtils.WPF.VieModel; -using SuperUtils.WPF.VisualTools; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; -using System.IO.Ports; using System.Linq; -using System.Windows; using System.Windows.Media; using static SuperCom.Entity.HighLightRule; -using System; +using static SuperCom.App; namespace SuperCom.ViewModel { public class VieModel_Setting : ViewModelBase { - SqliteMapper ruleMapper { get; set; } + public VieModel_Setting() + { + Init(); + } + + + SqliteMapper RuleMapper { get; set; } private ObservableCollection _BaudRates; @@ -153,14 +157,14 @@ public void NewRule(string ruleName = "我的规则") HighLightRule rule = new HighLightRule(); rule.RuleName = ruleName; rule.FileName = ""; - ruleMapper.InsertAndGetID(rule); + RuleMapper.InsertAndGetID(rule); HighLightRules.Add(rule); } public bool DeleteRule(long id) { - int count = ruleMapper.DeleteById(id); + int count = RuleMapper.DeleteById(id); if (count <= 0) { return false; @@ -238,7 +242,7 @@ public void SetRuleSetColor(Color color, long id) public void UpdateRule(HighLightRule rule) { - int count = ruleMapper.UpdateById(rule); + int count = RuleMapper.UpdateById(rule); if (count <= 0) { Console.WriteLine($"重命名 {rule.RuleName} 失败"); @@ -255,15 +259,15 @@ public void SaveAllRule() { item.SetFileName(); item.WriteToXshd(); - ruleMapper.UpdateById(item); + RuleMapper.UpdateById(item); } - HighLightRule.AllRules = ruleMapper.SelectList(); + HighLightRule.AllRules = RuleMapper.SelectList(); } } public void RenameRule(HighLightRule rule) { - bool result = ruleMapper.UpdateFieldById("RuleName", rule.RuleName, rule.RuleID); + bool result = RuleMapper.UpdateFieldById("RuleName", rule.RuleName, rule.RuleID); if (!result) { Console.WriteLine($"重命名 {rule.RuleName} 失败"); @@ -304,14 +308,11 @@ public int AutoBackupPeriodIndex } - public VieModel_Setting() - { - Init(); - } + public void Init() { - ruleMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + RuleMapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); LoadBaudRates(); LoadHighLightRules(); RuleSets = new ObservableCollection(); @@ -319,7 +320,7 @@ public void Init() public void LoadHighLightRules() { - List highLightRules = ruleMapper.SelectList(); + List highLightRules = RuleMapper.SelectList(); HighLightRules = new ObservableCollection(); foreach (var item in highLightRules) { @@ -346,12 +347,5 @@ public void LoadBaudRates() } } } - - static VieModel_Setting() - { - - } - - } } \ No newline at end of file diff --git a/SuperCom/WatchDog/AbstractDog.cs b/SuperCom/WatchDog/AbstractDog.cs index e5d045f..73aecc6 100644 --- a/SuperCom/WatchDog/AbstractDog.cs +++ b/SuperCom/WatchDog/AbstractDog.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using static SuperCom.App; diff --git a/SuperCom/Windows/Window_AdvancedSend.xaml.cs b/SuperCom/Windows/Window_AdvancedSend.xaml.cs index 7ac0544..d1c6253 100644 --- a/SuperCom/Windows/Window_AdvancedSend.xaml.cs +++ b/SuperCom/Windows/Window_AdvancedSend.xaml.cs @@ -10,18 +10,13 @@ using System.Collections.Generic; using System.IO.Ports; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using System.Windows.Threading; +using static SuperCom.App; namespace SuperCom { @@ -30,6 +25,7 @@ namespace SuperCom /// public partial class Window_AdvancedSend : BaseWindow { + private const string DEFAULT_PROJECT_NAME = "我的项目"; public VieModel_AdvancedSend vieModel { get; set; } public MainWindow Main { get; set; } @@ -104,7 +100,7 @@ private void BaseWindow_ContentRendered(object sender, EventArgs e) private void AddNewProject(object sender, MouseButtonEventArgs e) { // 保存 - vieModel.AddProject("我的项目"); + vieModel.AddProject(DEFAULT_PROJECT_NAME); DataChanged(); } diff --git a/SuperCom/Windows/Window_Setting.xaml.cs b/SuperCom/Windows/Window_Setting.xaml.cs index 1953ffd..3d61b08 100644 --- a/SuperCom/Windows/Window_Setting.xaml.cs +++ b/SuperCom/Windows/Window_Setting.xaml.cs @@ -11,17 +11,13 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using static SuperCom.Entity.HighLightRule; +using static SuperCom.App; +using System.Data; namespace SuperCom { @@ -32,6 +28,12 @@ public partial class Window_Setting : BaseWindow { public const int HIGH_LIGHT_TAB_INDEX = 3; + + public const string INPUT_NOTICE_TEXT = "请输入波特率"; + + public static string BASE_XSHD_PATH = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, + "AvalonEdit", "Higlighting"); + private MainWindow Main { get; set; } public VieModel_Setting vieModel { get; set; } public Window_Setting() @@ -146,7 +148,7 @@ private void SaveConfigValue() private void AddNewBaudRate(object sender, MouseButtonEventArgs e) { - DialogInput input = new DialogInput("请输入波特率"); + DialogInput input = new DialogInput(INPUT_NOTICE_TEXT); if ((bool)input.ShowDialog(this)) { string text = input.Text; @@ -253,8 +255,7 @@ private void ApplyRule() //string xshdPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AvalonEdit", "Higlighting", "Default.xshd"); HighLightRule rule = vieModel.HighLightRules.Where(arg => arg.RuleID == vieModel.CurrentRuleID).FirstOrDefault(); if (rule == null) return; - string xshdPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, - "AvalonEdit", "Higlighting", rule.FileName); + string xshdPath = Path.Combine(BASE_XSHD_PATH, rule.FileName); if (!File.Exists(xshdPath)) return; using (Stream s = File.OpenRead(xshdPath)) @@ -555,7 +556,8 @@ private void CopyCommand(object sender, RoutedEventArgs e) private void previewTextEditor_GotFocus(object sender, RoutedEventArgs e) { - ((sender as TextEditor).Parent as Border).BorderBrush = (Brush)FindResource("Button.Selected.BorderBrush"); ; + ((sender as TextEditor).Parent as Border).BorderBrush = + (Brush)FindResource("Button.Selected.BorderBrush"); ; } private void previewTextEditor_LostFocus(object sender, RoutedEventArgs e) diff --git a/SuperCom/Windows/Window_ShortCut.xaml.cs b/SuperCom/Windows/Window_ShortCut.xaml.cs index c3ffb10..025f557 100644 --- a/SuperCom/Windows/Window_ShortCut.xaml.cs +++ b/SuperCom/Windows/Window_ShortCut.xaml.cs @@ -3,55 +3,43 @@ using SuperControls.Style; using SuperUtils.Common; using SuperUtils.Framework.ORM.Mapper; -using SuperUtils.WPF.VisualTools; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace SuperCom { /// /// Interaction logic for Window_ShortCut.xaml /// - public partial class Window_ShortCut : BaseWindow, INotifyPropertyChanged + public partial class Window_ShortCut : BaseWindow { - public event PropertyChangedEventHandler PropertyChanged; + private const string ADD_STRING = "+"; - protected void RaisePropertyChanged([CallerMemberName] string name = null) - { - this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } - SqliteMapper mapper = new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); + SqliteMapper Mapper = + new SqliteMapper(ConfigManager.SQLITE_DATA_PATH); - private MainWindow mainWindow { get; set; } + private MainWindow MainWindow { get; set; } public Window_ShortCut() { InitializeComponent(); this.DataContext = this; Init(); - } public void Init() { dataGrid.ItemsSource = null; ShortCutBindings = new ObservableCollection(); - List shortCutBindings = mapper.SelectList(); + List shortCutBindings = Mapper.SelectList(); foreach (var item in shortCutBindings) { item.RefreshKeyList(); @@ -64,7 +52,7 @@ public void Init() Window window = SuperUtils.WPF.VisualTools.WindowHelper.GetWindowByName("MainWindow", App.Current.Windows); if (window != null && window is MainWindow w) { - mainWindow = w; + MainWindow = w; } } @@ -93,10 +81,6 @@ private void BaseWindow_ContentRendered(object sender, EventArgs e) } - private void SearchBox_Search(object sender, RoutedEventArgs e) - { - - } public void DoSearch(string text) { @@ -115,7 +99,7 @@ public void DoSearch(string text) text = text.ToLower(); List searchList = text.Split(' ').ToList(); bool searchKey = false; - if (text.IndexOf("+") > 0) + if (text.IndexOf(ADD_STRING) > 0) { searchKey = true; searchList = text.Split('+').ToList(); @@ -199,7 +183,7 @@ private void Row_DoubleClick(object sender, MouseButtonEventArgs e) if (allKey.Count > 0) { List list = allKey.Select(arg => KeyBoardHelper.KeyToString(arg).RemoveKeyDiff()).ToList(); - keyInputTextBox.Text = string.Join("+", list).RemoveKeyDiff(); + keyInputTextBox.Text = string.Join(ADD_STRING, list).RemoveKeyDiff(); //Keyboard.Focus(keyInputTextBox); } @@ -265,7 +249,7 @@ private void TextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEvent allkey.AddRange(funcKeys); allkey.AddRange(normalKeys); - keyInputTextBox.Text = string.Join("+", keys).RemoveKeyDiff(); + keyInputTextBox.Text = string.Join(ADD_STRING, keys).RemoveKeyDiff(); hiddenTextBlock.Text = string.Join(",", allkey.Select(arg => (int)arg)); ShortCutBinding shortCutBinding = ShortCutBindingList.Where(arg => arg.Keys.ToLower().Equals(hiddenTextBlock.Text.ToLower())).FirstOrDefault(); if (shortCutBinding != null) @@ -305,11 +289,11 @@ private void SaveKey() { CurrentShortCutBinding.Keys = hiddenTextBlock.Text; CurrentShortCutBinding.RefreshKeyList(); - mapper.Update(CurrentShortCutBinding); + Mapper.Update(CurrentShortCutBinding); Init(); SearchBox_TextChanged(null, null); // 通知到其他应用 - mainWindow.OnShortCutChanged(); + MainWindow.OnShortCutChanged(); } funcKeys.Clear(); diff --git a/SuperCom/Windows/Window_VirtualPort.xaml.cs b/SuperCom/Windows/Window_VirtualPort.xaml.cs index 758e2e8..f2c5da3 100644 --- a/SuperCom/Windows/Window_VirtualPort.xaml.cs +++ b/SuperCom/Windows/Window_VirtualPort.xaml.cs @@ -4,7 +4,6 @@ using SuperControls.Style.Windows; using SuperUtils.IO; using SuperUtils.Windows.WindowRegistry; -using SuperUtils.WPF.VisualTools; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -12,39 +11,32 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace SuperCom.Windows { /// /// Interaction logic for Window_VirtualPort.xaml /// - public partial class Window_VirtualPort : BaseWindow, INotifyPropertyChanged + public partial class Window_VirtualPort : BaseWindow { + private const string PORT_PREFIX_A = "CNCA"; + private const string PORT_PREFIX_B = "CNCB"; + private const string PORT_PREFIX = "COM"; + private const int SHOW_NEW_PORT_INTERVAL = 100; - public event PropertyChangedEventHandler PropertyChanged; + private static readonly string COM_0_COM_INSTALLED_PATH = + System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Installer", "setup.exe"); - protected void RaisePropertyChanged([CallerMemberName] string name = null) - { - this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } public Window_VirtualPort() { InitializeComponent(); this.DataContext = this; } - - private bool _IsCom0ConInstalled = false; public bool IsCom0ConInstalled { @@ -153,9 +145,6 @@ public async void Init() } - - private static string COM_0_COM_INSTALLED_PATH = - System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Installer", "setup.exe"); private void InstallCom0Com(object sender, RoutedEventArgs e) { if (!File.Exists(COM_0_COM_INSTALLED_PATH)) @@ -164,7 +153,7 @@ private void InstallCom0Com(object sender, RoutedEventArgs e) return; } FileHelper.TryOpenFile(COM_0_COM_INSTALLED_PATH); - bool success = (bool)new MsgBox("安装完成后重新打开虚拟串口").ShowDialog(this); + _ = (bool)new MsgBox("安装完成后重新打开虚拟串口").ShowDialog(this); this.Close(); } @@ -199,7 +188,7 @@ private async void DeletePort(object sender, RoutedEventArgs e) string id = button.Tag.ToString(); if (string.IsNullOrEmpty(id)) return; - id = id.Replace("CNCA", "").Replace("CNCB", ""); + id = id.Replace(PORT_PREFIX_A, "").Replace(PORT_PREFIX_B, ""); int.TryParse(id, out int n); if (n >= 0) { @@ -360,11 +349,9 @@ private void CloseNewVirtualPortGrid(object sender, RoutedEventArgs e) private async void ShowNewVirtualPortGrid(object sender, RoutedEventArgs e) { newVirtualPortGrid.Visibility = Visibility.Visible; - - - portNameA.Text = "COM"; - portNameB.Text = "COM"; - await Task.Delay(100); + portNameA.Text = PORT_PREFIX; + portNameB.Text = PORT_PREFIX; + await Task.Delay(SHOW_NEW_PORT_INTERVAL); portNameA.SetFocus(); }