Ejemplo n.º 1
0
        //check all command state
        public void UpdateCommandState(Workspaces.IWorkspace1 workSpace)
        {
            foreach (KeyValuePair <string, IUICommand> cmd in this._commands)
            {
                IController controller = this._controllerFinder.FindController(cmd.Value.controllerId);

                cmd.Value.CheckConditions(controller, workSpace);
            }
        }
Ejemplo n.º 2
0
        public void CheckConditions(IController controller, Workspaces.IWorkspace1 workSpace)
        {
            SetConditionAffectedProperty(ConditionAffect.Enabled,
                                         a => this._barItem.Enabled = a == ConditionFailedAction.Nothing,
                                         controller);
            SetConditionAffectedProperty(ConditionAffect.Visibility, a =>
            {
                if (a == ConditionFailedAction.Nothing)
                {
                    this._barItem.Visibility = BarItemVisibility.Always;
                }
                else
                {
                    this._barItem.Visibility = BarItemVisibility.Never;
                }
                if (!(this._barItem is BarButtonItemEx))
                {
                    return;
                }
                var barButtonItem = this._barItem as BarButtonItemEx;
                var page          = barButtonItem.FormRibbon.Pages.Cast <RibbonPage>()
                                    .Where(c => c.Groups.Cast <RibbonPageGroup>()
                                           .Any(d => d.ItemLinks.Cast <BarItemLink>()
                                                .Any(e => e.Item == barButtonItem)
                                                )
                                           );
                if (page == null)
                {
                    return;
                }
                if (page.Count() <= 0)
                {
                    return;
                }
                var group = page.First().Groups.Cast <RibbonPageGroup>()
                            .Where(d => d.ItemLinks.Cast <BarItemLink>()
                                   .Any(e => e.Item == barButtonItem)
                                   );
                if (group == null)
                {
                    return;
                }
                if (group.Count() <= 0)
                {
                    return;
                }
                group.First().Visible = group.First().ItemLinks.Cast <BarButtonItemLink>().Any(c => c.Item.Visibility == BarItemVisibility.Always);
            },
                                         controller);

            if (!(this._barItem is BarButtonItem))
            {
                return;
            }

            BarButtonItem buttonItem = this._barItem as BarButtonItem;

            if (buttonItem.ButtonStyle == BarButtonStyle.Check)
            {
                SetConditionAffectedProperty(ConditionAffect.Down,
                                             a => buttonItem.Down = a == ConditionFailedAction.Nothing,
                                             workSpace);
            }
        }