コード例 #1
0
        public async void OnNavigatedTo(object parameter)
        {
            this.SetRequestedTheme();

            if (this.currentViewModel != null)
            {
                bool cancel = await this.currentViewModel.ShouldCancelChangesAsync();

                if (cancel)
                {
                    return;
                }
            }

            if (parameter is ITask)
            {
                // edit mode
                this.currentViewModel = this.editViewModel;
                this.editViewModel.LoadTask((ITask)parameter);
            }
            else
            {
                // creation mode
                this.currentViewModel = this.createViewModel;
                if (parameter is TaskCreationParameters)
                {
                    this.createViewModel.UseTaskCreationParameters((TaskCreationParameters)parameter);
                }
            }

            this.DataContext = this.currentViewModel;
            this.Bindings.Update();
            this.NotesEditor.SetRichEditBoxContentFromViewModel();
        }
コード例 #2
0
        public override bool Execute(KeyRoutedEventArgs e)
        {
            MainPageViewModel mainPageViewModel = this.GetCurrentPageDataContextAs <MainPageViewModel>();
            TaskViewModelBase taskViewModel     = this.GetCurrentPageDataContextAs <TaskViewModelBase>();

            if (mainPageViewModel != null)
            {
                mainPageViewModel.SpeechCommand.Execute(null);
                return(true);
            }
            else if (taskViewModel != null)
            {
                taskViewModel.StartSpeechTitleCommand.Execute(null);
                return(true);
            }

            return(false);
        }
コード例 #3
0
        public TaskPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.NotesEditor.SkipDisposeOnUnload = true;

            this.BtnAddDueDate.Tapped   += this.OnBtnTapped;
            this.BtnAddStartDate.Tapped += this.OnBtnTapped;
            this.BtnAddReminder.Tapped  += this.OnBtnTapped;
            this.BtnAddFrequency.Tapped += this.OnBtnTapped;
            this.BtnAddProgress.Tapped  += this.OnBtnTapped;
            this.BtnAddTags.Tapped      += this.OnBtnTapped;
            this.BtnAddContext.Tapped   += this.OnBtnTapped;
            this.BtnAddSubtask.Tapped   += this.OnBtnTapped;
            this.BtnFolder.Tapped       += this.OnBtnTapped;
            this.BtnPriority.Tapped     += this.OnBtnTapped;

            this.Loaded += this.OnLoaded;
            this.ItemsControlEntries.SizeChanged += this.OnItemsControlEntriesSizeChanged;

            var navigationService = (NavigationService)Ioc.Resolve <INavigationService>();

            this.createViewModel           = Ioc.Build <CreateTaskViewModel>();
            this.createViewModel.Disposed += (s, e) =>
            {
                // do not dispose if the TaskPage is still shown as a flyout, eg. when user close the extended task notes flyout
                var peekFlyout = navigationService.PeekFlyout();
                if (peekFlyout == null || !(peekFlyout.Content is TaskPage))
                {
                    this.currentViewModel = null;
                }
            };

            this.editViewModel           = Ioc.Build <EditTaskViewModel>();
            this.editViewModel.Disposed += (s, e) =>
            {
                // do not dispose if the TaskPage is still shown as a flyout, eg. when user close the extended task notes flyout
                var peekFlyout = navigationService.PeekFlyout();
                if (peekFlyout == null || !(peekFlyout.Content is TaskPage))
                {
                    this.currentViewModel = null;
                }
            };
            this.editViewModel.NavigateNext     += (s, e) => this.Navigate(forward: true);
            this.editViewModel.NavigatePrevious += (s, e) => this.Navigate(forward: false);

            this.workbook = Ioc.Resolve <IWorkbook>();

            // sync folders
            this.workbook.FolderAdded += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                    this.currentViewModel.TargetFolder = this.workbook.Folders.LastOrDefault();
                }
            };
            this.workbook.FolderRemoved += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                    if (this.currentViewModel.TargetFolder == e.Item)
                    {
                        this.currentViewModel.TargetFolder = this.workbook.Folders.FirstOrDefault();
                    }
                }
            };
            this.workbook.FolderChanged += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                }
            };
            this.workbook.FoldersReordered += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                }
            };

            // sync contexts
            this.workbook.ContextAdded += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                    this.currentViewModel.TargetContext = this.workbook.Contexts.LastOrDefault();
                }
            };
            this.workbook.ContextRemoved += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                    if (this.currentViewModel.TargetContext == e.Item)
                    {
                        this.currentViewModel.TargetContext = this.workbook.Contexts.FirstOrDefault();
                    }
                }
            };
            this.workbook.ContextChanged += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                }
            };
            this.workbook.ContextsReordered += (s, e) =>
            {
                if (this.currentViewModel != null)
                {
                    this.currentViewModel.Refresh();
                }
            };
        }
コード例 #4
0
 public void OnNavigatedTo(object parameter)
 {
     this.taskViewModel = (TaskViewModelBase)parameter;
     this.DataContext   = this.taskViewModel;
 }
