Skip to content

Commit

Permalink
Remove/Add buttons work
Browse files Browse the repository at this point in the history
  • Loading branch information
Hosch250 committed May 29, 2015
1 parent a555ebb commit fb3c07d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,34 +523,6 @@ private void GetGetter(out Declaration target, ref Declaration method)
}
}

private void PromptIfTargetImplementsInterface(ref Declaration target, ref Declaration method)
{
var declaration = method;
var interfaceImplementation = _declarations.FindInterfaceImplementationMembers().SingleOrDefault(m => m.Equals(declaration));
if (method == null || interfaceImplementation == null)
{
return;
}

var interfaceMember = _declarations.FindInterfaceMember(interfaceImplementation);
var message = string.Format(RubberduckUI.ReorderPresenter_TargetIsInterfaceMemberImplementation, method.IdentifierName, interfaceMember.ComponentName, interfaceMember.IdentifierName);

var confirm = MessageBox.Show(message, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (confirm == DialogResult.No)
{
method = null;
return;
}

method = interfaceMember;

var proc = (dynamic)declaration.Context;
var paramList = (VBAParser.ArgListContext)proc.argList();

var indexOfInterfaceParam = paramList.arg().ToList().FindIndex(item => item.GetText() == _target.Context.GetText());
target = FindTargets(_method).ElementAt(indexOfInterfaceParam);
}

private bool IsSelectedDeclaration(QualifiedSelection selection, Declaration declaration)
{
return declaration.QualifiedName.QualifiedModuleName == selection.QualifiedName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ namespace Rubberduck.UI.Refactorings.RemoveParameters
public partial class RemoveParametersDialog : Form, IRemoveParametersView
{
public RemoveParameterRefactoring RemoveParams { get; set; }
private Parameter _selectedItem;

public RemoveParametersDialog()
{
InitializeComponent();
InitializeCaptions();

MethodParametersGrid.SelectionChanged += MethodParametersGrid_SelectionChanged;
RemoveButton.Click += RemoveButtonClicked;
AddButton.Click += AddButtonClicked;
}

private void InitializeCaptions()
Expand Down Expand Up @@ -82,36 +85,35 @@ public void OnOkButtonClicked()

private void RemoveButtonClicked(object sender, EventArgs e)
{

if (_selectedItem != null)
{
RemoveParams.Parameters.Find(item => item == _selectedItem).IsRemoved = true;
SelectionChanged();
}
}

private void AddButtonClicked(object sender, EventArgs e)
{

if (_selectedItem != null)
{
RemoveParams.Parameters.Find(item => item == _selectedItem).IsRemoved = false;
SelectionChanged();
}
}

private int GetFirstSelectedRowIndex(int index)
{
return MethodParametersGrid.SelectedRows[index].Index;
}

/*private void ReselectParameter()
{
MethodParametersGrid.Refresh();
MethodParametersGrid.Rows
.Cast<DataGridViewRow>()
.Single(row => row.DataBoundItem == _selectedItem).Selected = true;
SelectionChanged();
}*/

private void SelectionChanged()
{
/*MoveUpButton.Enabled = _selectedItem != null
&& MethodParametersGrid.SelectedRows[0].Index != 0;
_selectedItem = MethodParametersGrid.SelectedRows.Count == 0
? null
: (Parameter)MethodParametersGrid.SelectedRows[0].DataBoundItem;

MoveDownButton.Enabled = _selectedItem != null
&& MethodParametersGrid.SelectedRows[0].Index != RemoveParams.Parameters.Count - 1;*/
RemoveButton.Enabled = _selectedItem != null && !_selectedItem.IsRemoved;
AddButton.Enabled = _selectedItem != null && _selectedItem.IsRemoved;
}
}
}

0 comments on commit fb3c07d

Please sign in to comment.