Пример #1
0
        /// <summary>
        /// Can the client do the command?</summary>
        /// <param name="commandTag">Command</param>
        /// <returns>True iff client can do the command</returns>
        public bool CanDoCommand(object commandTag)
        {
            bool enabled = false;
            var  context = m_contextRegistry.GetActiveContext <CircuitEditingContext>();

            if (context != null)
            {
                ISelectionContext selectionContext = context.As <ISelectionContext>();
                if (CommandTag.CreateMaster.Equals(commandTag))
                {
                    enabled = selectionContext.GetLastSelected <Element>() != null; // at least one module selected
                }
                else if (CommandTag.ExpandMaster.Equals(commandTag))
                {
                    enabled = selectionContext.GetLastSelected <SubCircuitInstance>() != null; // at least one mastered instance selected
                }
            }

            return(enabled);
        }