添加选择功能
This commit is contained in:
parent
9b55e8b683
commit
a4bdf235ce
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,22 +9,24 @@ namespace TestWordAddIn1
|
||||
public partial class ProofreadItem : UserControl
|
||||
{
|
||||
|
||||
private readonly Color BG_NORMAL = Color.WhiteSmoke;
|
||||
private readonly Color BG_HOVER = Color.AliceBlue;
|
||||
private readonly Color BG_ACTIVE = Color.AliceBlue;
|
||||
private readonly Color BG_NORMAL = Colors.FromHex("f9f8f8");
|
||||
private readonly Color BG_HOVER = Colors.FromHex("b7dde8");
|
||||
private readonly Color BG_ACTIVE = Colors.FromHex("b7dde8");
|
||||
private DiffItem diffItem;
|
||||
private int currentStart;
|
||||
private Document document;
|
||||
private Bookmark bookmark;
|
||||
private Microsoft.Office.Tools.Word.Document document;
|
||||
private Microsoft.Office.Tools.Word.Bookmark bookmark;
|
||||
private bool processed = false;
|
||||
|
||||
public ProofreadItem()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.BackColor = BG_NORMAL;
|
||||
this.document = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
this.document = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);
|
||||
this.Click += ProofreadItem_Click1;
|
||||
}
|
||||
|
||||
|
||||
private void ProofreadItem_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
this.BackColor = BG_HOVER;
|
||||
@ -37,11 +39,6 @@ namespace TestWordAddIn1
|
||||
Console.WriteLine("ProofreadItem_MouseLeave");
|
||||
}
|
||||
|
||||
private void ProofreadItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.BackColor = BG_ACTIVE;
|
||||
Console.WriteLine("ProofreadItem_Click");
|
||||
}
|
||||
private void AddBookmark(Color color)
|
||||
{
|
||||
int rangeStart = this.currentStart + this.diffItem.Start,
|
||||
@ -49,13 +46,34 @@ namespace TestWordAddIn1
|
||||
|
||||
Range r = this.document.Range(rangeStart, rangeEnd);
|
||||
|
||||
this.bookmark = this.document.Bookmarks.Add("mark_" + this.diffItem.Id, r);
|
||||
this.bookmark = this.document.Controls.AddBookmark(r,"mark_" + this.diffItem.Id);
|
||||
this.bookmark.Selected += Bookmark_Selected;
|
||||
if (this.diffItem.Tag != "i")
|
||||
{
|
||||
r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(color);
|
||||
}
|
||||
}
|
||||
|
||||
private void Bookmark_Selected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
|
||||
{
|
||||
this.BackColor = BG_ACTIVE;
|
||||
}
|
||||
private void ProofreadItem_Click1(object sender, EventArgs e)
|
||||
{
|
||||
if(this.BackColor == BG_ACTIVE)
|
||||
{
|
||||
this.BackColor = BG_NORMAL;
|
||||
return;
|
||||
}
|
||||
if (this.diffItem == null || this.bookmark == null
|
||||
|| (this.diffItem.IsAccept == AcceptEnum.Accept && this.diffItem.Tag == "d"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.bookmark.Select();
|
||||
this.BackColor = BG_ACTIVE;
|
||||
}
|
||||
|
||||
public void SetProofreadItem(DiffItem it, int start)
|
||||
{
|
||||
this.diffItem = it;
|
||||
@ -120,7 +138,8 @@ namespace TestWordAddIn1
|
||||
{
|
||||
if (this.diffItem.IsAccept != AcceptEnum.Default) return;
|
||||
this.diffItem.IsAccept = AcceptEnum.Ignore;
|
||||
this.bookmark.Range.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||
//this.bookmark.Range.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||
this.bookmark.Range.Shading.BackgroundPatternColorIndex = WdColorIndex.wdAuto;
|
||||
MessageBox.Show("忽略" + this.currentStart + this.diffItem.Text);
|
||||
this.ProcessView();
|
||||
}
|
||||
@ -130,7 +149,8 @@ namespace TestWordAddIn1
|
||||
if (this.diffItem.IsAccept != AcceptEnum.Default) return;
|
||||
this.diffItem.IsAccept = AcceptEnum.Accept;
|
||||
var rng = this.bookmark.Range;
|
||||
rng.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||
//rng.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||
rng.Shading.BackgroundPatternColorIndex = WdColorIndex.wdAuto;
|
||||
if (this.diffItem.Tag == "d")
|
||||
{
|
||||
rng.Delete();
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user