Exemplo n.º 1
0
        internal void LoadCustomUI()
        {
            bool uiLoaded = false;

            if (ExcelDnaUtil.ExcelVersion >= 12.0)
            {
                // Load ComAddIns
                foreach (AssemblyLoader.ExcelAddInInfo addIn in _addIns)
                {
                    if (addIn.IsCustomUI)
                    {
                        // Load ExcelRibbon classes
                        ExcelRibbon excelRibbon = addIn.Instance as ExcelRibbon;
                        excelRibbon.DnaLibrary = addIn.ParentDnaLibrary;
                        ExcelComAddInHelper.LoadComAddIn(excelRibbon);
                        uiLoaded = true;
                    }
                }

                // CONSIDER: Really not sure if this is a good idea - seems to interfere with unloading somehow.
                //if (uiLoaded == false && CustomUIs != null)
                //{
                //    // Check whether we should add an empty ExcelCustomUI instance to load a Ribbon interface?
                //    bool loadEmptyAddIn = false;
                //    if (CustomUIs != null)
                //    {
                //        foreach (XmlNode xmlCustomUI in CustomUIs)
                //        {
                //            if (xmlCustomUI.LocalName == "customUI" &&
                //                (xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2007 ||
                //                 (ExcelDnaUtil.ExcelVersion >= 14.0 &&
                //                  xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2010)))
                //            {
                //                loadEmptyAddIn = true;
                //            }
                //            if (loadEmptyAddIn)
                //            {
                //                // There will be Ribbon xml to load. Make a temp add-in and load it.
                //                ExcelRibbon customUI = new ExcelRibbon();
                //                customUI.DnaLibrary = this;
                //                ExcelComAddInHelper.LoadComAddIn(customUI);
                //                uiLoaded = true;
                //            }
                //        }
                //    }
                //}
            }

            // should we load CommandBars?
            if (uiLoaded == false && CustomUIs != null)
            {
                foreach (XmlNode xmlCustomUI in CustomUIs)
                {
                    if (xmlCustomUI.LocalName == "commandBars")
                    {
                        ExcelCommandBarUtil.LoadCommandBars(xmlCustomUI, this.GetImage);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void AddCommandMenu(string commandName, string menuName, string menuText, string description, string shortCut, string helpTopic)
        {
            try // Basically suppress problems here..?
            {
                CommandBarPopup menu;
                if (!_foundMenus.TryGetValue(menuName, out menu))
                {
                    // We've not seen this menu before

                    // Check if the menu exists
                    CommandBars        commandBars  = ExcelCommandBarUtil.GetCommandBars();
                    CommandBar         worksheetBar = commandBars[1];
                    CommandBarControls controls     = worksheetBar.Controls;
                    int controlCount = controls.Count();

                    for (int i = 1; i <= controlCount; i++)
                    {
                        CommandBarControl control = controls[i];
                        if (control.Caption == menuName && control is CommandBarPopup)
                        {
                            menu = (CommandBarPopup)control;
                            _foundMenus[menuName] = menu;
                            break;
                        }
                    }

                    if (menu == null)
                    {
                        // Make a new menu
                        menu         = controls.AddPopup(menuName);
                        menu.Caption = menuName;
                        _addedMenus.Add(menu);
                        _foundMenus[menuName] = menu;
                    }
                }

                CommandBarControls menuButtons = menu.Controls;
                int buttonCount = menu.Controls.Count();
                for (int i = 1; i <= buttonCount; i++)
                {
                    CommandBarControl button = menuButtons[i];
                    if (button.Caption == menuText && button is CommandBarButton)
                    {
                        button.OnAction = commandName;
                        return;
                    }
                }

                // If we're here, need to add a button.
                CommandBarButton newButton = menuButtons.AddButton();
                newButton.Caption  = menuText;
                newButton.OnAction = commandName;
                _addedButtons.Add(newButton);
            }
            catch (Exception e)
            {
                Logger.Initialization.Error(e, "MenuManager.AddCommandMenu Error");
            }
        }
Exemplo n.º 3
0
        public void AutoClose()
        {
            IntelliSenseServer.Uninstall();
            Java.Dispose();
            WDSJniPMMLMenuToDelete.Delete(true);
            ExcelCommandBarUtil.UnloadCommandBars();

            __JniPMML            = null;
            Java                 = null;
            pair                 = null;
            java_class_path      = null;
            java_init_classid    = IntPtr.Zero;
            java_init_class_name = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Exemplo n.º 4
0
 internal void UnloadCustomUI()
 {
     // This is safe, even if no Com Add-Ins were loaded.
     ExcelComAddInHelper.UnloadComAddIns();
     ExcelCommandBarUtil.UnloadCommandBars();
 }
 public override void UnloadCommandBars()
 {
     ExcelCommandBarUtil.UnloadCommandBars();
 }
 public override void LoadCommandBars(string xmlCustomUI, GetImageDelegate getImage)
 {
     ExcelCommandBarUtil.LoadCommandBars(xmlCustomUI, getImage);
 }
 public override void LoadCommandBars(string xmlCustomUI)
 {
     ExcelCommandBarUtil.LoadCommandBars(xmlCustomUI);
 }
 public override CommandBars GetCommandBars()
 {
     return(ExcelCommandBarUtil.GetCommandBars());
 }