Ejemplo n.º 1
0
        private void toggleButtonMapping_Click(object sender, RibbonControlEventArgs e)
        {
            //get the ctp for this window (or null if there's not one)
            CustomTaskPane ctpPaneForThisWindow = Utilities.FindTaskPaneForCurrentWindow();

            if (toggleButtonMapping.Checked == false)
            {
                Debug.Assert(ctpPaneForThisWindow != null, "how was the ribbon button pressed if there was no control?");

                //it's being unclicked
                if (ctpPaneForThisWindow != null)
                {
                    ctpPaneForThisWindow.Visible = false;
                }
            }
            else
            {
                if (ctpPaneForThisWindow == null)
                {
                    //set the cursor to wait
                    Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorWait;

                    //set up the task pane
                    ctpPaneForThisWindow = Globals.ThisAddIn.CustomTaskPanes.Add(new Controls.ControlMain(), Properties.Resources.TaskPaneName);
                    ctpPaneForThisWindow.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

                    //store it for later
                    if (Globals.ThisAddIn.Application.ShowWindowsInTaskbar)
                    {
                        Globals.ThisAddIn.TaskPaneList.Add(Globals.ThisAddIn.Application.ActiveWindow, ctpPaneForThisWindow);
                    }

                    //connect task pane events
                    Globals.ThisAddIn.ConnectTaskPaneEvents(ctpPaneForThisWindow);

                    //get the control we hosted
                    Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;

                    //hand the eventing class to the control
                    DocumentEvents de = new DocumentEvents(ccm);
                    ccm.EventHandlerAndOnChildren = de;
                    ccm.RefreshControls(Controls.ControlMain.ChangeReason.DocumentChanged, null, null, null, null, null);

                    //show it
                    ctpPaneForThisWindow.Visible = true;

                    //reset the cursor
                    Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
                }
                else
                {
                    //it's built and being clicked, show it
                    ctpPaneForThisWindow.Visible = true;
                }
            }
        }
        private void launchTaskPane()
        {
            //set the cursor to wait
            Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorWait;

            //set up the task pane
            CustomTaskPane ctpPaneForThisWindow
                = Globals.ThisAddIn.CustomTaskPanes.Add(
                    new Controls.ControlMain(),
                    Properties.Resources.TaskPaneName);
            ctpPaneForThisWindow.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

            //store it for later
            if (Globals.ThisAddIn.Application.ShowWindowsInTaskbar)
                Globals.ThisAddIn.TaskPaneList.Add(Globals.ThisAddIn.Application.ActiveWindow, ctpPaneForThisWindow);

            //connect task pane events
            Globals.ThisAddIn.ConnectTaskPaneEvents(ctpPaneForThisWindow);

            //get the control we hosted
            Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;

            ccm.formPartList.ccm = ccm;

            // OK, OpenDoPE parts should exist
            Model model = Model.ModelFactory(Globals.ThisAddIn.Application.ActiveDocument);
            // hand the OpenDoPE model to the control
            ccm.model = model;

            //hand the eventing class to the control
            DocumentEvents de = new DocumentEvents(ccm);
            de.RibbonMapping = this; // so de can enable/disable stuff on ribbon

            ccm.EventHandlerAndOnChildren = de;

            // following is no good for us, since it selects first part
            //ccm.RefreshControls(Controls.ControlMain.ChangeReason.DocumentChanged, null, null, null, null, null);

            // The current cxp is stored in the DocumentEvents object
            // (which in turn is a field in ControlBase).
            // The user custom xml part is to current in DocumentEvents.
            // But we also need:
            string requiredRoot = System.Configuration.ConfigurationManager.AppSettings["RootElement"];
            Office.CustomXMLPart userPart = model.getUserPart(requiredRoot);
            Office.CustomXMLNode mxnNewNode = userPart.DocumentElement;

            log.Debug("DocumentElement of user part: " + mxnNewNode.BaseName);
            ccm.formPartList.controlPartList.RefreshPartList(true, false, false, mxnNewNode.OwnerPart.Id, null, mxnNewNode);

            //ccm.RefreshControls(Controls.ControlMain.ChangeReason.OnEnter, null, null, null, mxnNewNode, null);
            // would also work, but is more opaque

            //show it
            ctpPaneForThisWindow.Visible = true;

            this.buttonBind.Enabled = true;
            this.buttonCondition.Enabled = true;
            this.buttonRepeat.Enabled = true;

            this.menuAdvanced.Enabled = true;

            this.buttonReplaceXML.Enabled = true;
            this.buttonClearAll.Enabled = true;

            //reset the cursor
            Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }
Ejemplo n.º 3
0
        private void launchTaskPane()
        {
            //set the cursor to wait
            Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorWait;

            //set up the task pane
            CustomTaskPane ctpPaneForThisWindow
                = Globals.ThisAddIn.CustomTaskPanes.Add(
                      new Controls.ControlMain(),
                      Properties.Resources.TaskPaneName);

            ctpPaneForThisWindow.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

            //store it for later
            if (Globals.ThisAddIn.Application.ShowWindowsInTaskbar)
            {
                Globals.ThisAddIn.TaskPaneList.Add(Globals.ThisAddIn.Application.ActiveWindow, ctpPaneForThisWindow);
            }

            //connect task pane events
            Globals.ThisAddIn.ConnectTaskPaneEvents(ctpPaneForThisWindow);

            //get the control we hosted
            Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;

            ccm.formPartList.ccm = ccm;

            // OK, OpenDoPE parts should exist
            Model model = Model.ModelFactory(Globals.ThisAddIn.Application.ActiveDocument);

            // hand the OpenDoPE model to the control
            ccm.model = model;


            //hand the eventing class to the control
            DocumentEvents de = new DocumentEvents(ccm);

            de.Ribbon = this; // so de can enable/disable stuff on ribbon


            ccm.EventHandlerAndOnChildren = de;

            // following is no good for us, since it selects first part
            //ccm.RefreshControls(Controls.ControlMain.ChangeReason.DocumentChanged, null, null, null, null, null);

            // The current cxp is stored in the DocumentEvents object
            // (which in turn is a field in ControlBase).
            // The user custom xml part is to current in DocumentEvents.
            // But we also need:
            string requiredRoot = System.Configuration.ConfigurationManager.AppSettings["RootElement"];

            Office.CustomXMLPart userPart   = model.getUserPart(requiredRoot);
            Office.CustomXMLNode mxnNewNode = userPart.DocumentElement;

            log.Debug("DocumentElement of user part: " + mxnNewNode.BaseName);
            ccm.formPartList.controlPartList.RefreshPartList(true, false, false, mxnNewNode.OwnerPart.Id, null, mxnNewNode);

            //ccm.RefreshControls(Controls.ControlMain.ChangeReason.OnEnter, null, null, null, mxnNewNode, null);
            // would also work, but is more opaque

            //show it
            ctpPaneForThisWindow.Visible = true;

            this.buttonBindEnabled      = true;
            this.buttonConditionEnabled = true;
            this.buttonRepeatEnabled    = true;

            this.menuAdvancedEnabled = true;

            this.buttonReplaceXMLEnabled = true;
            this.buttonClearAllEnabled   = true;

            myInvalidate();

            //reset the cursor
            Globals.ThisAddIn.Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }