-
Notifications
You must be signed in to change notification settings - Fork 1
/
RefTaskPane.cs
136 lines (117 loc) · 4 KB
/
RefTaskPane.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Drawing;
using System.Windows.Forms;
namespace PaperWriting
{
public partial class RefTaskPane : UserControl
{
private Properties.Settings Settings=Properties.Settings.Default;
public RefTaskPane()
{
InitializeComponent();
}
/// <summary>
/// 刷新。
/// </summary>
public void RefreshContent()
{
try
{
hyperref.Checked = Settings.HyperRef;
var previews = Globals.ThisAddIn.GetReferencePreviews();
imageList.Images.Clear();
QuotableContents.Clear();
foreach (var preview in previews)
{
imageList.Images.Add(preview.Bookmark.Name, preview.Image);
ListViewItem item = new ListViewItem();
item.Text = preview.Text;
item.ImageKey = preview.Bookmark.Name;
item.Group = QuotableContents.Groups[(int)preview.Group];
item.Tag = preview.Bookmark.Name;
item.ToolTipText = "双击即可引用";
QuotableContents.Items.Add(item);
}
}
catch (Exception) { }
}
private void refresh_Click(object sender, EventArgs e)
{
RefreshContent();
}
private void RefTaskPane_VisibleChanged(object sender, EventArgs e)
{
if (Visible == true)
RefreshContent();
}
private void insert_Click(object sender, EventArgs e)
{
insert_selected();
}
private void insert_selected()
{
foreach (var selectedItem in QuotableContents.SelectedItems)
{
Globals.ThisAddIn.AddRef((string)((ListViewItem)selectedItem).Tag, hyperref.Checked);
}
}
/// <summary>
/// 删除所选。
/// </summary>
private void delete_selected()
{
foreach (var selectedItem in QuotableContents.SelectedItems)
{
Globals.ThisAddIn.RemoveBookmark((string)((ListViewItem)selectedItem).Tag);
QuotableContents.Items.Remove((ListViewItem)selectedItem);
}
}
private void delete_Click(object sender, EventArgs e)
{
delete_selected();
}
private void QuotableContents_DoubleClick(object sender, EventArgs e)
{
insert_selected();
}
private void 引用选中项ToolStripMenuItem_Click(object sender, EventArgs e)
{
insert_selected();
}
private void 删除选中项ToolStripMenuItem_Click(object sender, EventArgs e)
{
delete_selected();
}
private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
{
RefreshContent();
}
private void onKeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space)
{
insert_selected();
}
}
private void hyperref_CheckedChanged(object sender, EventArgs e)
{
Globals.ThisAddIn.Settings.HyperRef = hyperref.Checked;
}
private void btn_MouseDown(object sender, MouseEventArgs e)
{
((Button)sender).FlatAppearance.BorderColor = Color.FromArgb(62, 109, 181);
}
private void btn_MouseUp(object sender, MouseEventArgs e)
{
((Button)sender).FlatAppearance.BorderColor = Color.FromArgb(163, 189, 227);
}
private void btn_MouseEnter(object sender, EventArgs e)
{
((Button)sender).FlatAppearance.BorderColor = Color.FromArgb(163, 189, 227);
}
private void btn_MouseLeave(object sender, EventArgs e)
{
((Button)sender).FlatAppearance.BorderColor = Color.FromArgb(171,171,171);
}
}
}