Skip to content

Commit d0f0981

Browse files
committed
enable export error message
1 parent e639d9a commit d0f0981

File tree

7 files changed

+21
-7
lines changed

7 files changed

+21
-7
lines changed

src/IME WL Converter Win/Forms/MainForm.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ private void btnConvert_Click(object sender, EventArgs e)
229229
mainBody.Filters = GetFilters();
230230
mainBody.BatchFilters = GetBatchFilters();
231231
mainBody.ReplaceFilters = GetReplaceFilters();
232-
mainBody.Import.ImportLineErrorNotice += WriteErrorMessage;
232+
mainBody.Import.ImportLineErrorNotice += WriteErrorMessage;
233+
mainBody.Export.ExportErrorNotice += WriteErrorMessage;
233234
mainBody.ProcessNotice+=RichTextBoxShow;
234235
timer1.Enabled = true;
235236
backgroundWorker1.RunWorkerAsync();

src/ImeWlConverterCore/IME/BaseImport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,11 @@ protected void SendImportLineErrorNotice(string msg)
3939
{
4040
ImportLineErrorNotice?.Invoke(msg);
4141
}
42+
43+
public event Action<string> ExportErrorNotice;
44+
protected void SendExportErrorNotice(string msg)
45+
{
46+
ExportErrorNotice?.Invoke(msg);
47+
}
4248
}
4349
}

src/ImeWlConverterCore/IME/Win10MsPinyin.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ public WordLibraryList ImportLine(string str)
170170
{
171171
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
172172
}
173-
173+
public event Action<string> ExportErrorNotice;
174+
174175
public IList<string> Export(WordLibraryList wlList)
175176
{
176177
//Win10拼音只支持最多32个字符的编码
177178
wlList = Filter(wlList);
178179

179-
string tempPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\Win10微软拼音词库.dat";
180+
string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "\\Win10微软拼音词库.dat");
180181
if (File.Exists(tempPath)) { File.Delete(tempPath); }
181182
var fs = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write);
182183
BinaryWriter bw = new BinaryWriter(fs);

src/ImeWlConverterCore/IME/Win10MsPinyinSelfStudy.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ public WordLibraryList ImportLine(string str)
531531
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
532532
}
533533
public string ExportFilePath { get; set; }
534+
public event Action<string> ExportErrorNotice;
535+
protected void SendExportErrorNotice(string msg)
536+
{
537+
ExportErrorNotice?.Invoke(msg);
538+
}
534539
/// <summary>
535540
/// 最多支持2W条一个dat文件
536541
/// </summary>
@@ -543,7 +548,7 @@ public IList<string> Export(WordLibraryList wlList)
543548
var list = new List<WordLibraryList>();
544549
if(wlList.Count>20000)
545550
{
546-
throw new Exception("微软拼音自学习词库最多支持2万条记录的导入,当前词条数为:"+wlList.Count+",操过限制,请设置过滤条件或者更换词库源。");
551+
SendExportErrorNotice("微软拼音自学习词库最多支持2万条记录的导入,当前词条数为:"+wlList.Count+",超过限制,请设置过滤条件或者更换词库源。");
547552
//以后微软拼音放开2W限制了,再把这个异常取消吧。
548553
var item20000 = new WordLibraryList();
549554
for(var i=0;i<wlList.Count;i++)

src/ImeWlConverterCore/IME/Win10MsWubi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ public WordLibraryList ImportLine(string str)
160160
{
161161
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
162162
}
163-
163+
public event Action<string> ExportErrorNotice;
164164
public IList<string> Export(WordLibraryList wlList)
165165
{
166166
//Win10拼音只支持最多32个字符的编码
167167
wlList = Filter(wlList);
168-
string tempPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\Win10微软五笔词库.dat";
168+
string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "\\Win10微软五笔词库.dat");
169169
if (File.Exists(tempPath)) { File.Delete(tempPath); }
170170
var fs = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write);
171171
BinaryWriter bw = new BinaryWriter(fs);

src/ImeWlConverterCore/ImeWlConverterCore-net46.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>net46</TargetFramework>
66
<AssemblyName>ImeWlConverterCore</AssemblyName>
77
<RootNamespace>ImeWlConverterCore</RootNamespace>
8-
<Version>2.7.0</Version>
8+
<Version>2.8.0</Version>
99
</PropertyGroup>
1010

1111
<ItemGroup>

src/ImeWlConverterCore/Interface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public interface IWordLibraryTextImport : IWordLibraryImport
2727

2828
public interface IWordLibraryExport
2929
{
30+
event Action<string> ExportErrorNotice;
3031
Encoding Encoding { get; }
3132
CodeType CodeType { get; }
3233
/// <summary>

0 commit comments

Comments
 (0)