Пример #1
0
 /// <summary>
 /// Updates command</summary>
 /// <param name="commandTag">Command</param>
 /// <param name="commandState">Command state</param>
 void ICommandClient.UpdateCommand(object commandTag, CommandState commandState)
 {
     if (m_removeTargetsCmdTags.Contains(commandTag))
     {
         commandState.Text = RemoveTargetString.Localize() + m_selectedTargets.First().Name;
     }
 }
Пример #2
0
        /// <summary>
        /// Tests if client can perform command</summary>
        /// <param name="commandTag">Command</param>
        /// <returns>True iff client can perform command</returns>
        bool ICommandClient.CanDoCommand(object commandTag)
        {
            if (m_targetProviders == null)
            {
                return(false);
            }

            if (CommandTag.VitaNeighborhood.Equals(commandTag))
            {
                if (m_selectedTargets != null && m_selectedTargets.Any())
                {
                    return(m_selectedTargets.All(target => target.Protocol == Deci4pTargetInfo.ProtocolName));
                }

                return(false);
            }

            // add target
            if (m_addTargetsCmdTags.Contains(commandTag))
            {
                foreach (var targetProvider in TargetProviders)
                {
                    string addCmdTag = AddNewString.Localize() + targetProvider.Name;
                    if (addCmdTag.Equals(commandTag))
                    {
                        return(true);
                    }
                }

                return(false);
            }


            // remove target
            if (m_removeTargetsCmdTags.Contains(commandTag))
            {
                foreach (var targetProvider in TargetProviders)
                {
                    string remCmdTag = RemoveTargetString.Localize() + targetProvider.Name;
                    if (remCmdTag.Equals(commandTag))
                    {
                        if (m_selectedTargets != null && m_selectedTargets.Any())
                        {
                            // whether all these selected targets are provided by this provider
                            return(m_selectedTargets.All(target => targetProvider.GetTargets(m_targetConsumer).Contains(target)));
                        }
                    }
                }

                return(false);
            }

            return(false);
        }