2 using System.Collections.Generic;
6 using Word = Microsoft.Office.Interop.Word;
7 using Office = Microsoft.Office.Core;
8 using Microsoft.Office.Tools.Word;
9 using Microsoft.Office.Interop.Word;
13 using Microsoft.Office.Core;
14 using System.Diagnostics;
16 using System.Collections;
59 return base.RequestService(serviceGuid);
65 int n = sel.ContentControls.Count;
66 Microsoft.Office.Interop.Word.ContentControl cp = sel.Range.ParentContentControl;
68 String mytitle =
null;
76 if (mytitle ==
"violet")
78 Debug.WriteLine(
"control selected " + sid);
82 CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(xid);
83 string xml = xmlpart.XML;
117 Microsoft.Office.Interop.Word.Selection selection = this.
Application.Selection;
118 if (selection !=
null && selection.Range !=
null)
120 WdSelectionType sel = selection.Type;
128 MemoryStream ms =
new MemoryStream(_utility.
BitmapBytes);
133 Image _drawnimage = Image.FromStream(ms);
151 Microsoft.Office.Interop.Word.ContentControl cp2 = selection.Range.ParentContentControl;
158 CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(cp2.Tag);
169 CustomXMLPart cp = vstoDocument.CustomXMLParts.Add(_utility.
xml);
172 PictureContentControl piccontrol = vstoDocument.Controls.AddPictureContentControl(selection.Range, Guid.NewGuid().ToString());
173 piccontrol.Image = _drawnimage;
174 piccontrol.Title =
"violet";
175 piccontrol.Tag = cp.Id;
190 public static Image
ScaleImage(Image image,
int maxWidth,
int maxHeight)
192 var ratioX = (double)maxWidth / image.Width;
193 var ratioY = (
double)maxHeight / image.Height;
194 var ratio = Math.Min(ratioX, ratioY);
196 var newWidth = (int)(image.Width * ratio);
197 var newHeight = (int)(image.Height * ratio);
199 var newImage =
new Bitmap(newWidth, newHeight);
200 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)