Exemple #1
0
 /// <summary>
 /// 打开TaskPane
 /// </summary>
 /// <param name="QuestionList"></param>
 private void executeTaskPane(List <Question> QuestionList)
 {
     if (Globals.ThisAddIn._MyCustomTaskPane != null)
     {
         Globals.ThisAddIn._MyCustomTaskPane.Dispose(); // 释放旧TaskPane
         UCForRichText richTextBox = new UCForRichText(QuestionList);
         Globals.ThisAddIn._MyCustomTaskPane         = Globals.ThisAddIn.CustomTaskPanes.Add(richTextBox, "解析结果");
         Globals.ThisAddIn._MyCustomTaskPane.Width   = 800;
         Globals.ThisAddIn._MyCustomTaskPane.Visible = true;
     }
 }
Exemple #2
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // 初始化右侧解析框
            UCForRichText richTextBox = new UCForRichText();
            _MyCustomTaskPane = this.CustomTaskPanes.Add(richTextBox, "解析结果");
            _MyCustomTaskPane.Width = 800;
            _MyCustomTaskPane.Visible = false;

            //获取右键菜单对象mzBar
            Office.CommandBar mzBar = Application.CommandBars["Text"];
            //重置菜单
            mzBar.Reset();
            //获取右键菜单的控制对象
            Office.CommandBarControls bars = mzBar.Controls;

            /*已被mzBar.Reset();替代,用于除去其余标签为"autoAnswer"的菜单项
            foreach (Office.CommandBarControl temp_contrl in bars)
            {
                string t = temp_contrl.Tag.Trim();
                if (t.Equals("autoAnswer"))
                {
                    temp_contrl.Delete();
                }
            }
            */

            //在右键菜单列表添加新的菜单项
            Office.CommandBarControl comControl = bars.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); //添加自己的菜单项
            //将该菜单项转为按钮可点击模式
            Office.CommandBarButton comButton = comControl as Office.CommandBarButton;
            if (comControl != null)
            {
                comButton.Tag = "autoAnswer";//添加标签"autoAnswer"
                comButton.Caption = "选择答案";//设置文本
                comButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                comButton.Enabled = false;//设置不可点击
                //name = comButton.accName;
                //comButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(_RightBtn_Click);

            }

            Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
            vstoDoc.BeforeDoubleClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeDoubleClick);

            this.Application.WindowBeforeRightClick += new Word.ApplicationEvents4_WindowBeforeRightClickEventHandler(Application_WindowBeforeRightClick);
        }