/// <summary> Manage the user's right click: manage the menus creation</summary>
        /// <param name="sheet">The sheet where the right click is done</param>
        /// <param name="concernedRange">Concerned Range</param>
        /// <param name="cancel"></param>
        private void OnSheetBeforeRightClickViewsManagement(object sheet, ExcelInterop.Range range, ref bool cancel)
        {
            ExcelInterop.Application application = range.Application;
            CommandBar commandBar = application.CommandBars["Cell"];

            commandBar.Reset();

            ExcelInterop.Range realRange = range.Cells[1, 1];
            foreach (ContextualMenusRequestedHandler manager in contextualMenusManagers)
            {
                try
                {
                    IEnumerable <IContextualMenu> menus = manager((ExcelInterop.Worksheet)sheet, realRange);
                    if (menus != null)
                    {
                        foreach (IContextualMenu menu in menus)
                        {
                            CreateMenus(commandBar.Controls, menu);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string methodName = manager.Method == null ? string.Empty : manager.Method.Name.EmptyIfNull();
                    throw new EtkException($"Contextual menu manager: '{methodName}' invocation failed: {ex.Message}.");
                }
            }
            realRange = null;
        }
Example #2
0
        private void RemoveItem()
        {
            Word.Application applicationObject = Globals.ThisAddIn.Application as Word.Application;
            CommandBar       popupCommandBar   = applicationObject.CommandBars["Text"];

            foreach (object _object in popupCommandBar.Controls)
            {
                CommandBarButton commandBarButton = _object as CommandBarButton;
                if (commandBarButton == null)
                {
                    continue;
                }

                popupCommandBar.Reset();
            }
        }
 public void Reset()
 {
     _bar.Reset();
 }
 /// <summary>
 /// Resets the command bar from previouse results
 /// </summary>
 /// <param name="commandBar">CommandBar instance</param>
 private void CleanCommandBar(ref CommandBar commandBar)
 {
     commandBar.Reset();
 }