Beispiel #1
0
        public async void OnActionCallback(Office.IRibbonControl control)
        {
            IRibbonControlObject controlObject = _controlFactory.GetControlObject(control);

            if (controlObject == null)
            {
                return;
            }

            IRibbonControlEnabled controlObjectEnabled = controlObject as IRibbonControlEnabled;

            //ribbon.ToggleEnabled(false);
            var rb1 = Globals.Ribbons[control.Context as Inspector];
            await controlObject.OnActionCallback();

            //controlObjectEnabled?.ToggleEnabled(true);
        }
Beispiel #2
0
        public IRibbonControlObject GetControlObject(Office.IRibbonControl control)
        {
            List <IRibbonControlObject> controlObjects = null;

            if (control?.Context == null)
            {
                return(null);
            }

            var contextHashCode = control.Context.GetHashCode();

            Debug.WriteLine($"Context hash code:{contextHashCode}");
            logger.Message($"Context hash code:{contextHashCode}");

            IRibbonControlObject controlObject = null;

            controls.TryGetValue(contextHashCode, out controlObjects);

            if (controlObjects != null)
            {
                controlObject = controlObjects.FirstOrDefault(c => c.Tag == control.Tag);
            }


            if (controlObject == null)
            {
                controlObject = ControlFactoryMethod(control);
                if (controlObject != null)
                {
                    if (controlObjects != null)
                    {
                        controlObjects.Add(controlObject);
                        controls[contextHashCode] = controlObjects;
                    }
                    else
                    {
                        controlObjects = new List <IRibbonControlObject>(new[] { controlObject });
                        controls.Add(contextHashCode, controlObjects);
                    }
                }
            }

            return(controlObject);
        }