Skip to content

Commit d2fcb03

Browse files
author
panwenbo
committed
One.Toolbox
紧急修复Note笔记丢失问题:
1 parent 1246f5a commit d2fcb03

File tree

10 files changed

+47
-55
lines changed

10 files changed

+47
-55
lines changed

One.Toolbox/One.Toolbox.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Nullable>enable</Nullable>
88
<UseWPF>true</UseWPF>
99
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
10-
<Version>2.6.3</Version>
10+
<Version>2.6.4</Version>
1111
<ImplicitUsings>enable</ImplicitUsings>
1212
<SatelliteResourceLanguages>zh-Hans;en-us</SatelliteResourceLanguages>
1313
<ApplicationIcon>Icon.ico</ApplicationIcon>

One.Toolbox/Resources/Languages/en_US.xaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
4-
<system:String x:Key="AppTitle">One.Toolbox - Debug serial port with Lua!</system:String>
54
<system:String x:Key="Open">Open</system:String>
65
<system:String x:Key="OpenPort_close">Close</system:String>
76
<system:String x:Key="OpenPort_port">Port</system:String>
@@ -50,27 +49,8 @@
5049
<system:String x:Key="QuickSendChangeIdButton">Enter where you want to insert(empty means delete this line)</system:String>
5150
<system:String x:Key="QuickSendChangeIdTitle">Change index of this line</system:String>
5251
<system:String x:Key="QuickSendChangeList">Change to another quick send list</system:String>
53-
<system:String x:Key="LuaCard">Run script</system:String>
54-
<system:String x:Key="LuaNewScript">New script</system:String>
55-
<system:String x:Key="LuaRunScript">Run script</system:String>
56-
<system:String x:Key="LuaOpenFolder">Open script folder</system:String>
57-
<system:String x:Key="LuaRefreshList">Refresh script List</system:String>
58-
<system:String x:Key="LuaApiReference">See api reference</system:String>
59-
<system:String x:Key="LuaGetShare">Get scripts on community</system:String>
60-
<system:String x:Key="LuaFileName">File name:</system:String>
61-
<system:String x:Key="LuaConfirmCreate">Confirm create file</system:String>
62-
<system:String x:Key="Cancel">Cancel</system:String>
63-
<system:String x:Key="LuaStop">Stop run</system:String>
64-
<system:String x:Key="LuaQuit">Quit</system:String>
65-
<system:String x:Key="LuaOverload">Reload and run</system:String>
66-
<system:String x:Key="LuaPause">Pause Log print,Right-click Clear Log</system:String>
67-
<system:String x:Key="LuaContinue">Continue print log</system:String>
68-
<system:String x:Key="LuaSendScript">Run Lua command - [Enter]</system:String>
69-
<system:String x:Key="LuaNoName">Please enter file name!</system:String>
70-
<system:String x:Key="LuaExist">File is exist!</system:String>
71-
<system:String x:Key="LuaCreateFail">Create file failed, please check.</system:String>
52+
7253
<system:String x:Key="AboutCard">About</system:String>
73-
<system:String x:Key="AboutSubTitle">Debug with your own script!</system:String>
7454
<system:String x:Key="AboutDiscriptionMain">One.Toolbox is a small software that contains a collection of tools such as character conversion, serial debugging, and network debugging.</system:String>
7555

7656
<system:String x:Key="AboutAutoUpdate">Auto update</system:String>

