public MainViewModel(IDesktopModel model) { if (model == null) { throw new ArgumentNullException("model"); } _model = model; _model.ArticleChanged += Model_ArticleChanged; _isLoaded = false; CreateArticleCommand = new DelegateCommand(param => { EditedArticle = new Article { PublishedAt = DateTime.Now, Author = "admin", }; OnArticleEditingStarted(); }); CreateImageCommand = new DelegateCommand(param => OnImageEditingStarted((param as Article).Id)); UpdateArticleCommand = new DelegateCommand(param => UpdateArticle(param as Article)); DeleteArticleCommand = new DelegateCommand(param => DeleteArticle(param as Article)); SaveChangesCommand = new DelegateCommand(param => SaveChanges()); CancelChangesCommand = new DelegateCommand(param => CancelChanges()); LoadCommand = new DelegateCommand(param => LoadAsync()); SaveCommand = new DelegateCommand(param => SaveAsync()); ExitCommand = new DelegateCommand(param => OnExitApplication()); }
private void App_Startup(object sender, StartupEventArgs e) { _model = new DesktopModel(new NewsService("http://localhost:53634")); // megadjuk a szolgáltatás címét _loginViewModel = new LoginViewModel(_model); _loginViewModel.ExitApplication += new EventHandler(ViewModel_ExitApplication); _loginViewModel.LoginSuccess += new EventHandler(ViewModel_LoginSuccess); _loginViewModel.LoginFailed += new EventHandler(ViewModel_LoginFailed); _loginView = new LoginWindow(); _loginView.DataContext = _loginViewModel; _loginView.Show(); }
public LoginViewModel(IDesktopModel model) { if (model == null) { throw new ArgumentNullException("model"); } _model = model; UserName = String.Empty; ExitCommand = new DelegateCommand(param => OnExitApplication()); LoginCommand = new DelegateCommand(param => LoginAsync(param as PasswordBox)); }