/// <summary> /// Разорвать связь между текущим презентером и представлением /// </summary> public void DetatchFromPresenter() { lock (this) { if (Presenter != null) { Presenter.DisconnectView(this); Presenter = null; } } }
/// <summary> /// Связать представление с презентером /// </summary> /// <param name="presenter">Презентер</param> /// <param name="requiresInitialState">Нужна ли инициализация представления ?</param> public void AttachToPresenter(IGraphPresenter presenter, bool requiresInitialState) { if (presenter == null) { throw new ArgumentNullException(nameof(presenter)); } DetatchFromPresenter(); Presenter = presenter; Presenter.ConnectView(this, requiresInitialState); }
public MainView() { InitializeComponent(); graph = new GraphModel(4); shortestPath = new ShortestPathModel(); graphPresenter = new GraphPresenter(graph, shortestPath); shortestPathPresenter = new ShortestPathPresenter(shortestPath, graph); algorithmControlView1.AttachToPresenter(shortestPathPresenter, true); shortestPathView1.AttachToPresenter(shortestPathPresenter, true); GraphControlView.AttachToPresenter(graphPresenter, true); GraphMatrixView.AttachToPresenter(graphPresenter, true); graphLogicalView1.AttachToPresenter(graphPresenter, true); }
public void SetPresenter(IGraphPresenter presenter) { _presenter = presenter; }