Beispiel #1
0
        public MainForm(IToDoListService toDoListService,
                        IToDoListDao toDoListDao, IToDoTaskDao toDoTaskDao)
        {
            InitializeComponent();

            _toDoListService = toDoListService;
            _toDoListDao     = toDoListDao;
            _toDoTaskDao     = toDoTaskDao;

            Text = Constants.AppName;
            Icon = Properties.Resources.List;

            buttonPrevious.Image = Properties.Resources.Left.ResizeTo(Constants.Sizes.DefaultNavigationImageSize);
            var rightArrowImage = Properties.Resources.Left.ResizeTo(Constants.Sizes.DefaultNavigationImageSize);

            rightArrowImage.RotateFlip(RotateFlipType.Rotate180FlipY);
            buttonNext.Image = rightArrowImage;

            buttonPickDate.Text = Constants.Interface.Main.PickDate;

            _toDoListModels = _toDoListService.PopulateToDoListCache()
                              .Select(tdl => new ToDoListModel(tdl)).ToList();

            var currentList = _toDoListModels
                              .FirstOrDefault(tdlm => tdlm.Date.ToShortDateString() == DateTime.Now.ToShortDateString())
                              ?? _toDoListModels.OrderByDescending(tdlm => tdlm.Date).FirstOrDefault();

            _currentToDoList = currentList;

            var toDoListControl = new ToDoListControl(currentList, _toDoListService, _toDoListDao, _toDoTaskDao);

            flowLayoutPanel1.Controls.Add(toDoListControl);
        }
Beispiel #2
0
        private void buttonPickDate_Click(object sender, EventArgs e)
        {
            Action <DateTime> pickToDoListForDateAction = (pickedDate) =>
            {
                //Pick date and find 'ToDo List' for that date
                var listByDate = _toDoListDao.GetOneByDate(pickedDate);

                //If 'ToDo List' doesn't exist, create new one
                if (listByDate == null)
                {
                    var newList = _toDoListDao.Insert(ToDoList.New(pickedDate));
                    listByDate = newList;
                    _toDoListService.AddListToCache(listByDate);
                }

                // Create model for 'ToDoList' and display it
                flowLayoutPanel1.Controls.Clear();
                var listByDateModel = new ToDoListModel(listByDate);
                _currentToDoList = listByDateModel;

                var toDoListControl = new ToDoListControl(listByDateModel, _toDoListService, _toDoListDao, _toDoTaskDao);
                flowLayoutPanel1.Controls.Add(toDoListControl);
            };

            var datePickerForm = new DatePickerForm(pickToDoListForDateAction);

            datePickerForm.Show();
        }
Beispiel #3
0
        private void SwitchListControls(bool forward)
        {
            var nextList      = _toDoListService.PickNextToDoList(_currentToDoList, forward);
            var nextListModel = new ToDoListModel(nextList);

            _currentToDoList = nextListModel;
            var toDoListControl = new ToDoListControl(nextListModel, _toDoListService, _toDoListDao, _toDoTaskDao);

            flowLayoutPanel1.Controls.Clear();
            flowLayoutPanel1.Controls.Add(toDoListControl);
        }