One.Toolbox/Resources/Languages/zh_CN.xaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
4-
<system:String x:Key="AppTitle">One.Toolbox - 能跑Lua脚本的串口调试工具</system:String>
54
<system:String x:Key="Open">打开</system:String>
65
<system:String x:Key="OpenPort_close">关闭</system:String>
76
<system:String x:Key="OpenPort_port">串口</system:String>
@@ -50,28 +49,8 @@
5049
<system:String x:Key="QuickSendChangeIdButton">输入你想改到哪个序号的位置(留空表示删除该项目)</system:String>
5150
<system:String x:Key="QuickSendChangeIdTitle">更改这个条目的序号</system:String>
5251
<system:String x:Key="QuickSendChangeList">切换到其他快捷发送数据列表</system:String>
53-
<system:String x:Key="LuaCard">运行脚本</system:String>
54-
<system:String x:Key="LuaNewScript">新建脚本</system:String>
55-
<system:String x:Key="LuaRunScript">运行脚本</system:String>
56-
<system:String x:Key="LuaOpenFolder">打开脚本目录</system:String>
57-
<system:String x:Key="LuaRefreshList">刷新脚本列表</system:String>
58-
<system:String x:Key="LuaApiReference">查看接口文档</system:String>
59-
<system:String x:Key="LuaGetShare">获取社区上分享的脚本,或把脚本分享给大家</system:String>
60-
<system:String x:Key="LuaFileName">文件名:</system:String>
61-
<system:String x:Key="LuaConfirmCreate">确认新建文件</system:String>
62-
<system:String x:Key="Cancel">取消</system:String>
63-
<system:String x:Key="LuaStop">停止运行</system:String>
64-
<system:String x:Key="LuaQuit">退出</system:String>
65-
<system:String x:Key="LuaOverload">重新载入代码并运行</system:String>
66-
<system:String x:Key="LuaPause">暂停打印,右键单击清空日志</system:String>
67-
<system:String x:Key="LuaContinue">继续打印</system:String>
68-
<system:String x:Key="LuaSendScript">实时执行lua语句 - [Enter]</system:String>
69-
<system:String x:Key="LuaNoName">请输入文件名!</system:String>
70-
<system:String x:Key="LuaExist">该文件已存在!</system:String>
71-
<system:String x:Key="LuaCreateFail">新建失败,请检查!</system:String>
7252

7353
<system:String x:Key="AboutCard">关于</system:String>
74-
<system:String x:Key="AboutSubTitle">能跑Lua脚本的串口调试工具</system:String>
7554
<system:String x:Key="AboutDiscriptionMain">One.Toolbox是一款包含字符转换,串口调试工具,网络调试工具等工具集合的小软件。</system:String>
7655
<system:String x:Key="AboutAutoUpdate">开启软件后,自动检查是否需要更新</system:String>
7756
<system:String x:Key="AboutLoadingUpdate">更新数据加载中</system:String>

One.Toolbox/Services/SettingService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ void InitDefaultData()
6666
{
6767
AllConfig = new AllConfigModel();
6868

69-
AllConfig.SerialportSetting.QuickSendList.Add(new QuickSendVM()
69+
AllConfig.SerialportSetting.QuickSendList.Add(new QuickSendModel()
7070
{
7171
Id = 0,
7272
Commit = "发送",
7373
Hex = false,
7474
Text = "Hello?",
7575
});
7676

77-
AllConfig.SerialportSetting.QuickSendList.Add(new QuickSendVM()
77+
AllConfig.SerialportSetting.QuickSendList.Add(new()
7878
{
7979
Id = 1,
8080
Commit = "Hex发送",

One.Toolbox/ViewModels/NotePad/EditFileInfoVM.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ private void OnSelectedHighlightingChanged(object obj)
126126
private void RenameFile(object obj)
127127
{
128128
var parent = obj as Grid;
129-
var txb = parent.FindName("txb1") as TextBox;
130-
if (txb != null)
129+
if (parent.FindName("txb1") is TextBox txb)
131130
{
132131
IsEditFileName = true;
133132
txb.LostFocus += Txb_LostFocus;
@@ -245,8 +244,10 @@ public void SaveDocument()
245244
{
246245
StreamWriter writer = Encoding != null ? new StreamWriter(fs, Encoding) : new StreamWriter(fs);
247246
if (Document != null)
247+
{
248248
Document.WriteTextTo(writer);
249-
writer.Flush();
249+
writer.Flush();
250+
}
250251
}
251252
}
252253
}

One.Toolbox/ViewModels/NotePad/NotePadPageVM.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ public NotePadPageVM()
2929

3030
SaveSetting();
3131
});
32+
33+
InitData();
3234
}
3335

3436
public override void OnNavigatedEnter()
3537
{
3638
base.OnNavigatedEnter();
37-
InitData();
3839
}
3940

4041
void InitData()
@@ -111,14 +112,15 @@ public void SaveSetting()
111112
service.AllConfig.EditFileInfoList.Clear();
112113
foreach (var item in EditFileInfoViewModelOC)
113114
{
114-
item.SaveDocument();
115115
EditFileInfo editFileInfo = new()
116116
{
117117
FilePath = item.FilePath,
118118
FileName = item.FileName,
119119
CreateTime = item.CreateTime,
120120
ModifyTime = item.ModifyTime,
121121
};
122+
item.SaveDocument();
123+
122124
service.AllConfig.EditFileInfoList.Add(editFileInfo);
123125
}
124126

One.Toolbox/ViewModels/Serialport/QuickSendVM.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,34 @@ private void SendData(object obj)
6161
}
6262
}
6363
}
64+
65+
public QuickSendModel ToM()
66+
{
67+
QuickSendModel quickSendVM = new QuickSendModel();
68+
quickSendVM.Id = Id;
69+
quickSendVM.Text = Text;
70+
quickSendVM.Hex = Hex;
71+
quickSendVM.Commit = Commit;
72+
73+
return quickSendVM;
74+
}
75+
}
76+
77+
public class QuickSendModel
78+
{
79+
public int Id { get; set; }
80+
public string Text { get; set; }
81+
public bool Hex { get; set; }
82+
public string Commit { get; set; }
83+
84+
public QuickSendVM ToVM()
85+
{
86+
QuickSendVM quickSendVM = new QuickSendVM();
87+
quickSendVM.Id = Id;
88+
quickSendVM.Text = Text;
89+
quickSendVM.Hex = Hex;
90+
quickSendVM.Commit = Commit;
91+
92+
return quickSendVM;
93+
}
6494
}

