2 using System.Collections.Generic;
11 using System.Xml.Linq;
12 using Word = Microsoft.Office.Interop.Word;
13 using Office = Microsoft.Office.Core;
14 using Microsoft.Office.Tools.Word;
15 using Microsoft.Office.Interop.Word;
19 using Microsoft.Office.Core;
20 using System.Diagnostics;
22 using System.Collections;
26 public partial class ThisAddIn
63 return base.RequestService(serviceGuid);
69 int n = sel.ContentControls.Count;
70 Microsoft.Office.Interop.Word.ContentControl cp = sel.Range.ParentContentControl;
72 String mytitle =
null;
80 if (mytitle ==
"violet")
82 Debug.WriteLine(
"control selected " + sid);
86 CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(xid);
87 string xml = xmlpart.XML;
121 Microsoft.Office.Interop.Word.Selection selection = this.
Application.Selection;
122 if (selection !=
null && selection.Range !=
null)
124 WdSelectionType sel = selection.Type;
132 MemoryStream ms =
new MemoryStream(_utility.
BitmapBytes);
137 Image _drawnimage = Image.FromStream(ms);
155 Microsoft.Office.Interop.Word.ContentControl cp2 = selection.Range.ParentContentControl;
162 CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(cp2.Tag);
173 CustomXMLPart cp = vstoDocument.CustomXMLParts.Add(_utility.
xml);
176 PictureContentControl piccontrol = vstoDocument.Controls.AddPictureContentControl(selection.Range, Guid.NewGuid().ToString());
177 piccontrol.Image = _drawnimage;
178 piccontrol.Title =
"violet";
179 piccontrol.Tag = cp.Id;
193 public static Image
ScaleImage(Image image,
int maxWidth,
int maxHeight)
198 var ratioX = (double)maxWidth;
199 var ratioY = (double)maxHeight;
200 var ratio = Math.Min(ratioX, ratioY);
202 var newWidth = (int)(image.Width * ratio);
203 var newHeight = (int)(image.Height * ratio);
205 var newImage =
new Bitmap(newWidth, newHeight);
206 Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
Microsoft.Office.Interop.Word Word
internal void AddPictureContentControl(Utility _utility)
static Image ScaleImage(Image image, int maxWidth, int maxHeight)
void ThisAddIn_Startup(object sender, System.EventArgs e)
static internal ThisRibbonCollection Ribbons
void Application_DocumentBeforeSave(Word.Document doc, ref bool SaveAsUI, ref bool Cancel)
internal Microsoft.Office.Interop.Word.Application Application
override object RequestService(Guid serviceGuid)
使UNIX上開發的C程式移植到windows上 /summary>
static internal global::Microsoft.Office.Tools.Word.ApplicationFactory Factory
void Application_WindowBeforeDoubleClick(Selection sel, ref bool Cancel)
void initPath(string xml)
載入圖片
Microsoft.Office.Core Office
void InternalStartup()
此為設計工具支援所需的方法 - 請勿使用程式碼編輯器 修改這個方法的內容。
void ThisAddIn_Shutdown(object sender, System.EventArgs e)