Beispiel #1
0
        //右键删除课程(电脑)
        private async void btnCourse_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            e.Handled = true;

            try
            {
                Button btn = sender as Button;

                Match tagMatch = Regex.Match(btn.Tag.ToString(), @"\[(\d+?)\]\[(\d+?)\]");
                int   i        = int.Parse(tagMatch.Groups[1].Value);
                int   j        = int.Parse(tagMatch.Groups[2].Value);

                MessageDialog dialog = new MessageDialog("将要删除本节课,是吗?");
                dialog.Title = "温馨提示";
                dialog.Commands.Add(new UICommand("确定", async command =>
                {
                    CoursePage.Current.TipPanel.Visibility = Visibility.Visible;

                    await CourseDataService.DeleteCourse(weeklyList, i, j, weekOfTerm);

                    InitializeRootGrid(CoursePage.Current.CourseGrid);

                    CoursePage.Current.TipPanel.Visibility = Visibility.Collapsed;
                }));
                dialog.Commands.Add(new UICommand("取消"));

                await dialog.ShowAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }