116 lines
3.6 KiB
C#
116 lines
3.6 KiB
C#
|
|
using System;
|
|
using System.Drawing;
|
|
using AIProofread;
|
|
using Microsoft.Office.Interop.Word;
|
|
using Bookmark = Microsoft.Office.Tools.Word.Bookmark;
|
|
|
|
namespace UtilLib
|
|
{
|
|
public class ProofreadItem
|
|
{
|
|
public Bookmark mark;
|
|
private CorrectedContent content;
|
|
private float originSize;
|
|
|
|
public ProofreadItem(CorrectedContent content)
|
|
{
|
|
this.content = content;
|
|
InitBookMark();
|
|
}
|
|
|
|
private void InitBookMark()
|
|
{
|
|
// 创建mark
|
|
this.mark = DocumentUtil.AddBookmark(
|
|
content.tag == "i" ? null : content.color,
|
|
content.start, content.end
|
|
);
|
|
if (mark != null)
|
|
{
|
|
// 记录目前字体
|
|
originSize = mark.Range.Font.Size;
|
|
// 设置下划线
|
|
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
|
// 设置名称
|
|
mark.Name = Config.BuildBookmarkName(content.id);
|
|
//mark.Selected += OnMarkSelected;
|
|
//mark.SelectionChange += OnMarkSelectionChange;
|
|
}
|
|
}
|
|
|
|
private void OnMarkSelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
|
|
{
|
|
//throw new System.NotImplementedException();
|
|
//mark.Range.Font.Size = originSize;
|
|
Console.WriteLine("xxx");
|
|
}
|
|
|
|
private void OnMarkSelected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
|
|
{
|
|
//throw new System.NotImplementedException();
|
|
mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体
|
|
}
|
|
|
|
public void Select()
|
|
{
|
|
if (mark != null)
|
|
{
|
|
mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体
|
|
}
|
|
}
|
|
public void UnSelect()
|
|
{
|
|
if (mark != null)
|
|
{
|
|
mark.Range.Font.Size = originSize; // 还原
|
|
}
|
|
}
|
|
|
|
private void SetMarkStyle()
|
|
{
|
|
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
|
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.color));
|
|
}
|
|
|
|
private void ResetMarkStyle()
|
|
{
|
|
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
|
mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
|
}
|
|
|
|
public void Process(int status)
|
|
{
|
|
//
|
|
content.isAccept = status;
|
|
if (status == AcceptStatus.Accept)
|
|
{
|
|
if(content.tag == "r" || content.tag == "i")
|
|
{
|
|
mark.Text = content.text;
|
|
}else if (content.tag == "d")
|
|
{
|
|
mark.Text = "\u200C";
|
|
}
|
|
ResetMarkStyle();
|
|
}
|
|
else if (status == AcceptStatus.Review || status == AcceptStatus.Ignore)
|
|
{
|
|
ResetMarkStyle();
|
|
}
|
|
else if (status == AcceptStatus.Default)
|
|
{
|
|
if (content.tag == "r" || content.tag == "d")
|
|
{
|
|
mark.Text = content.origin;
|
|
}
|
|
else if(content.tag == "i")
|
|
{
|
|
mark.Text = "\u200C";
|
|
}
|
|
SetMarkStyle();
|
|
}
|
|
}
|
|
}
|
|
}
|