1

I am trying to understand the MVP design pattern. I have aplication WinForms (View) + DLL (IVIEW, IMODEL)

1) Where is a better place for Presentor? DLL or WinForms app?

2) Where do I call a method SaveFile() for saving the results in a file?

public MyPresenter(IMyModel model, IMyView view) 
{
   ...
   this.view.SavetoFile += View_SavetoFile;
}
private void View_SavetoFile(object sender, EventArgs e)
{
   SaveFile()
}
private void SaveFile()
{
  using (var saveFileDialog = new SaveFileDialog())
  {
     if (DialogResult.OK == saveFileDialog.ShowDialog())
     {
       using (var xnmlFile = new XMLFile(saveFileDialog.FileName))
       {
        xmlFile.Save(this.model.Result)
       }
     }
 }

Is that right?

Libor V.
  • 11
  • 2
  • There is really [a GREAT post](http://stackoverflow.com/questions/4794121/model-view-presenter-in-winforms) on StackOverflow, read the answer it should make things clear for you. After reading that I hope you will feel that putting any UI related stuff (like showing `SaveFileDialog`) into presenter is not the way to go with MVP. Instead `Presenter` should ask `View` to show dialog and return results back to `Presenter`, after which `Presenter` can proceed with the rest. Also I would suggest reading [this post](https://lostechies.com/derekgreer/2008/11/23/model-view-presenter-styles/). – Michael Oct 05 '15 at 18:14

0 Answers0