Пример #1
0
        public VMOperationWlbHostCommand(IMainWindow mainWindow, IEnumerable<SelectedItem> vms, Host host, vm_operations operation, WlbRecommendations.WlbRecommendation recommendation)
            : base(mainWindow, vms, operation)
        {
            Util.ThrowIfParameterNull(recommendation, "recommendation");
            Util.ThrowIfParameterNull(host, "host");

            _host = host;
            _menuText = _host.Name.EscapeAmpersands();

            //Default or failure case, there is no score/star rating actually, just don't display star
            _secondImage = null;
            _menuImage = Images.StaticImages._000_ServerDisconnected_h32bit_16;
            _recommendation = recommendation;

            if (CanExecute())
            {
                _starRating = _recommendation.StarRating;
                _menuImage = Images.StaticImages._000_TreeConnected_h32bit_16;
                _secondImage = GetWLBStarImage(_starRating);
            }
            else
            {
                // get the failure reason if the dictionary is populated with reasons that are all the same.
                // otherwise don't display a reason - leave this to the error dialog.

                string reason = null;
                foreach (string r in _recommendation.CantExecuteReasons.Values)
                {
                    if (reason != null && r != reason)
                    {
                        return;
                    }
                    reason = r;
                }

                if (!string.IsNullOrEmpty(reason))
                {
                    _menuText = string.Format(Messages.MAINWINDOW_CONTEXT_REASON, _menuText, reason);
                }
            }
        }
        public VMOperationWlbHostCommand(IMainWindow mainWindow, IEnumerable <SelectedItem> vms, Host host, vm_operations operation, WlbRecommendations.WlbRecommendation recommendation)
            : base(mainWindow, vms, operation)
        {
            Util.ThrowIfParameterNull(recommendation, "recommendation");
            Util.ThrowIfParameterNull(host, "host");

            _host     = host;
            _menuText = _host.Name().EscapeAmpersands();

            //Default or failure case, there is no score/star rating actually, just don't display star
            _secondImage    = null;
            _menuImage      = Images.StaticImages._000_ServerDisconnected_h32bit_16;
            _recommendation = recommendation;

            if (CanExecute())
            {
                _starRating  = _recommendation.StarRating;
                _menuImage   = Images.StaticImages._000_TreeConnected_h32bit_16;
                _secondImage = GetWLBStarImage(_starRating);
            }
            else
            {
                // get the failure reason if the dictionary is populated with reasons that are all the same.
                // otherwise don't display a reason - leave this to the error dialog.

                string reason = null;
                foreach (string r in _recommendation.CantExecuteReasons.Values)
                {
                    if (reason != null && r != reason)
                    {
                        return;
                    }
                    reason = r;
                }

                if (!string.IsNullOrEmpty(reason))
                {
                    _menuText = string.Format(Messages.MAINWINDOW_CONTEXT_REASON, _menuText, reason);
                }
            }
        }