Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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));
        }