/// <summary> /// Default constructor. /// </summary> public MainFormView() { InitializeComponent(); presenter = Bootstrapper.ServiceLocator.GetService <IMainFormViewPresenter>(); this.AttachToPresenter(Presenter, true); }
/// <summary> /// Detach current view from his current presenter. /// </summary> public void DetatchFromPresenter() { lock (this) { if (Presenter != null) { Presenter.DisconnectView(this); presenter = null; } } }
/// <summary> /// Attach current view to specific presenter. /// </summary> /// <param name="presenter">Presenter object to attach for this view.</param> /// <param name="requiresInitialState">Indicates that view require initial state.</param> public void AttachToPresenter(IMainFormViewPresenter presenter, bool requiresInitialState) { if (presenter == null) { throw new ArgumentNullException("presenter"); } DetatchFromPresenter(); this.presenter = presenter; presenter.ConnectView(this, requiresInitialState); }
/// <summary> /// Load event for MainFormView. /// </summary> /// <param name="sender">Object with send this event.</param> /// <param name="e">Event object.</param> private void MainFormView_Load(object sender, EventArgs e) { presenter = Bootstrapper.ServiceLocator.GetService <IMainFormViewPresenter>(); Settings.Click += (x, y) => { using ( SettingsView view = new SettingsView()) { view.ShowDialog(); } }; ShowInstruction.Click += (x, y) => { Presenter.OpenInstruction(); }; About.Click += (x, y) => { using ( AboutView view = new AboutView()) { view.ShowDialog(); } }; Close.Click += (x, y) => { if (MessageBoxView.Show("Zamknąć aplikację? Wszystkie wykonane obliczenia zostaną utracone.", "Zamknij", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.Close(); } }; SetDefaulfAlgorithm(); SetStartupValues(); SetStartupControlsState(); SetWeightsDataSource(null); }