コード例 #1
0
        public EncapsulateFieldModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            _view.ViewModel.TargetDeclaration = _model.TargetDeclaration;

            var isVariant   = _model.TargetDeclaration.AsTypeName.Equals(Tokens.Variant);
            var isValueType = !isVariant && (SymbolList.ValueTypes.Contains(_model.TargetDeclaration.AsTypeName) ||
                                             _model.TargetDeclaration.DeclarationType == DeclarationType.Enumeration);

            AssignSetterAndLetterAvailability(isVariant, isValueType);

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.PropertyName           = _view.ViewModel.PropertyName;
            _model.ImplementLetSetterType = _view.ViewModel.IsLetSelected;
            _model.ImplementSetSetterType = _view.ViewModel.IsSetSelected;
            _model.CanImplementLet        = _view.ViewModel.CanHaveLet;

            _model.ParameterName = _view.ViewModel.ParameterName;
            return(_model);
        }
コード例 #2
0
        public ExtractInterfaceModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            _view.ViewModel.ComponentNames = _model.State.DeclarationFinder
                                             .UserDeclarations(DeclarationType.Module)
                                             .Where(moduleDeclaration => moduleDeclaration.ProjectId == _model.TargetDeclaration.ProjectId)
                                             .Select(module => module.ComponentName)
                                             .ToList();
            _view.ViewModel.InterfaceName = _model.InterfaceName;
            _view.ViewModel.Members       = _model.Members.ToList();

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.InterfaceName = _view.ViewModel.InterfaceName;
            _model.Members       = _view.ViewModel.Members;
            return(_model);
        }
コード例 #3
0
        public RemoveParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count == 0)
            {
                var message = string.Format(RubberduckUI.RemovePresenter_NoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.NotifyWarn(message, RubberduckUI.RemoveParamsDialog_TitleText);
                return(null);
            }

            if (_model.Parameters.Count == 1)
            {
                return(_model);
            }

            _view.ViewModel.Parameters = _model.Parameters.Select(p => p.ToViewModel()).ToList();
            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }
            _model.RemoveParameters = _view.ViewModel.Parameters.Where(m => m.IsRemoved).Select(vm => vm.ToModel()).ToList();
            return(_model);
        }
コード例 #4
0
        public ReorderParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count < 2)
            {
                var message = string.Format(RubberduckUI.ReorderPresenter_LessThanTwoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.Show(message, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            _view.ViewModel.Parameters = new ObservableCollection <Parameter>(_model.Parameters);

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.Parameters = _view.ViewModel.Parameters.ToList();
            return(_model);
        }
コード例 #5
0
        public RemoveParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count == 0)
            {
                var message = string.Format(RubberduckUI.RemovePresenter_NoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.Show(message, RubberduckUI.RemoveParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            if (_model.Parameters.Count == 1)
            {
                _model.Parameters[0].IsRemoved = true;
                return(_model);
            }

            _view.ViewModel.Parameters = _model.Parameters;
            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.Parameters = _view.ViewModel.Parameters;
            return(_model);
        }
コード例 #6
0
        public IAddRemoveReferencesModel Show(ProjectDeclaration project)
        {
            if (project is null)
            {
                return(null);
            }

            Model.Project         = project;
            _view.ViewModel.Model = Model;

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            Model.NewReferences = _view.ViewModel.ProjectReferences.SourceCollection.OfType <ReferenceModel>().ToList();
            return(Model);
        }
コード例 #7
0
ファイル: RenamePresenter.cs プロジェクト: tommy9/Rubberduck
        public RenameModel Show(Declaration target)
        {
            if (null == target)
            {
                return(null);
            }

            _model.Target          = target;
            _view.ViewModel.Target = target;

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.NewName = _view.ViewModel.NewName;
            return(_model);
        }
コード例 #8
0
        public ExtractInterfaceModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            _view.ViewModel.ComponentNames = _model.TargetDeclaration.Project.VBComponents.Select(c => c.Name).ToList();
            _view.ViewModel.InterfaceName  = _model.InterfaceName;
            _view.ViewModel.Members        = _model.Members.ToList();

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.InterfaceName = _view.ViewModel.InterfaceName;
            _model.Members       = _view.ViewModel.Members;
            return(_model);
        }