コード例 #1
0
        private void ManuallySetImage(Document doc, ContentControl cc, Title title)
        {
            cc.LockContents = false;
            PictureContentControl pcc = null;

            foreach (var obj in doc.Controls)
            {
                if (obj is PictureContentControl)
                {
                    var tempPcc = obj as PictureContentControl;
                    if (tempPcc.ID == cc.ID)
                    {
                        pcc = tempPcc;
                        break;
                    }
                }
            }

            if (pcc == null)
            {
                pcc = doc.Controls.AddPictureContentControl(cc, cc.ID);
            }
            var newImage = GetBitmapFromUrl(title.BoxArt.LargeUrl);

            if (newImage != null)
            {
                pcc.Image = newImage;
                pcc.InnerObject.Range.InlineShapes[1].LockAspectRatio = MsoTriState.msoTrue;
                pcc.InnerObject.Range.InlineShapes[1].Width           = 128F;
            }
        }
コード例 #2
0
        public void Click_AddTables(Office.IRibbonControl ctrl)
        {
            //object start = 0;
            //object end = 0;

            //Microsoft.Office.Interop.Word.Range tableLocation = Globals.ThisAddIn.Application.ActiveDocument.Range(ref start, ref end);

            //testTable = Globals.ThisAddIn.Application.ActiveDocument.Tables.Add(tableLocation, 3, 3);
            //testTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDouble;

            //WordControls.Button btn;
            WordTools.Document doc = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);
            if (!doc.Controls.Contains("TTTT"))
            {
                WinForm.Button btnFrm = new System.Windows.Forms.Button();
                btnFrm.Text      = "点击";
                btnFrm.Click    += BtnFrm_Click;
                btnFrm.Name      = "btnTest";
                btnFrm.BackColor = System.Drawing.Color.Black;
                btnFrm.ForeColor = System.Drawing.Color.Yellow;
                doc.Controls.AddControl(btnFrm, Globals.ThisAddIn.Application.ActiveDocument.Paragraphs[1].Range, 100, 30, "TTTT");
            }
            else
            {
                (doc.Controls["TTTT"] as WinForm.Button).Visible = true;
            }
        }
コード例 #3
0
ファイル: ThisAddIn.cs プロジェクト: MrMCMax/embedInFile
 private Tools.ContentControl AddTextControlAtSelection(string name)
 {
     Tools.Document       vstoDoc = Globals.Factory.GetVstoObject(activeDoc());
     Tools.ContentControl cc      = vstoDoc.Controls.AddContentControl(name,
                                                                       Word.WdContentControlType.wdContentControlRichText);
     return(cc);
 }
コード例 #4
0
ファイル: XslGenerator.cs プロジェクト: leonchen09/poc
        public string SaveAsXsl(HTMLDocument htmlDoc, VstoWord.Document doc)
        {
            string content = null;

            try
            {
                if (htmlDoc.hasChildNodes())
                {
                    using (MemoryStream stream = new MemoryStream())
                    {
                        using (XmlWriter xslWriter = XmlWriter.Create(stream, new XmlWriterSettings {
                            Encoding = UTF8Encoding
                        }))
                        {
                            //<?xml version="1.0" encoding = "utf-8" standalone="yes"?>
                            //<xsl:stylesheet version="1.0">
                            xslWriter.WriteStartXsltDocument();

                            bool indent = false;

#if DEBUG
                            indent = true;
#endif

                            //<xsl:output method="xml" indent="yes" />
                            xslWriter.WriteXslOutputElement(indent);

                            //<xsl:template match="root path"> TODO:PdwDataRootName
                            xslWriter.WriteStartXslTemplateElement(XslRootPath);

                            IEnumerable <ControlBase> controls = doc.Controls.GetValidItems();

                            GenerateWatermarkElement(htmlDoc);

                            //TODO:CONFIRM THIS FUNCTION
                            CreateHtmlTemplate(xslWriter, htmlDoc.firstChild, controls);

                            //<xsl:template />
                            xslWriter.WriteEndElement();

                            //<xsl:stylesheet />
                            xslWriter.WriteEndXsltDocument();
                        }

                        content = UTF8Encoding.GetString(stream.ToArray());

                        Debug.WriteLine(content);
                    }
                }
            }
            catch
            {
                //TODO:EXCEPTION TYPE
                throw;
            }

            return(content);
        }
コード例 #5
0
ファイル: DiagramController.cs プロジェクト: Phlaw/yuml-word
 public DiagramController()
 {
     //myCustomTaskPane.Visible = true;
     Microsoft.Office.Tools.Word.Document vstoDoc = Globals.Factory.GetVstoObject(
         Globals.ThisAddIn.Application.ActiveDocument
         );
     vstoDoc.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(
         this.ThisDocument_SelectionChange
         );
 }
コード例 #6
0
ファイル: XslGenerator.cs プロジェクト: leonchen09/poc
        public string GenXsl()
        {
            Word.Document doc = Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc;

            VstoWord.Document vstoDoc = Globals.Factory.GetVstoObject(doc);

            HTMLDocument htmlDoc = ReadHtmlDocument(_htmlFileName);

            PrepareBookmark();

            string xsl = SaveAsXsl(htmlDoc, vstoDoc);

            return(xsl);
        }
コード例 #7
0
ファイル: PdmService.cs プロジェクト: leonchen09/poc
        public void Restore(string key)
        {
            VstoWord.Document doc = _vstoDoc;

            doc.RestoreControls();

            PdmServiceProfile profile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).PdmProfile;

            foreach (var control in doc.Controls.GetValidItems())
            {
                profile.Control  = control;
                profile.IsAdding = false;

                ControlEventBinding(key);
            }
        }
コード例 #8
0
ファイル: PdmService.cs プロジェクト: leonchen09/poc
 public PdmService()
 {
     _vstoDoc = Globals.Factory.GetVstoObject(Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc);
 }