Example #1
0
        public void InitializeLoginView()
        {
            string controlName = "viewControl";

            RemoveViewControl(controlName);
            LoginControlView viewControl = new LoginControlView();

            viewControl.Name     = "viewControl";
            viewControl.Location = new System.Drawing.Point(0, 0);
            this.Size            = new Size(350, 238);
            viewControl.TabIndex = 0;
            Controls.Add(viewControl);
            Presenter.InitializePresenter(viewControl);
            viewControl.Focus();
        }
        private void View_Login(object sender, LoginEventArgs e)
        {
            LoginControlView lc = sender as LoginControlView;

            if (lc != null)
            {
                if (CorrectUsernameAndPassword(e.Username, e.Password))
                {
                    _model.Login    = e.Username;
                    _model.Password = e.Password;
                    ViewChangedArgs args = new ViewChangedArgs(ViewType.Shop);
                    ViewChanged?.Invoke(this, args);
                }
                else
                {
                    _view.SetError(ConstantTexts.WrongUsernameOrPassword);
                }
            }
        }
 public LoginControlPresenter(Model model, LoginControlView view)
 {
     _view        = view;
     _model       = model;
     _view.Login += View_Login;
 }