One.Toolbox/ViewModels/Serialport/SerialportParams.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class SerialportSettingModel
2020

2121
public bool ShortTimeInfo { get; set; }
2222

23-
public List<QuickSendVM> QuickSendList { get; set; } = new List<QuickSendVM>();
23+
public List<QuickSendModel> QuickSendList { get; set; } = new List<QuickSendModel>();
2424

2525
public SerialportSettingVM ToVM()
2626
{
@@ -33,7 +33,7 @@ public SerialportSettingVM ToVM()
3333
serialportSettingModel.MaxLength = MaxLength;
3434
serialportSettingModel.MaxPacksAutoClear = MaxPacksAutoClear;
3535
serialportSettingModel.LagAutoClear = LagAutoClear;
36-
serialportSettingModel.QuickSendList = QuickSendList;
36+
serialportSettingModel.QuickSendList = QuickSendList.Select(x => x.ToVM()).ToList();
3737
serialportSettingModel.ShortTimeInfo = ShortTimeInfo;
3838

3939
return serialportSettingModel;

One.Toolbox/ViewModels/Serialport/SerialportSettingVM.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public SerialportSettingModel ToModel()
5151
serialportSettingModel.MaxLength = MaxLength;
5252
serialportSettingModel.MaxPacksAutoClear = MaxPacksAutoClear;
5353
serialportSettingModel.LagAutoClear = LagAutoClear;
54-
serialportSettingModel.QuickSendList = QuickSendList;
54+
serialportSettingModel.QuickSendList = QuickSendList.Select(x => x.ToM()).ToList();
5555
serialportSettingModel.ShortTimeInfo = ShortTimeInfo;
5656

5757
return serialportSettingModel;

One.Toolbox/Views/NotePad/NotePadPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
</ListBox.ItemContainerStyle>
5757
<ListBox.ItemTemplate>
5858
<DataTemplate DataType="localVMS:EditFileInfoViewModel">
59-
<Grid >
59+
<Grid>
6060
<Grid.RowDefinitions>
6161
<RowDefinition />
6262
<RowDefinition Height="auto" />
6363
</Grid.RowDefinitions>
6464
<Grid.ContextMenu>
6565
<ContextMenu>
6666
<MenuItem Command="{Binding Data.DeleteFileCommand, Source={StaticResource proxy}}" Header="Delete" />
67-
<MenuItem Command="{Binding RenameFileCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=Parent.PlacementTarget}" Header="Rename" />
67+
<MenuItem Command="{Binding RenameFileCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Parent.PlacementTarget}" Header="Rename" />
6868
<!-- {Binding ElementName=listbox} cannot find -->
6969
<MenuItem Command="{Binding OpenFilePathCommand}" Header="Open File Path" />
7070
</ContextMenu>

0 commit comments

Comments
 (0)