예제 #1
0
        public MainViewModel(MonthControlViewModel MonthVM)
        {
            MonthVM     = new MonthControlViewModel();
            YearVM      = new YearControlViewModel();
            SettVM      = new SettingsControlViewModel();
            CurrentView = MonthVM;

            MonthViewCommand = new RelayCommand(o =>
            {
                CurrentView = MonthVM;
            });
            YearViewCommand = new RelayCommand(o =>
            {
                CurrentView = YearVM;
            });
            AddTaskCommand = new RelayCommand(o =>
            {
                new AddTaskWindow().ShowDialog();
            });
            AddEventCommand = new RelayCommand(o =>
            {
                new AddEventWindow().ShowDialog();
            });
            AddContactCommand = new RelayCommand(o =>
            {
                new AddContactWindow().ShowDialog();
            });
            RegistrationCommand = new RelayCommand(o =>
            {
                new RegistrationWindow().ShowDialog();
            });
            SettingsCommand = new RelayCommand(o =>
            {
                CurrentView = SettVM;
            });
        }
예제 #2
0
        public MainViewModel(MonthControlViewModel MonthVM, User authorisedUser)
        {
            MonthVM        = new MonthControlViewModel(authorisedUser);
            YearVM         = new YearControlViewModel();
            CurrentView    = MonthVM;
            AuthorisedUser = authorisedUser;

            UserName = AuthorisedUser.Name;
            Img      = AuthorisedUser.Img;

            MonthViewCommand = new RelayCommand(o =>
            {
                CurrentView = MonthVM;
            });
            YearViewCommand = new RelayCommand(o =>
            {
                CurrentView = YearVM;
            });
            AddTaskCommand = new RelayCommand(o =>
            {
                AddTaskWindow taskWin = new AddTaskWindow()
                {
                    DataContext = new AddTaskViewModel(_authorisedauser, MonthVM)
                };
                taskWin.ShowDialog();
            });
            AddEventCommand = new RelayCommand(o =>
            {
                AddEventWindow taskWin = new AddEventWindow()
                {
                    DataContext = new AddEventViewModel(_authorisedauser, MonthVM)
                };
                taskWin.ShowDialog();
            });
            AddContactCommand = new RelayCommand(o =>
            {
                AddContactWindow taskWin = new AddContactWindow()
                {
                    DataContext = new AddContactViewModel(_authorisedauser)
                };
                taskWin.ShowDialog();
            });
            RegistrationCommand = new RelayCommand(o =>
            {
                UserWindow taskWin = new UserWindow()
                {
                    DataContext = new UserViewModel(AuthorisedUser, this)
                };
                taskWin.ShowDialog();
            });

            Registry registry = new Registry();

            registry.Schedule(() =>
            {
                foreach (Event _event in UnitOfWorkSingleton.Instance.Events.List)
                {
                    TimeSpan?diffresult = _event.StartTime - DateTime.Now;
                    if (diffresult <= TimeSpan.FromMinutes(60))
                    {
                        MessageBox.Show("Час до начала события: " + _event.Name);
                    }
                }
            }).ToRunNow().AndEvery(20).Minutes();
            JobManager.Initialize(registry);
        }