Example #1
0
        void Application_WindowBeforeDoubleClick(Selection sel, ref bool Cancel)
        {
            int n = sel.ContentControls.Count;

            Microsoft.Office.Interop.Word.ContentControl cp = sel.Range.ParentContentControl;

            String mytitle = null;
            String sid     = null;

            if (cp != null)
            {
                mytitle = cp.Title;
                sid     = cp.ID;


                if (mytitle == "violet")
                {
                    Debug.WriteLine("control selected " + sid);
                    string xid = cp.Tag;

                    Microsoft.Office.Tools.Word.Document vstoDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
                    CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(xid);
                    string        xml     = xmlpart.XML;


                    Globals.Ribbons.Ribbon1.initPath(xml);

                    Globals.Ribbons.Ribbon1.RibbonUI.ActivateTabMso("TabAddIns");
                }
            }



            //throw new NotImplementedException();
        }
Example #2
0
        internal void AddPictureContentControl(Utility _utility)
        {
            Microsoft.Office.Tools.Word.Document    vstoDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
            Microsoft.Office.Interop.Word.Selection selection    = this.Application.Selection;
            if (selection != null && selection.Range != null)
            {
                WdSelectionType sel = selection.Type;    // inlineshape



                // if (sel == WdSelectionType.wdSelectionInlineShape)
                {
                    //  InlineShapes shape = vstoDocument.InlineShapes;
                    //shape[0].
                    MemoryStream ms = new MemoryStream(_utility.BitmapBytes);



                    Image _drawnimage = Image.FromStream(ms);

                    //_drawnimage.Save("temp.jpg");
                    // Word.ContentControl contentControl = Globals.ThisAddIn.Application.ActiveDocument.SelectContentControlsByTitle(_utility.TagName)[0];
                    //foreach (Word.ContentControl contentControl in vstoDocument.Content.ContentControls)
                    {
                        //  WdContentControlType type = contentControl.Type;
                        //if (type == WdContentControlType.wdContentControlPicture && contentControl.Tag.Equals(_utility.TagName))
                        {
                            //object missing = Type.Missing;
                            //Microsoft.Office.Interop.Word.ContentControl contentControl = vstoDocument.ContentControls.Add(WdContentControlType.wdContentControlPicture,
                            //                                                          ref missing);
                            //contentControl.Range.InlineShapes.AddPicture("temp.jpg", ref missing, ref missing,
                            //                                                  ref missing);


                            //contentControl.Title = "violet";
                            Microsoft.Office.Interop.Word.ContentControl cp2 = selection.Range.ParentContentControl;

                            if (cp2 != null)//update
                            {
                                CustomXMLPart xmlpart = vstoDocument.CustomXMLParts.SelectByID(cp2.Tag);
                                xmlpart.Delete();
                                cp2.Delete();
                            }


                            CustomXMLPart cp = vstoDocument.CustomXMLParts.Add(_utility.xml);


                            PictureContentControl piccontrol = vstoDocument.Controls.AddPictureContentControl(selection.Range, Guid.NewGuid().ToString());
                            piccontrol.Image = _drawnimage;// ScaleImage(_drawnimage, 200, 150);//Save(new Bitmap(returnImage), 270, 180, 0);
                            piccontrol.Title = "violet";
                            piccontrol.Tag   = cp.Id;
                        }
                    }

                    //      vstoDocument.Save();
                    ms.Flush();
                    ms.Close();
                }
            }
        }
Example #3
0
 private void ThisDocument_ContentControlOnExit(Microsoft.Office.Interop.Word.ContentControl ContentControl, ref bool Cancel)
 {
     Debug.Print("ThisDocument_ContentControlOnExit :" + ContentControl.Title);
 }
Example #4
0
 private void ThisDocument_ContentControlOnEnter(Microsoft.Office.Interop.Word.ContentControl ContentControl)
 {
     Debug.Print("ThisDocument_ContentControlOnEnter :" + ContentControl.Title);
 }
Example #5
0
 private void ThisDocument_ContentControlBeforeStoreUpdate(Microsoft.Office.Interop.Word.ContentControl ContentControl, ref string Content)
 {
     Debug.Print("ThisDocument_ContentControlBeforeStoreUpdate :" + ContentControl.Title);
 }
Example #6
0
 private void ThisDocument_ContentControlBeforeDelete(Microsoft.Office.Interop.Word.ContentControl OldContentControl, bool InUndoRedo)
 {
     Debug.Print("ThisDocument_ContentControlBeforeDelete :" + OldContentControl.Title);
 }
Example #7
0
 private void ThisDocument_ContentControlAfterAdd(Microsoft.Office.Interop.Word.ContentControl NewContentControl, bool InUndoRedo)
 {
     Debug.Print("ThisDocument_ContentControlAfterAdd :" + NewContentControl.Title);
 }