コード例 #5
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.viewModel = (TaskViewModelBase)this.DataContext;

            this.everyFrequency = null;
            this.daysFrequency  = null;
            this.eachFrequency  = null;

            this.cbDay1.IsChecked = false;
            this.cbDay2.IsChecked = false;
            this.cbDay3.IsChecked = false;
            this.cbDay4.IsChecked = false;
            this.cbDay5.IsChecked = false;
            this.cbDay6.IsChecked = false;
            this.cbDay7.IsChecked = false;

            var selectedFrequency = this.viewModel.SelectedFrequency;

            if (selectedFrequency != null && selectedFrequency.IsCustom)
            {
                var frequency = selectedFrequency;

                if (frequency.CustomFrequency is EveryXPeriodFrequency)
                {
                    this.everyFrequency    = frequency;
                    this.rbEvery.IsChecked = true;
                }
                else if (frequency.CustomFrequency is DaysOfWeekFrequency)
                {
                    this.daysFrequency    = frequency;
                    this.rbDays.IsChecked = true;

                    var daysOfweekFrequency = (DaysOfWeekFrequency)frequency.CustomFrequency;

                    this.cbDay1.IsChecked = daysOfweekFrequency.IsMonday;
                    this.cbDay2.IsChecked = daysOfweekFrequency.IsTuesday;
                    this.cbDay3.IsChecked = daysOfweekFrequency.IsWednesday;
                    this.cbDay4.IsChecked = daysOfweekFrequency.IsThursday;
                    this.cbDay5.IsChecked = daysOfweekFrequency.IsFriday;
                    this.cbDay6.IsChecked = daysOfweekFrequency.IsSaturday;
                    this.cbDay7.IsChecked = daysOfweekFrequency.IsSunday;
                }
                else if (frequency.CustomFrequency is OnXDayFrequency)
                {
                    this.eachFrequency           = frequency;
                    this.rbDaysOfMonth.IsChecked = true;
                }

                if (frequency.UseFixedDate)
                {
                    this.rbRepeatDueDate.IsChecked = true;
                }
                else
                {
                    this.rbRepeatTaskCompletes.IsChecked = true;
                }
            }
            else
            {
                this.rbEvery.IsChecked = true;

                if (selectedFrequency != null)
                {
                    if (selectedFrequency.CustomFrequency is DailyFrequency)
                    {
                        this.cbRates.SelectedItem  = FrequencyMetadata.AvailableRates.FirstOrDefault(rate => rate.Value == 1);
                        this.cbScales.SelectedItem = FrequencyMetadata.AvailableScales.FirstOrDefault(scale => scale.Value == CustomFrequencyScale.Day);
                    }
                    else if (selectedFrequency.CustomFrequency is WeeklyFrequency)
                    {
                        this.cbRates.SelectedItem  = FrequencyMetadata.AvailableRates.FirstOrDefault(rate => rate.Value == 1);
                        this.cbScales.SelectedItem = FrequencyMetadata.AvailableScales.FirstOrDefault(scale => scale.Value == CustomFrequencyScale.Week);
                    }
                    else if (selectedFrequency.CustomFrequency is MonthlyFrequency)
                    {
                        this.cbRates.SelectedItem  = FrequencyMetadata.AvailableRates.FirstOrDefault(rate => rate.Value == 1);
                        this.cbScales.SelectedItem = FrequencyMetadata.AvailableScales.FirstOrDefault(scale => scale.Value == CustomFrequencyScale.Month);
                    }
                    else if (selectedFrequency.CustomFrequency is YearlyFrequency)
                    {
                        this.cbRates.SelectedItem  = FrequencyMetadata.AvailableRates.FirstOrDefault(rate => rate.Value == 1);
                        this.cbScales.SelectedItem = FrequencyMetadata.AvailableScales.FirstOrDefault(scale => scale.Value == CustomFrequencyScale.Year);
                    }
                }

                if (selectedFrequency != null && !selectedFrequency.UseFixedDate)
                {
                    this.rbRepeatTaskCompletes.IsChecked = true;
                }
                else
                {
                    this.rbRepeatDueDate.IsChecked = true;
                }
            }

            if (this.everyFrequency == null)
            {
                this.everyFrequency = new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.EveryXPeriod));
            }

            if (this.daysFrequency == null)
            {
                this.daysFrequency = new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.DaysOfWeek));
            }

            if (this.eachFrequency == null)
            {
                this.eachFrequency = new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.OnXDayOfEachMonth));
            }

            this.areaEvery.DataContext        = this.everyFrequency.CustomFrequency;
            this.areaSpecificDays.DataContext = this.daysFrequency.CustomFrequency;
            this.areaDaysOfMonth.DataContext  = this.eachFrequency.CustomFrequency;

            if (this.cbRates.SelectedItem == null)
            {
                this.cbRates.SelectedItem = FrequencyMetadata.AvailableRates.FirstOrDefault(rate => rate.Value == this.everyFrequency.Custom <EveryXPeriodFrequency>().Rate);
            }

            if (this.cbScales.SelectedItem == null)
            {
                this.cbScales.SelectedItem = FrequencyMetadata.AvailableScales.FirstOrDefault(scale => scale.Value == this.everyFrequency.Custom <EveryXPeriodFrequency>().Scale);
            }

            this.cbRankings.SelectedItem = FrequencyMetadata.AvailableRankings.FirstOrDefault(ranking => ranking.Value == this.eachFrequency.Custom <OnXDayFrequency>().RankingPosition);
            this.cbDays.SelectedItem     = FrequencyMetadata.AvailableDays.FirstOrDefault(day => day.Value == this.eachFrequency.Custom <OnXDayFrequency>().DayOfWeek);
        }