Refactoring Form.ShowDialog () for MVP

I have WinForm and several properties that are installed on it.
For example: name, address are accepted in the form.
(many other properties in a real example)

The current implementation is somewhat similar to

frmName frmView = new  frmName (); //frmName  is WINFORM 
frmView.Name= "ABC"; //any valid string or read this from file
frmView.Address="SomeAddress"; //any valid address or read this from file

if (frmView.ShowDialog() == DialogResult.OK)
{
    //OK CLICK PROCESS and
    // get new values edited by user
     string name = frmView .Name;
     string address = frmView.Address;
     doProcessing(name,address);
}
else{
  //Ignore cancel click..
}

how to convert this to MVP based on Winform application.
It is also necessary to reorganize the processing performed using ShowDialog () in the presenter / model
(I do not know where to do this)?
It is also necessary to avoid writing code in the form itself. (Passive view)

Thanks to everyone.

+5
source share
1

MVP, , , :

frmName frmView = new frmName();

if (frmView.ShowDialog() == DialogResult.OK) {
    presenter.RequestProcessing(frmView.Name, frmView.Address);
} else {
    //Ignore cancel click..
}

, , . .

. , - (, ). , , , . , .

, , IPresenter . , "", , .

MVP , , . .

+5

All Articles