private void refreshDates()
        {
            // update the BegindDate / EndDate
            DateTime begin = this.BeginDate;

            if (this.Tasks.Count(t => t.SignificantDate.HasValue && t.SignificantDate < DateTime.MaxValue.Date) > 0)
            {
                begin = this.Tasks.Where(t => t.SignificantDate.HasValue && t.SignificantDate < DateTime.MaxValue.Date).Min(t => t.SignificantDate.Value);
            }

            DateTime end = this.EndDate;

            if (this.Tasks.Count(t => t.SignificantDate.HasValue && t.SignificantDate < DateTime.MaxValue.Date) > 0)
            {
                end = this.Tasks.Where(t => t.SignificantDate.HasValue && t.SignificantDate < DateTime.MaxValue.Date).Max(t => t.SignificantDate.Value);
            }

            // adjust the dates (we want to get the range of dates for all of the visible data but always show at least 1 month
            // in the past and 1 month the future. we won't show events more than 1 year in the past or 1 year in the future

            begin = DateMath.Min(begin, DateTime.Today.AddMonths(-2));
            begin = DateMath.Max(begin, DateTime.Today.AddYears(-1));

            end = DateMath.Max(end, DateTime.Today.AddMonths(2));
            end = DateMath.Min(end, DateTime.Today.AddYears(1));

            // set the props
            this.BeginDate = begin;
            this.EndDate   = end;

            // calculate the width of the panel

            // generate a collection of dates that we can use to populate
            // the labels on our timeline

            m_dates.Clear();
            m_months.Clear();


            DateTime date = begin;

            m_months.Add(new DateTime(date.Year, date.Month, 1));

            while (date <= end)
            {
                m_dates.Add(date);
                date = date.AddDays(1);

                if (date.Day == 1)
                {
                    m_months.Add(new DateTime(date.Year, date.Month, 1));
                }
            }
        }
예제 #2
0
        private void new_task_committed(object sender, EventArgs e)
        {
            Debug.Assert(m_newTask != null);
            var newTask = m_taskList.AddTask(m_newTask.Task, App.Root.FolderColorOptions);

            m_unfilteredTaskList.Add(new TaskViewModel(newTask));
            m_taskList.CurrentFolder = newTask.EffectiveFolder;

            CancelNewTask();
        }
예제 #3
0
        public TaskListViewModel(TaskData taskList, Func <Task, bool> filter)
        {
            Util.RequireNotNull(taskList, "taskList");
            m_taskList = taskList;
            ((INotifyCollectionChanged)m_taskList.Tasks).CollectionChanged += (sender, args) => RefreshFilter();

            Util.RequireNotNull(filter, "filter");
            m_filter = filter;

            m_unfilteredTaskList = new ObservableCollectionPlus <TaskViewModel>();
            m_taskList.Tasks.ForEach(t => m_unfilteredTaskList.Add(new TaskViewModel(t)));

            // Tasks
            m_newTaskCommand       = new CommandWrapper(ShowNewTask, () => m_newTask == null);
            m_cancelNewTaskCommand = new CommandWrapper(() => CancelNewTask(), () => m_newTask != null);
            m_deleteTaskCommand    = new CommandWrapper <Task>(task => DeleteTask(task), task => true);
        }
예제 #4
0
        public TaskListViewModel(TaskData taskList, Func<Task, bool> filter)
        {
            Contract.Requires(null != taskList, "taskList");
            m_taskList = taskList;
            ((INotifyCollectionChanged)m_taskList.Tasks).CollectionChanged += (sender, args) => RefreshFilter();

            Contract.Requires(null != filter, "filter");
            m_filter = filter;

            m_unfilteredTaskList = new ObservableCollectionPlus<TaskViewModel>();
            m_taskList.Tasks.ForEach(t => m_unfilteredTaskList.Add(new TaskViewModel(t)));

            // Tasks
            m_newTaskCommand = new DelegateCommand(ShowNewTask, () => m_newTask == null);
            m_cancelNewTaskCommand = new DelegateCommand(() => CancelNewTask(), () => m_newTask != null);
            m_deleteTaskCommand = new DelegateCommand<Task>(task => DeleteTask(task), task => true);
        }
예제 #5
0
        public static DemoCollection <T> Create(IList <T> source, int initialCount, int minCount, int maxCount)
        {
            Contract.Requires(source != null);
            Contract.Requires(source.Count > 0);
            Contract.Requires(initialCount >= 0);
            Contract.Requires(minCount >= 0);
            Contract.Requires(minCount <= initialCount);
            Contract.Requires(initialCount <= maxCount);

            var sourceItems = source.ToReadOnlyCollection();

            var observableCollection = new ObservableCollectionPlus <T>();

            for (int i = 0; i < initialCount; i++)
            {
                observableCollection.Add(sourceItems[i % sourceItems.Count]);
            }

            return(new DemoCollection <T>(sourceItems, observableCollection, minCount, maxCount, initialCount));
        }