-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
112 lines (98 loc) · 4.37 KB
/
Main.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
using Microsoft.Office.Tools.Ribbon;
using System;
namespace PaperWriting
{
public partial class Main
{
private Properties.Settings Settings = Properties.Settings.Default;
private void inmaths_Click(object sender, RibbonControlEventArgs e) => Globals.ThisAddIn.InsertNumberedMath();
private void insert_figs_ButtonClick(object sender, RibbonControlEventArgs e)
{
int widthlimit = -1;
try
{
if (this.widthlimit.Text != "")
{
widthlimit = int.Parse(this.widthlimit.Text);
}
}
catch (FormatException) { }
if (((RibbonControl)sender).Id == "from_file" || ((RibbonControl)sender).Id == "insert_figs")
{
Globals.ThisAddIn.InsertFigureFromFile(ref widthlimit);
}
else if (((RibbonControl)sender).Id == "from_clipboard")
{
Globals.ThisAddIn.InsertFigureFromClipboard(ref widthlimit);
}
}
private void insert_label_ButtonClick(object sender, RibbonControlEventArgs e)
{
if (((RibbonControl)sender).Id == "figlabel")
{
AddinUtility.InsertContent(Settings.Figure, Settings.FigureStyle);
}
else if (((RibbonControl)sender).Id == "tablelabel" || ((RibbonControl)sender).Id == "insert_label")
{
AddinUtility.InsertContent(Settings.Table, Settings.TableStyle);
}
}
private void addQuote_ItemsLoading(object sender, RibbonControlEventArgs e)
{
addQuote.Items.Clear();
foreach (var quoteItem in Globals.ThisAddIn.GetReferencePreviews())
{
RibbonDropDownItem item = this.Factory.CreateRibbonDropDownItem();
item.Label = quoteItem.Text;
item.Image = quoteItem.Image;
item.Tag = quoteItem.Bookmark.Name;
addQuote.Items.Add(item);
}
}
private void addQuote_Click(object sender, RibbonControlEventArgs e) => Globals.ThisAddIn.AddRef((string)addQuote.SelectedItem.Tag);
private void widthlimit_TextChanged(object sender, RibbonControlEventArgs e)
{
if (widthlimit.Text != "" && !int.TryParse(widthlimit.Text, out _))
widthlimit.Text = "";
Settings.WidthLimit = widthlimit.Text;
}
private void quotes_DialogLauncherClick(object sender, RibbonControlEventArgs e) => Globals.ThisAddIn.refTaskPane_pane.Visible = !Globals.ThisAddIn.refTaskPane_pane.Visible;
private void addQuote_ButtonClick(object sender, RibbonControlEventArgs e)
{
if (e.Control.Id == "show_refTaskPane")
Globals.ThisAddIn.refTaskPane_pane.Visible = !Globals.ThisAddIn.refTaskPane_pane.Visible;
}
private void Main_Load(object sender, RibbonUIEventArgs e)
{
widthlimit.Text = Settings.WidthLimit;
}
private void Insert_DialogLauncherClick(object sender, RibbonControlEventArgs e)
{
if (Globals.ThisAddIn.settingsForm.IsDisposed) Globals.ThisAddIn.settingsForm = new SettingsForm();
Globals.ThisAddIn.settingsForm.Show();
Globals.ThisAddIn.settingsForm.Focus();
}
private void headers_ButtonClick(object sender, RibbonControlEventArgs e)
{
if (Settings.InsertToAnotherParagraph) Globals.ThisAddIn.Application.Selection.TypeParagraph();
var sender_ = (RibbonButton)sender;
switch (sender_.Name)
{
case "h1":
AddinUtility.InsertContent(Settings.Header1, Settings.Header1Style);
break;
case "h2":
AddinUtility.InsertContent(Settings.Header2, Settings.Header2Style);
break;
case "h3":
AddinUtility.InsertContent(Settings.Header3, Settings.Header3Style);
break;
}
}
private void makequotable_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.Application.ActiveDocument.Bookmarks.Add(AddinUtility.GenerateBookmarkName(), Globals.ThisAddIn.Application.Selection);
Globals.ThisAddIn.refTaskPane.RefreshContent();
}
}
}