async void HardwareButtons_BackPressed_DetailPage(object sender, BackPressedEventArgs e)
        {
            e.Handled = true;
            if (string.IsNullOrEmpty(ViewModel.Tasks.Title))
            {
                NavigateHelper.NavigateToPage(typeof(MainPage));
                return;
            }
            //此处最好进行一个判断,是更新还是新增操作,然后进行相关的数据库操作
            Task taskNeedAwait = null;
            FrameTransitionParam param = new FrameTransitionParam();
            if (this.IsNavigateForUpdate)//true表示更新
            {
                // 修改的数据
                param.UpdateTasks = ViewModel.Tasks;
                taskNeedAwait = ViewModel.UpdateTasks();
            }
            else//false 表示新增
            {
                param.NewTasks = ViewModel.Tasks;
                taskNeedAwait = ViewModel.AddTasks();
            }
            // 在跳转前取消注册
            HardwareButtons.BackPressed -= HardwareButtons_BackPressed_DetailPage;
            NavigateHelper.NavigateToPageWithParam(typeof(MainPage), param);

            await taskNeedAwait;
        }
예제 #2
0
 public async static void NavigateToPageWithParam(Type type, FrameTransitionParam param)
 {
     var frame = Window.Current.Content as Frame;
     await Window.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         frame.Navigate(type, param);
     });
 }
예제 #3
0
        private void TasksListItemContent_Tapped(object sender, TappedRoutedEventArgs e)
        {
            e.Handled = true;

            var taskItemControl = sender as TasksItemControl;
            if (taskItemControl == null)
            {
                return;
            }
            var tasksItem = taskItemControl.DataContext as Tasks;

            FrameTransitionParam param = new FrameTransitionParam { Tasks = tasksItem };

            NavigateHelper.NavigateToPageWithParam(typeof(TasksDetailPageSimple), param);
        }
예제 #4
0
        ///// <summary>
        ///// 点击任务列表,跳转taskdetail页面
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void TasksListItem_Clicked(object sender, ItemClickEventArgs e)
        //{
        //    //与修改要有一个标识进行区分,标识就是判断是否存在tasks
        //    FrameTransitionParam param = new FrameTransitionParam { Projects = ViewModel.ProjectsSelected as Projects, Tasks = e.ClickedItem as Tasks };

        //    NavigateHelper.NavigateToPageWithParam(typeof(TasksDetailPageSimple), param);
        //}


        /// <summary>
        /// 点击新增按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AppBarAdd_Clicked(object sender, RoutedEventArgs e)
        {
            //与修改要有一个标识进行区分,可以创建一个临时对象,进行数据传递
            FrameTransitionParam param = new FrameTransitionParam { Projects = ViewModel.ProjectsSelected as Projects };

            NavigateHelper.NavigateToPageWithParam(typeof(TasksDetailPageSimple), param);
        }
예제 #5
0
        private async Task DealWithFrameTransitionParam(FrameTransitionParam param)
        {
            if (param != null)
            {
                if (param.TasksIdFromToast != null)
                {
                    var toastTasks = ViewModel.Tasks.FirstOrDefault(t => t.Id == param.TasksIdFromToast);
                    if (toastTasks == null)
                    {
                        await MessageDialogHelper.MessageDialogShowAsync("该任务已在其他端被删除", "提示");
                    }
                    else
                    {
                        ViewModel.ToastTasks = toastTasks;
                        this.txtToastTasksTitle.Text = ViewModel.ToastTasks.Title;
                        this.txtToastTasksDueTime.Text = ViewModel.ToastTasks.DueDate.ToString();
                        this.cmbToastTasksSnooze.ItemsSource = SelectionListEnum.SnoozeBackTimeSelectionList;
                        this.cmbToastTasksSnooze.DisplayMemberPath = "Name";
                        this.cmbToastTasksSnooze.SelectedValuePath = "SnoozeBackValue";

                        if (this.cmbToastTasksSnooze.SelectedIndex == -1)
                        {
                            this.cmbToastTasksSnooze.SelectedIndex = 0;
                        }

                        this.popupToastTasksDetail.Width = Window.Current.Bounds.Width;
                        this.popupToastTasksDetail.Visibility = Windows.UI.Xaml.Visibility.Visible;
                        this.popupToastTasksDetail.IsOpen = true;
                    }
                }
                //从修改页面传过来的数据,为了不再从数据库重新查一次。
                if (param.NewTasks != null)
                {
                    ViewModel.Tasks.Add(param.NewTasks);
                }
                if (param.UpdateTasks != null)
                {
                    var oldTasks = ViewModel.Tasks.FirstOrDefault(t => t.Id == param.UpdateTasks.Id);
                    if (oldTasks != null)
                    {
                        ViewModel.Tasks.Remove(oldTasks);
                    }
                    ViewModel.Tasks.Insert(0, param.UpdateTasks);
                }
            }
        }