update
This commit is contained in:
parent
09009596de
commit
4116886a32
Binary file not shown.
@ -331,10 +331,12 @@
|
||||
<Compile Include="core\Tools.cs" />
|
||||
<Compile Include="core\MainPanelWebMessage.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Model\DocumentInfo.cs" />
|
||||
<Compile Include="ProofreadItem.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Transform.cs" />
|
||||
<Compile Include="Util\HostHelper.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<EmbeddedResource Include="Controls\FormContact.resx">
|
||||
@ -406,8 +408,18 @@
|
||||
<Name>util-lib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
<None Include="Resources\icon-refresh.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-refresh-wps.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-save.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-save-wps.jpg" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
@ -49,19 +49,17 @@ namespace AIProofread
|
||||
public void ShowUpgradeView()
|
||||
{
|
||||
var needUpgrade = CurrentUpgrade.NeedUpgrade(Config.APP_VERSION);
|
||||
if (!needUpgrade)
|
||||
{
|
||||
showDialog("当前版本为最新版本,无需升级");
|
||||
return;
|
||||
}
|
||||
if (CurrentUpgrade.Ext == 1)
|
||||
{
|
||||
if (!needUpgrade)
|
||||
var ret = MessageBox.Show(CurrentUpgrade.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (ret == DialogResult.Yes)
|
||||
{
|
||||
showDialog("当前版本为最新版本,无需升级");
|
||||
}
|
||||
else
|
||||
{
|
||||
var ret = MessageBox.Show(CurrentUpgrade.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (ret == DialogResult.Yes)
|
||||
{
|
||||
OpenUrlWithOsBrowser(CurrentUpgrade.DownloadUrl);
|
||||
}
|
||||
OpenUrlWithOsBrowser(CurrentUpgrade.DownloadUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -462,7 +460,7 @@ namespace AIProofread
|
||||
{
|
||||
if (item.mark != null)
|
||||
{
|
||||
if (item.content.tag == "i" && item.content.isAccept == AcceptStatus.Default)
|
||||
if (item.content.Tag == "i" && item.content.IsAccept == AcceptStatus.Default)
|
||||
{
|
||||
item.mark.Text = "";
|
||||
}
|
||||
@ -691,7 +689,7 @@ namespace AIProofread
|
||||
{
|
||||
throw new Exception("没有找到校对文档对象");
|
||||
}
|
||||
List<DocumentCorrectItem> list = JsonConvert.DeserializeObject<List<DocumentCorrectItem>>(content);
|
||||
List<CorrectContext> list = JsonConvert.DeserializeObject<List<CorrectContext>>(content);
|
||||
|
||||
// 先清除所有数据
|
||||
clearAllProofreadMark(CurrentDocument);
|
||||
@ -703,11 +701,11 @@ namespace AIProofread
|
||||
List<int> disabledList = new List<int>();
|
||||
foreach (var correct in list)
|
||||
{
|
||||
if (correct.Diffs != null && correct.Diffs.Count > 0)
|
||||
if (correct.CorrectItems != null && correct.CorrectItems.Count > 0)
|
||||
{
|
||||
prevOffset = 0;
|
||||
int index = 0;
|
||||
foreach (var item in correct.Diffs)
|
||||
foreach (var item in correct.CorrectItems)
|
||||
{
|
||||
int _prev = prevOffset;
|
||||
// 查找对应区域并再该区域添加书签
|
||||
@ -715,17 +713,17 @@ namespace AIProofread
|
||||
// 防止调用方法中没有更新
|
||||
if (_prev >= prevOffset)
|
||||
{
|
||||
prevOffset = correct.SentenceOffset + item.start;
|
||||
prevOffset = correct.SentenceOffset + item.Start;
|
||||
}
|
||||
|
||||
if (item.tag != "i") index++;
|
||||
if (item.Tag != "i") index++;
|
||||
if (mark != null)
|
||||
{
|
||||
marks.Add(item.id, new ProofreadItem(item, mark, documentId));
|
||||
marks.Add(item.Id, new ProofreadItem(item, mark, documentId));
|
||||
}
|
||||
else
|
||||
{
|
||||
disabledList.Add(item.id);
|
||||
disabledList.Add(item.Id);
|
||||
var msg = new Dictionary<string, object>{
|
||||
{"message","没有找到标记对象" },
|
||||
{ "origin",item },
|
||||
@ -742,15 +740,15 @@ namespace AIProofread
|
||||
{
|
||||
if (item.Value.mark != null)
|
||||
{
|
||||
if (item.Value.content.tag == "i")
|
||||
if (item.Value.content.Tag == "i")
|
||||
{
|
||||
item.Value.mark.Text = ToolUtil.GetBlankText(item.Value.content.text.Length);
|
||||
item.Value.mark.Text = ToolUtil.GetBlankText(item.Value.content.Text.Length);
|
||||
}
|
||||
if (item.Value.content.color != null)
|
||||
if (item.Value.content.Color != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var color = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.color));
|
||||
var color = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.Color));
|
||||
// 给选区添加背景颜色
|
||||
item.Value.mark.Shading.BackgroundPatternColor = color;
|
||||
}
|
||||
@ -812,14 +810,14 @@ namespace AIProofread
|
||||
/// <param name="sentense">校对</param>
|
||||
/// <param name="prevOffset"></param>
|
||||
/// <returns></returns>
|
||||
public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark1(CorrectedContent correct, DocumentCorrectItem sentense, ref int prevOffset)
|
||||
public Microsoft.Office.Tools.Word.Bookmark FindRangeAndCreateBookmark1(CorrectItem correct, CorrectContext sentense, ref int prevOffset)
|
||||
{
|
||||
Microsoft.Office.Tools.Word.Bookmark bookmark = null;
|
||||
try
|
||||
{
|
||||
var document = CurrentDocument;
|
||||
ControlCollection controls = Globals.Factory.GetVstoObject(document).Controls;
|
||||
var markName = Config.BuildBookmarkName(correct.id);
|
||||
var markName = Config.BuildBookmarkName(correct.Id);
|
||||
|
||||
// 判断是否已经存在
|
||||
if (controls.Contains(markName))
|
||||
@ -852,8 +850,8 @@ namespace AIProofread
|
||||
string fullText = fullRange.Text ?? paragraphRange.Text;
|
||||
// 当前段落文本
|
||||
string paragraphText = paragraphRange.Text;
|
||||
End = Start + correct.end;
|
||||
Start = Start + correct.start;
|
||||
End = Start + correct.End;
|
||||
Start = Start + correct.Start;
|
||||
// 避免越界
|
||||
prevOffset = Math.Min(prevOffset, paragraphText.Length - 1);
|
||||
|
||||
@ -862,7 +860,7 @@ namespace AIProofread
|
||||
string originText = sentense.Insert;
|
||||
|
||||
// 如果是新增 则查找定位
|
||||
if (correct.tag == "i")
|
||||
if (correct.Tag == "i")
|
||||
{
|
||||
// s1. 通过接口的位置 和 文档内容进行比对
|
||||
try
|
||||
@ -882,16 +880,16 @@ namespace AIProofread
|
||||
if (findRange == null)
|
||||
{
|
||||
// 找前缀
|
||||
var prefix = correct.start > 2 ? (
|
||||
correct.start > INSERT_FIND_OFFSET
|
||||
? originText.Substring(correct.start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, correct.start)
|
||||
var prefix = correct.Start > 2 ? (
|
||||
correct.Start > INSERT_FIND_OFFSET
|
||||
? originText.Substring(correct.Start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, correct.Start)
|
||||
) : null;
|
||||
// 找后缀
|
||||
var suffix = prefix == null ? (
|
||||
correct.end + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(correct.start, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(correct.start, originText.Length - correct.start)
|
||||
correct.End + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(correct.Start, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(correct.Start, originText.Length - correct.Start)
|
||||
) : null;
|
||||
// 偏移量
|
||||
var start = prefix != null || suffix != null
|
||||
@ -909,7 +907,7 @@ namespace AIProofread
|
||||
findRange = document.Range(Start, End);
|
||||
}
|
||||
// 不是新增模式 且定位区域文本和原始文本不匹配
|
||||
if (correct.tag != "i" && findRange.Text != correct.origin)
|
||||
if (correct.Tag != "i" && findRange.Text != correct.Origin)
|
||||
{
|
||||
// 查找
|
||||
findRange = DocumentUtil.FindRange(correct, sentense, ref prevOffset, CurrentDocument, paragraphRange);
|
||||
|
@ -12,7 +12,7 @@ namespace AIProofread
|
||||
public class Config
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "1.0.11";
|
||||
public static readonly string APP_VERSION = "1.0.12";
|
||||
public static bool IS_WPS = false;
|
||||
|
||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||
|
@ -10,6 +10,7 @@ namespace AIProofread
|
||||
public class Logger
|
||||
{
|
||||
private static readonly string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -24,7 +25,7 @@ namespace AIProofread
|
||||
StreamWriter streamWriter = File.AppendText(path);
|
||||
streamWriter.WriteLine("***************************[" + (Config.IS_WPS ? "WPS" : "WORD") + "]***************************");
|
||||
streamWriter.WriteLine("消息:" + msg);
|
||||
streamWriter.WriteLine("时间:" + DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"));
|
||||
streamWriter.WriteLine("时间:" + DateTime.Now.ToString("HH:mm:ss"));
|
||||
streamWriter.WriteLine();
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
|
228
AIProofread/Model/DocumentInfo.cs
Normal file
228
AIProofread/Model/DocumentInfo.cs
Normal file
@ -0,0 +1,228 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using UtilLib;
|
||||
|
||||
namespace AIProofread.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 文档信息 包含文档相关数据、面板及对文档的相关操作
|
||||
/// </summary>
|
||||
public class DocumentInfo
|
||||
{
|
||||
private static char[] ArticleSpecialChars = new char[4] { '\a', '\r', '\v', '\f' };
|
||||
|
||||
//private Document currentDocument;
|
||||
public Document CurrentDocument { get; set; }
|
||||
private string fileName;
|
||||
private string uniqueId;
|
||||
|
||||
private List<Range> ranges = new List<Range>();
|
||||
public string UniqueId
|
||||
{
|
||||
get { return uniqueId; }
|
||||
|
||||
}
|
||||
|
||||
// 计算uniqueId
|
||||
private void ComputeUniqueId()
|
||||
{
|
||||
string filename = CurrentDocument.FullName;
|
||||
if (!string.IsNullOrEmpty(uniqueId) || string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 通过文档路径生成唯一id
|
||||
uniqueId = filename.GetHashCode().ToString();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
public DocumentInfo(Document doc)
|
||||
{
|
||||
this.CurrentDocument = doc;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
ranges.Clear();
|
||||
ComputeUniqueId();
|
||||
}
|
||||
|
||||
//处理文档选区时 判断当前选区是否有校对项 有则选择该范围
|
||||
public void ProcessSelectionChange(Selection s)
|
||||
{
|
||||
// 判断选区内是否有书签
|
||||
if (s.Bookmarks != null && s.Bookmarks.Count > 0)
|
||||
{
|
||||
// 判断是否时点击 点击的起始和结束位置相同
|
||||
if (s.Range.Start == s.Range.End)
|
||||
{
|
||||
//
|
||||
var count = s.Bookmarks.Count;
|
||||
// 原则只有一个书签
|
||||
//foreach (Microsoft.Office.Interop.Word.Bookmark item in s.Bookmarks)
|
||||
//{
|
||||
// int proofreadId = Config.GetBookmarkIdByName(item.Name);
|
||||
// if (proofreadId > 0)
|
||||
// {
|
||||
// //Bridge.bridge.SelectMarkById(proofreadId, 0);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前文档文本
|
||||
public string GetText()
|
||||
{
|
||||
return CurrentDocument.Range().Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前选中文本
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSelectedText()
|
||||
{
|
||||
return CurrentDocument.Range().Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定选区的文本
|
||||
/// </summary>
|
||||
/// <param name="range"></param>
|
||||
/// <returns></returns>
|
||||
public string GetRangeText(Range range)
|
||||
{
|
||||
string text = range?.Text;
|
||||
return string.IsNullOrEmpty(text) ? "" : text;
|
||||
}
|
||||
|
||||
// 定位所有的校对项
|
||||
public void LocateAllProofreadItems(List<CorrectContext> list)
|
||||
{
|
||||
// 获取所有的校对项
|
||||
//List<Range> proofreadItems = GetProofreadItems();
|
||||
var prevOffset = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item.CorrectItems != null && item.CorrectItems.Count > 0)
|
||||
{
|
||||
foreach (var correct in item.CorrectItems)
|
||||
{
|
||||
var range = LocateProofreadItem(correct,item,ref prevOffset);
|
||||
if (range == null) continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找偏移量
|
||||
/// </summary>
|
||||
private static readonly int INSERT_FIND_OFFSET = 5;
|
||||
/// <summary>
|
||||
/// 定位校对项
|
||||
/// </summary>
|
||||
/// <param name="correct">校对项</param>
|
||||
/// <param name="ctx">校对上下文</param>
|
||||
/// <param name="prevOffset">上一步的</param>
|
||||
/// <returns></returns>
|
||||
private Range LocateProofreadItem(CorrectItem correct, CorrectContext ctx, ref int prevOffset)
|
||||
{
|
||||
var document = CurrentDocument;
|
||||
// 校对项的段落号超过文档的段落数,直接返回
|
||||
if (ctx.ParagraphNumber > document.Paragraphs.Count) return null;
|
||||
// 获取当前段落
|
||||
var paragraph = document.Paragraphs[ctx.ParagraphNumber];
|
||||
if (paragraph == null) return null;
|
||||
|
||||
|
||||
var paraRange = paragraph.Range;
|
||||
var paraText = paraRange.Text;
|
||||
var paraStart = paraRange.Start;
|
||||
|
||||
var offset = paraStart + ctx.SentenceOffset;
|
||||
//var cutLength = Math.Min(c.InsertLen, paraText.Length - offset);
|
||||
var sentence = paraText.Substring(ctx.SentenceOffset, ctx.InsertLength);
|
||||
if (sentence == ctx.Insert)
|
||||
{ // 比对原始内容与校对原文是否一致
|
||||
var range = document.Range(offset + correct.Start, offset + correct.End);
|
||||
//
|
||||
if (range.Text == correct.Origin) return range;
|
||||
}
|
||||
|
||||
var originText = ctx.Insert;
|
||||
// 如果是新增 则查找定位
|
||||
if (correct.Tag == "i")
|
||||
{
|
||||
// 找前缀
|
||||
var prefix1 = correct.Start > 2 ? (
|
||||
correct.Start > INSERT_FIND_OFFSET
|
||||
? originText.Substring(correct.Start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, correct.Start)
|
||||
) : null;
|
||||
// 找后缀
|
||||
var suffix1 = prefix1 == null ? (
|
||||
correct.End + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(correct.Start, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(correct.Start, originText.Length - correct.Start)
|
||||
) : null;
|
||||
// 偏移量
|
||||
var start1 = prefix1 != null || suffix1 != null
|
||||
? paraText.IndexOf(prefix1 ?? suffix1, prevOffset)
|
||||
: -1;
|
||||
if (start1 != -1)
|
||||
{
|
||||
var findOffset = paraStart + start1 + (prefix1 != null ? prefix1.Length : 0);
|
||||
return document.Range(findOffset, findOffset);
|
||||
}
|
||||
}
|
||||
|
||||
// 执行查找
|
||||
int wordStart = correct.Start;
|
||||
int wordEnd = correct.End;
|
||||
|
||||
// 找前缀
|
||||
var prefix = wordStart > 2 ? (
|
||||
wordStart > INSERT_FIND_OFFSET
|
||||
? originText.Substring(wordStart - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, wordStart)
|
||||
) : null;
|
||||
|
||||
// 找后缀
|
||||
var suffix = prefix == null ? (
|
||||
wordEnd + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(wordStart, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(wordStart, originText.Length - wordStart)
|
||||
) : null;
|
||||
var start = prefix != null || suffix != null
|
||||
? paraText.IndexOf(prefix ?? suffix, prevOffset) // item.start +
|
||||
: -1;
|
||||
if (start != -1)
|
||||
{
|
||||
var findOffset = paraRange.Start + start + (prefix != null ? prefix.Length : 0);
|
||||
var range = document.Range(findOffset, findOffset + wordEnd - wordStart);
|
||||
if (range.Text == correct.Origin) { return range; }
|
||||
}
|
||||
// 直接定位查找
|
||||
start = paraText.IndexOf(correct.Origin, prevOffset);
|
||||
if (start == -1) return null;
|
||||
// 定位整体开始位置
|
||||
start = paraStart + start;
|
||||
return document.Range(start, start + correct.Origin.Length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@ namespace UtilLib
|
||||
public class ProofreadItem
|
||||
{
|
||||
public Bookmark mark;
|
||||
public CorrectedContent content;
|
||||
public CorrectItem content;
|
||||
private float originSize;
|
||||
private WdColor originColor;
|
||||
private WdColor originBackgroundColor;
|
||||
public string Name { get; set; }
|
||||
public int DocumentId { get; set; }
|
||||
|
||||
public ProofreadItem(CorrectedContent content,int documentId)
|
||||
public ProofreadItem(CorrectItem content,int documentId)
|
||||
{
|
||||
this.content = content;
|
||||
this.DocumentId = documentId;
|
||||
@ -28,10 +28,10 @@ namespace UtilLib
|
||||
|
||||
private void SetMarkName()
|
||||
{
|
||||
this.Name = this.mark != null ? mark.Name : Config.BuildBookmarkName(content.id);
|
||||
this.Name = this.mark != null ? mark.Name : Config.BuildBookmarkName(content.Id);
|
||||
}
|
||||
|
||||
public ProofreadItem(CorrectedContent content, Bookmark bookmark, int documentId)
|
||||
public ProofreadItem(CorrectItem content, Bookmark bookmark, int documentId)
|
||||
{
|
||||
this.DocumentId = documentId;
|
||||
this.content = content;
|
||||
@ -52,13 +52,13 @@ namespace UtilLib
|
||||
{
|
||||
// 创建mark
|
||||
this.mark = bookmark != null ? bookmark
|
||||
: DocumentUtil.AddBookmark(content.tag == "i" ? null : content.color, content.start, content.end);
|
||||
: DocumentUtil.AddBookmark(content.Tag == "i" ? null : content.Color, content.Start, content.End);
|
||||
if (mark != null)
|
||||
{
|
||||
// 记录目前字体
|
||||
originSize = mark.Range.Font.Size;
|
||||
// 设置名称
|
||||
mark.Name = Config.BuildBookmarkName(content.id);
|
||||
mark.Name = Config.BuildBookmarkName(content.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ namespace UtilLib
|
||||
private void OnMarkSelected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
|
||||
{
|
||||
//throw new System.NotImplementedException();
|
||||
Bridge.bridge.SelectMarkById(content.id,DocumentId);
|
||||
Bridge.bridge.SelectMarkById(content.Id,DocumentId);
|
||||
}
|
||||
|
||||
public void Select()
|
||||
@ -102,7 +102,7 @@ namespace UtilLib
|
||||
{
|
||||
if (mark == null) return;
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
||||
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.color));
|
||||
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.Color));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -133,14 +133,14 @@ namespace UtilLib
|
||||
|
||||
if (mark == null) return;
|
||||
//
|
||||
content.isAccept = status;
|
||||
content.IsAccept = status;
|
||||
if (status == AcceptStatus.Accept)
|
||||
{
|
||||
if (content.tag == "r" || content.tag == "i")
|
||||
if (content.Tag == "r" || content.Tag == "i")
|
||||
{
|
||||
mark.Text = content.text;
|
||||
mark.Text = content.Text;
|
||||
}
|
||||
else if (content.tag == "d")
|
||||
else if (content.Tag == "d")
|
||||
{
|
||||
mark.Text = "";
|
||||
}
|
||||
@ -150,20 +150,20 @@ namespace UtilLib
|
||||
{
|
||||
ResetMarkStyle();
|
||||
// 新增添加了空格 所以当忽略时还原
|
||||
if (content.tag == "i")
|
||||
if (content.Tag == "i")
|
||||
{
|
||||
mark.Text = "";
|
||||
}
|
||||
}
|
||||
else if (status == AcceptStatus.Default)
|
||||
{
|
||||
if (content.tag == "r" || content.tag == "d")
|
||||
if (content.Tag == "r" || content.Tag == "d")
|
||||
{
|
||||
mark.Text = content.origin;
|
||||
mark.Text = content.Origin;
|
||||
}
|
||||
else if (content.tag == "i")
|
||||
else if (content.Tag == "i")
|
||||
{
|
||||
mark.Text = ToolUtil.GetBlankText(content.text.Length);
|
||||
mark.Text = ToolUtil.GetBlankText(content.Text.Length);
|
||||
}
|
||||
SetMarkStyle();
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ using System.Security;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
[assembly: AssemblyVersion("1.1")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.1")]
|
||||
|
||||
|
40
AIProofread/Properties/Resources.Designer.cs
generated
40
AIProofread/Properties/Resources.Designer.cs
generated
@ -170,6 +170,46 @@ namespace AIProofread.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_refresh {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-refresh", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_refresh_wps {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-refresh-wps", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_save {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-save", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_save_wps {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-save-wps", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
|
@ -118,12 +118,20 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
|
||||
<data name="icon-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-setting-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-setting-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-logout" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-logout.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-phone-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-phone-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-user-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-user-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-setting" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-setting.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
@ -131,43 +139,46 @@
|
||||
<data name="icon-phone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-phone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-update" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-book-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-book-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-proofread-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-proofread-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-update-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-update-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-book" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-book.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-user" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-book-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-book-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-clear-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-clear-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-logout-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-logout-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-phone-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-phone-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-update" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-proofread-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-proofread-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-user" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-setting-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-setting-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-update-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-update-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-refresh-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-refresh-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-user-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-user-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icon-save" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-save-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-save-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
AIProofread/Resources/icon-refresh-wps.jpg
Normal file
BIN
AIProofread/Resources/icon-refresh-wps.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
AIProofread/Resources/icon-refresh.png
Normal file
BIN
AIProofread/Resources/icon-refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
AIProofread/Resources/icon-save-wps.jpg
Normal file
BIN
AIProofread/Resources/icon-save-wps.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
AIProofread/Resources/icon-save.png
Normal file
BIN
AIProofread/Resources/icon-save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 598 B |
32
AIProofread/Ribbon1.Designer.cs
generated
32
AIProofread/Ribbon1.Designer.cs
generated
@ -48,6 +48,9 @@ namespace AIProofread
|
||||
this.btnLogout = this.Factory.CreateRibbonButton();
|
||||
this.LblNickname = this.Factory.CreateRibbonLabel();
|
||||
this.LblDate = this.Factory.CreateRibbonLabel();
|
||||
this.Group = this.Factory.CreateRibbonGroup();
|
||||
this.ButtonSaveCache = this.Factory.CreateRibbonButton();
|
||||
this.ButtonLoadCache = this.Factory.CreateRibbonButton();
|
||||
this.grpDebug = this.Factory.CreateRibbonGroup();
|
||||
this.btnShowPane = this.Factory.CreateRibbonButton();
|
||||
this.btnHidePane = this.Factory.CreateRibbonButton();
|
||||
@ -55,12 +58,14 @@ namespace AIProofread
|
||||
this.button1 = this.Factory.CreateRibbonButton();
|
||||
this.tabAIProofread.SuspendLayout();
|
||||
this.group1.SuspendLayout();
|
||||
this.Group.SuspendLayout();
|
||||
this.grpDebug.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabAIProofread
|
||||
//
|
||||
this.tabAIProofread.Groups.Add(this.group1);
|
||||
this.tabAIProofread.Groups.Add(this.Group);
|
||||
this.tabAIProofread.Groups.Add(this.grpDebug);
|
||||
this.tabAIProofread.Label = "AI校对王";
|
||||
this.tabAIProofread.Name = "tabAIProofread";
|
||||
@ -165,6 +170,28 @@ namespace AIProofread
|
||||
this.LblDate.Name = "LblDate";
|
||||
this.LblDate.Visible = false;
|
||||
//
|
||||
// Group
|
||||
//
|
||||
this.Group.Items.Add(this.ButtonSaveCache);
|
||||
this.Group.Items.Add(this.ButtonLoadCache);
|
||||
this.Group.Name = "Group";
|
||||
//
|
||||
// ButtonSaveCache
|
||||
//
|
||||
this.ButtonSaveCache.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
this.ButtonSaveCache.Image = global::AIProofread.Properties.Resources.icon_save;
|
||||
this.ButtonSaveCache.Label = "手动保存数据";
|
||||
this.ButtonSaveCache.Name = "ButtonSaveCache";
|
||||
this.ButtonSaveCache.ShowImage = true;
|
||||
//
|
||||
// ButtonLoadCache
|
||||
//
|
||||
this.ButtonLoadCache.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
this.ButtonLoadCache.Image = global::AIProofread.Properties.Resources.icon_refresh;
|
||||
this.ButtonLoadCache.Label = "追踪历史数据";
|
||||
this.ButtonLoadCache.Name = "ButtonLoadCache";
|
||||
this.ButtonLoadCache.ShowImage = true;
|
||||
//
|
||||
// grpDebug
|
||||
//
|
||||
this.grpDebug.Items.Add(this.btnShowPane);
|
||||
@ -209,6 +236,8 @@ namespace AIProofread
|
||||
this.tabAIProofread.PerformLayout();
|
||||
this.group1.ResumeLayout(false);
|
||||
this.group1.PerformLayout();
|
||||
this.Group.ResumeLayout(false);
|
||||
this.Group.PerformLayout();
|
||||
this.grpDebug.ResumeLayout(false);
|
||||
this.grpDebug.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
@ -234,6 +263,9 @@ namespace AIProofread
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnHidePane;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnOpenLog;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton button1;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonGroup Group;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton ButtonSaveCache;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton ButtonLoadCache;
|
||||
}
|
||||
|
||||
partial class ThisRibbonCollection
|
||||
|
@ -48,11 +48,13 @@ namespace AIProofread
|
||||
btnClear.Image = AIProofread.Properties.Resources.icon_clear_wps;
|
||||
btnOpenLexicon.Image = AIProofread.Properties.Resources.icon_book_wps;
|
||||
btnSetting.Image = AIProofread.Properties.Resources.icon_setting_wps;
|
||||
|
||||
BtnGetContact.Image = AIProofread.Properties.Resources.icon_phone_wps;
|
||||
BtnUpdate.Image = AIProofread.Properties.Resources.icon_update_wps;
|
||||
btnLogin.Image = AIProofread.Properties.Resources.icon_user_wps;
|
||||
btnLogout.Image = AIProofread.Properties.Resources.icon_logout_wps;
|
||||
// 缓存相关
|
||||
ButtonLoadCache.Image = AIProofread.Properties.Resources.icon_refresh_wps;
|
||||
ButtonSaveCache.Image = AIProofread.Properties.Resources.icon_save_wps;
|
||||
}
|
||||
|
||||
public void ProcessLoginInfo(Userinfo userinfo)
|
||||
|
@ -1,17 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Word = Microsoft.Office.Interop.Word;
|
||||
using Microsoft.Office.Tools.Word;
|
||||
using AIProofread.Controls;
|
||||
using Microsoft.Office.Tools;
|
||||
using Newtonsoft.Json;
|
||||
using UtilLib;
|
||||
using System.Threading;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using AIProofread.Controls;
|
||||
using UtilLib;
|
||||
using AIProofread.Model;
|
||||
//using CustomTaskPane = Microsoft.Office.Core.CustomTaskPane;
|
||||
using CustomTaskPane = Microsoft.Office.Tools.CustomTaskPane;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -44,15 +43,27 @@ namespace AIProofread
|
||||
|
||||
public List<FormLogin> LoginFormList = new List<FormLogin>();
|
||||
|
||||
public Dictionary<Word.Document, CustomTaskPane> taskPanels = new Dictionary<Word.Document, CustomTaskPane>();
|
||||
public Dictionary<Word.Document, bool> panelsVisibleStatus = new Dictionary<Word.Document, bool>();
|
||||
public Dictionary<Word.Document, int> documentIdDics = new Dictionary<Word.Document, int>();
|
||||
public Dictionary<Document, CustomTaskPane> taskPanels = new Dictionary<Document, CustomTaskPane>();
|
||||
public Dictionary<Document, bool> panelsVisibleStatus = new Dictionary<Document, bool>();
|
||||
public Dictionary<Document, int> documentIdDics = new Dictionary<Document, int>();
|
||||
|
||||
/// <summary>
|
||||
/// 当前文档面板
|
||||
/// </summary>
|
||||
public CustomTaskPane currentDocumentTaskPane;
|
||||
/// <summary>
|
||||
/// 所有文档信息
|
||||
/// </summary>
|
||||
public Dictionary<Document, DocumentInfo> documentList = new Dictionary<Document, DocumentInfo>();
|
||||
/// <summary>
|
||||
/// 当前文档信息
|
||||
/// </summary>
|
||||
public DocumentInfo CurrentDocument { get; set; }
|
||||
|
||||
private static readonly Dictionary<Word.Document, Dictionary<int, ProofreadItem>> allMarks = new Dictionary<Word.Document, Dictionary<int, ProofreadItem>>();
|
||||
|
||||
private void Application_WindowDeactivate(Word.Document doc, Window Wn)
|
||||
private static readonly Dictionary<Document, Dictionary<int, ProofreadItem>> allMarks = new Dictionary<Document, Dictionary<int, ProofreadItem>>();
|
||||
|
||||
private void Application_WindowDeactivate(Document doc, Window Wn)
|
||||
{
|
||||
Logger.Log("Application_WindowDeactivate -- " + doc.FullName + " visible:");
|
||||
//HidePanel(Doc);
|
||||
@ -62,7 +73,7 @@ namespace AIProofread
|
||||
//}
|
||||
}
|
||||
|
||||
private void Application_WindowActivate(Word.Document activeDoc, Window Wn)
|
||||
private void Application_WindowActivate(Document activeDoc, Window Wn)
|
||||
{
|
||||
// 当前文档添加书签集合
|
||||
if (!allMarks.ContainsKey(activeDoc))
|
||||
@ -89,7 +100,7 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_DocumentBeforeClose(Word.Document currentDoc, ref bool Cancel)
|
||||
private void Application_DocumentBeforeClose(Document currentDoc, ref bool Cancel)
|
||||
{
|
||||
Logger.Log("Application_DocumentBeforeClose -- " + currentDoc.FullName);
|
||||
if (allMarks.ContainsKey(currentDoc))
|
||||
@ -100,7 +111,7 @@ namespace AIProofread
|
||||
DisposePanel(currentDoc);
|
||||
}
|
||||
|
||||
public void ActiveCurrentDocumentMarks(Word.Document document)
|
||||
public void ActiveCurrentDocumentMarks(Document document)
|
||||
{
|
||||
// 判断是否存在 没有的话初始化
|
||||
var currentDoc = document ?? Application.ActiveDocument ;
|
||||
@ -111,19 +122,19 @@ namespace AIProofread
|
||||
Bridge.marks = allMarks[currentDoc];
|
||||
}
|
||||
|
||||
private void Application_NewDocument(Word.Document Doc)
|
||||
private void Application_NewDocument(Document Doc)
|
||||
{
|
||||
Logger.Log("Application_NewDocument -- " + Doc.FullName);
|
||||
ShowPanel(Doc);
|
||||
}
|
||||
|
||||
private void Application_DocumentOpen(Word.Document Doc)
|
||||
private void Application_DocumentOpen(Document Doc)
|
||||
{
|
||||
Logger.Log("Application_DocumentOpen -- " + Doc.FullName);
|
||||
ShowPanel(Doc);
|
||||
}
|
||||
|
||||
void DisposePanel(Word.Document doc)
|
||||
void DisposePanel(Document doc)
|
||||
{
|
||||
if (panelsVisibleStatus.ContainsKey(doc))
|
||||
{
|
||||
@ -139,7 +150,7 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
void HideOtherPanel(Word.Document doc)
|
||||
void HideOtherPanel(Document doc)
|
||||
{
|
||||
if (taskPanels.ContainsKey(doc) && taskPanels[doc].Visible)
|
||||
{
|
||||
@ -156,7 +167,7 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
void HidePanel(Word.Document doc)
|
||||
void HidePanel(Document doc)
|
||||
{
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
@ -164,7 +175,7 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
private CustomTaskPane ShowPanel(Word.Document doc, bool show)
|
||||
private CustomTaskPane ShowPanel(Document doc, bool show)
|
||||
{
|
||||
|
||||
if (Application.ActiveDocument == null) return null;
|
||||
@ -199,7 +210,7 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// word创建面板
|
||||
/// </summary>
|
||||
private CustomTaskPane ShowPanel(Word.Document doc)
|
||||
private CustomTaskPane ShowPanel(Document doc)
|
||||
{
|
||||
return ShowPanel(doc, !IsWPS);
|
||||
}
|
||||
@ -325,7 +336,7 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_WindowSelectionChange(Word.Selection s)
|
||||
private void Application_WindowSelectionChange(Selection s)
|
||||
{
|
||||
if (s.Bookmarks != null)
|
||||
{
|
||||
@ -334,12 +345,13 @@ namespace AIProofread
|
||||
var count = s.Bookmarks.Count;
|
||||
if (s.Bookmarks.Count >= 1) // 只有这一个
|
||||
{
|
||||
foreach (Microsoft.Office.Interop.Word.Bookmark item in s.Bookmarks)
|
||||
foreach (Bookmark item in s.Bookmarks)
|
||||
{
|
||||
int proofreadId = Config.GetBookmarkIdByName(item.Name);
|
||||
if (proofreadId > 0)
|
||||
{
|
||||
Bridge.bridge.SelectMarkById(proofreadId,0);
|
||||
// 只选择第一个书签
|
||||
// TODO: 优化
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
7
AIProofread/Transform.cs
Normal file
7
AIProofread/Transform.cs
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
public class Transform
|
||||
{
|
||||
}
|
||||
}
|
@ -173,13 +173,13 @@ namespace AIProofread
|
||||
/// <param name="document"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <returns></returns>
|
||||
public static Range FindRange(CorrectedContent correct, DocumentCorrectItem sentense,ref int prevOffset, Microsoft.Office.Interop.Word.Document document, Range range)
|
||||
public static Range FindRange(CorrectItem correct, CorrectContext sentense,ref int prevOffset, Microsoft.Office.Interop.Word.Document document, Range range)
|
||||
{
|
||||
var paragraphText = range.Text;
|
||||
|
||||
string findText = correct.origin;
|
||||
int wordStart = correct.start;
|
||||
int wordEnd = correct.end;
|
||||
string findText = correct.Origin;
|
||||
int wordStart = correct.Start;
|
||||
int wordEnd = correct.End;
|
||||
|
||||
int offset = sentense.SentenceOffset;
|
||||
string originText = sentense.Insert;
|
||||
@ -293,13 +293,13 @@ namespace AIProofread
|
||||
|
||||
|
||||
|
||||
public static Bookmark FindRangeAndCreateBookmark(CorrectedContent correct, DocumentCorrectItem sentense, Microsoft.Office.Interop.Word.Document document, ref int prevOffset)
|
||||
public static Bookmark FindRangeAndCreateBookmark(CorrectItem correct, CorrectContext sentense, Microsoft.Office.Interop.Word.Document document, ref int prevOffset)
|
||||
{
|
||||
Bookmark bookmark = null;
|
||||
try
|
||||
{
|
||||
ControlCollection controls = Globals.Factory.GetVstoObject(document).Controls;
|
||||
var markName = Config.BuildBookmarkName(correct.id);
|
||||
var markName = Config.BuildBookmarkName(correct.Id);
|
||||
|
||||
// 判断是否已经存在
|
||||
if (controls.Contains(markName))
|
||||
@ -331,7 +331,7 @@ namespace AIProofread
|
||||
return bookmark;
|
||||
}
|
||||
|
||||
private static Range FindRangeByCorrect(DocumentCorrectItem c, CorrectedContent item, Paragraph paragraph, Microsoft.Office.Interop.Word.Document document, int prevOffset)
|
||||
private static Range FindRangeByCorrect(CorrectContext c, CorrectItem item, Paragraph paragraph, Microsoft.Office.Interop.Word.Document document, int prevOffset)
|
||||
{
|
||||
var paraRange = paragraph.Range;
|
||||
var paraText = paraRange.Text;
|
||||
@ -343,26 +343,26 @@ namespace AIProofread
|
||||
var sentence = paraText.Substring(c.SentenceOffset, c.InsertLength);
|
||||
if (sentence == c.Insert)
|
||||
{ // 比对原始内容与校对原文是否一致
|
||||
var range = document.Range(offset + item.start, offset + item.end);
|
||||
var range = document.Range(offset + item.Start, offset + item.End);
|
||||
//
|
||||
if (range.Text == item.origin) return range;
|
||||
if (range.Text == item.Origin) return range;
|
||||
}
|
||||
|
||||
var originText = c.Insert;
|
||||
// 如果是新增 则查找定位
|
||||
if (item.tag == "i")
|
||||
if (item.Tag == "i")
|
||||
{
|
||||
// 找前缀
|
||||
var prefix1 = item.start > 2 ? (
|
||||
item.start > INSERT_FIND_OFFSET
|
||||
? originText.Substring(item.start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, item.start)
|
||||
var prefix1 = item.Start > 2 ? (
|
||||
item.Start > INSERT_FIND_OFFSET
|
||||
? originText.Substring(item.Start - INSERT_FIND_OFFSET, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(0, item.Start)
|
||||
) : null;
|
||||
// 找后缀
|
||||
var suffix1 = prefix1 == null ? (
|
||||
item.end + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(item.start, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(item.start, originText.Length - item.start)
|
||||
item.End + INSERT_FIND_OFFSET < originText.Length
|
||||
? originText.Substring(item.Start, INSERT_FIND_OFFSET)
|
||||
: originText.Substring(item.Start, originText.Length - item.Start)
|
||||
) : null;
|
||||
// 偏移量
|
||||
var start1 = prefix1 != null || suffix1 != null
|
||||
@ -376,8 +376,8 @@ namespace AIProofread
|
||||
}
|
||||
|
||||
// 执行查找
|
||||
int wordStart = item.start;
|
||||
int wordEnd = item.end;
|
||||
int wordStart = item.Start;
|
||||
int wordEnd = item.End;
|
||||
|
||||
// 找前缀
|
||||
var prefix = wordStart > 2 ? (
|
||||
@ -399,14 +399,14 @@ namespace AIProofread
|
||||
{
|
||||
var findOffset = paraRange.Start + start + (prefix != null ? prefix.Length : 0);
|
||||
var range = document.Range(findOffset, findOffset + wordEnd - wordStart);
|
||||
if (range.Text == item.origin) { return range; }
|
||||
if (range.Text == item.Origin) { return range; }
|
||||
}
|
||||
// 直接定位查找
|
||||
start = paraText.IndexOf(item.origin, prevOffset);
|
||||
start = paraText.IndexOf(item.Origin, prevOffset);
|
||||
if (start == -1) return null;
|
||||
// 定位整体开始位置
|
||||
start = paraStart + start;
|
||||
return document.Range(start, start + item.origin.Length);
|
||||
return document.Range(start, start + item.Origin.Length);
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
4c1c6aa096bd384197619062b3689b9a218de9da2c1b7adc250936855349c9f3
|
||||
11c03afee37eea7e40c8b52f8e997c1261df45d7ed4e6445471b049c699b20a7
|
||||
|
@ -22,8 +22,8 @@ C:\Users\home-dev\source\repos\WordAddInTest2024\WordAddInTest2024\bin\Debug\Mic
|
||||
C:\Users\home-dev\source\repos\WordAddInTest2024\WordAddInTest2024\obj\Debug\AIProofread.csproj.CopyComplete
|
||||
C:\Users\home-dev\source\repos\WordAddInTest2024\WordAddInTest2024\obj\Debug\AIProofread.dll
|
||||
C:\Users\home-dev\source\repos\WordAddInTest2024\WordAddInTest2024\obj\Debug\AIProofread.pdb
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\runtimes\win-x64\native\WebView2Loader.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\runtimes\win-x86\native\WebView2Loader.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\runtimes\win-x64\native\WebView2Loader.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\runtimes\win-arm64\native\WebView2Loader.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.pdb
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -119,7 +119,10 @@ namespace updater
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
|
||||
| SecurityProtocolType.Tls
|
||||
| SecurityProtocolType.Tls11
|
||||
| SecurityProtocolType.Tls12;
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(UpgradeInfoURI + "api/v1/common/download/version");
|
||||
HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||
// 获取响应内容
|
||||
|
@ -10,8 +10,23 @@
|
||||
<AssemblyName>updater</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -50,16 +65,13 @@
|
||||
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AntdUI, Version=1.5.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>D:\libs\CSharp_AntdUI\net46\AntdUI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@ -116,5 +128,17 @@
|
||||
<ItemGroup>
|
||||
<Content Include="av802-h1xg6-001.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.6.2 %28x86 和 x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
13
updater/updater.csproj.user
Normal file
13
updater/updater.csproj.user
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory>publish\</PublishUrlHistory>
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>zh-CN</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class DocumentCorrectItem
|
||||
public class CorrectContext
|
||||
{
|
||||
public string Key { get; set; }
|
||||
/// <summary>
|
||||
@ -38,6 +38,6 @@ namespace UtilLib
|
||||
/// <summary>
|
||||
/// 当前句子的校对列表项
|
||||
/// </summary>
|
||||
public List<CorrectedContent> Diffs { get; set; }
|
||||
public List<CorrectItem> CorrectItems { get; set; }
|
||||
}
|
||||
}
|
@ -1,31 +1,33 @@
|
||||
namespace UtilLib
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class CorrectedContent
|
||||
public class CorrectItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 校对类别()
|
||||
/// </summary>
|
||||
public string tag { get; set; }
|
||||
public string Tag { get; set; }
|
||||
/// <summary>
|
||||
/// 校对原始文本
|
||||
/// </summary>
|
||||
public string origin { get; set; }
|
||||
public string Origin { get; set; }
|
||||
/// <summary>
|
||||
/// 校对文本
|
||||
/// </summary>
|
||||
public string text { get; set; }
|
||||
public string Text { get; set; }
|
||||
/// <summary>
|
||||
/// 校对项在句子中的开始位置
|
||||
/// </summary>
|
||||
public int start { get; set; }
|
||||
public int Start { get; set; }
|
||||
/// <summary>
|
||||
/// 校对项在句子中的结束位置
|
||||
/// </summary>
|
||||
public int end { get; set; }
|
||||
public int End { get; set; }
|
||||
/// <summary>
|
||||
/// 校对项ID
|
||||
/// </summary>
|
||||
public int id { get; set; }
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 校对项索引
|
||||
/// </summary>
|
||||
@ -33,14 +35,15 @@
|
||||
/// <summary>
|
||||
/// 校对所属分类
|
||||
/// </summary>
|
||||
public int type { get; set; }
|
||||
public int Type { get; set; }
|
||||
/// <summary>
|
||||
/// 校对状态
|
||||
/// </summary>
|
||||
public int isAccept { get; set; }
|
||||
[JsonProperty("is_accept")]
|
||||
public int IsAccept { get; set; }
|
||||
/// <summary>
|
||||
/// 校对项颜色
|
||||
/// </summary>
|
||||
public string color { get; set; }
|
||||
public string Color { get; set; }
|
||||
}
|
||||
}
|
@ -57,8 +57,8 @@
|
||||
<Compile Include="AcceptEnum.cs" />
|
||||
<Compile Include="AppConfig.cs" />
|
||||
<Compile Include="Colors.cs" />
|
||||
<Compile Include="CorrectedContent.cs" />
|
||||
<Compile Include="DocumentCorrectItem.cs" />
|
||||
<Compile Include="CorrectItem.cs" />
|
||||
<Compile Include="CorrectContext.cs" />
|
||||
<Compile Include="ProofreadType.cs" />
|
||||
<Compile Include="UpdateModel.cs" />
|
||||
<Compile Include="UpgradeData.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user