-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRibbon.cs
97 lines (84 loc) · 2.94 KB
/
Ribbon.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
using FlexConfirmMail.Dialog;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Media;
using System.Windows.Interop;
using Office = Microsoft.Office.Core;
namespace FlexConfirmMail
{
[ComVisible(true)]
public class Ribbon : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
public Ribbon()
{
}
public virtual object Ribbon_LoadImage(string imageName)
{
switch (imageName)
{
case "logo.png":
return Properties.Resources.logo;
}
return null;
}
public string Ribbon_LoadLabel(Office.IRibbonControl Control)
{
switch (Control.Id)
{
case "GroupFlexConfirmMail":
return Properties.Resources.RibbonGroupFlexConfirmMail;
case "ButtonFlexConfirmMail":
return Properties.Resources.RibbonButtonFlexConfirmMail;
}
return "";
}
#region IRibbonExtensibility のメンバー
public string GetCustomUI(string ribbonID)
{
if (ribbonID == "Microsoft.Outlook.Explorer")
{
return GetResourceText("FlexConfirmMail.Ribbon.xml");
}
return "";
}
#endregion
#region リボンのコールバック
//ここでコールバック メソッドを作成します。コールバック メソッドの追加について詳しくは https://go.microsoft.com/fwlink/?LinkID=271226 をご覧ください
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
}
#endregion
public void OnClickConfig(Office.IRibbonControl control)
{
// Some users reported that Intel Graphic + Win10 causes
// a blank screen. Diable Hardware Accerelation.
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
new ConfigDialog().ShowDialog();
}
#region ヘルパー
private static string GetResourceText(string resourceName)
{
Assembly asm = Assembly.GetExecutingAssembly();
string[] resourceNames = asm.GetManifestResourceNames();
for (int i = 0; i < resourceNames.Length; ++i)
{
if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
{
using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
{
if (resourceReader != null)
{
return resourceReader.ReadToEnd();
}
}
}
}
return null;
}
#endregion
}
}