Exemplo n.º 1
0
        public static async Task<string> SyncAllRemind(MyRemind remind)
        {

            id = "";
            if (remind.Time != null)
            {
                int min = int.Parse(remind.Time) % 60;
                int hour = int.Parse(remind.Time) / 60;
                int day = hour / 24;
                TimeSpan beforeTime = new TimeSpan(day, hour, min, 0);


                List<SelectedWeekNum> weeklist = new List<SelectedWeekNum>();
                foreach (var item in remind.DateItems)
                {
                    var itemWeekList = item.Week.Split(',');
                    var itemClassList = int.Parse(item.Class);
                    var itemDayList = int.Parse(item.Day);
                    TimeSet classTime = new TimeSet();
                    classTime.Set(itemClassList);
                    for (int i = 0; i < itemWeekList.Count(); i++)
                    {
                        SelectedWeekNum swn = new SelectedWeekNum();
                        //TODO 周数是是从第一周开始所以week设置要减一
                        swn.SetWeekTime(int.Parse(itemWeekList[i]) - 1);
                        remind.time = swn.WeekNumOfMonday.AddDays(itemDayList) + classTime.Time - beforeTime;
                        if (remind.time.Ticks < DateTime.Now.Ticks)
                        {

                        }
                        else
                        {
                            await AddRemind(remind);
                        }
                    }
                }
            }
            return id;
        }
        //private void EditRemindPage_BackRequested(object sender, BackRequestedEventArgs e)
        //{
        //    if (SelRemindGrid.Visibility == Visibility.Visible)
        //    {
        //        SelRemindGrid.Visibility = Visibility.Visible;
        //        SystemNavigationManager.GetForCurrentView().BackRequested -= EditRemindPage_BackRequested ;
        //        SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
        //    }
        //    else
        //    {
        //        this.NavigationCacheMode = NavigationCacheMode.Disabled;
        //        this.Visibility = Visibility.Collapsed;
        //        SystemNavigationManager.GetForCurrentView().BackRequested -= EditRemindPage_BackRequested; 
        //        SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
        //    }
        //}

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter != null && !App.isLoad)
            {
                App.isLoad = true;
                App.SelectedTime.SelTimeString = "";
                App.selectedWeek.WeekNumString = "";

                MyRemind temp = new MyRemind();
                temp = e.Parameter as MyRemind;
                tempID = temp.Id;
                int x = 0;
                for (int i = 0; i < beforeTime.Count; i++)
                {
                    if (temp.Time != null)
                    {

                        if (beforeTime[i].getBeforeTime() == int.Parse(temp.Time))
                        {
                            x = i;
                            break;
                        }
                    }
                    else
                        x = 0;
                }
                SelRemindListView.SelectedIndex = indexBefore = x;
                TitleTextBox.Text = temp.Title;

                ContentTextBox.Text = temp.Content;
                string s = temp.DateItems[0].Week;
                App.selectedWeek.WeekNumString = s + ",";
                string[] weekArray = s.Split(',');
                for (int i = 0; i < weekArray.Count(); i++)
                {
                    SelectedWeekNum wNum = new SelectedWeekNum()
                    {
                        WeekNum = int.Parse(weekArray[i])
                    };
                    wNum.SetWeekTime(int.Parse(weekArray[i]));
                    App.selectedWeekNumList.Add(wNum);
                }
                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < 7; j++)
                    {
                        App.timeSet[i, j] = new TimeSet();
                    }
                }
                foreach (var item in temp.DateItems)
                {
                    App.timeSet[int.Parse(item.Class), int.Parse(item.Day)].IsCheck = true;
                    App.SelectedTime.SelTimeString += CourseList(int.Parse(item.Class), int.Parse(item.Day)) + " ";
                }
            }

        }
        private void SaveSelected_Tapped(object sender, TappedRoutedEventArgs e)
        {
            App.selectedWeek.WeekNumString = "";
            App.selectedWeekNumList.Clear();
            for (int i = 0; i < SelWeekList.Count; i++)
            {
                if (SelWeekList[i].isSelected)
                {
                    SelectedWeekNum temp = new SelectedWeekNum() { WeekNum = i + 1 };
                    temp.SetWeekTime(i);
                    temp.WeekNumOfMonday.AddDays(-7);
                    App.selectedWeekNumList.Add(temp);
                    App.selectedWeek.WeekNumString += (i + 1).ToString() + "、";
                }
            }
            if (page == typeof(EditRemindPage))
            {
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                Frame.GoBack();
            }
            else
            {
                Frame rootFrame = Window.Current.Content as Frame;
                //rootFrame.Visibility = Visibility.Collapsed;
                this.Visibility = Visibility.Collapsed;

                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;


                //Frame.GoBack();
            }
            Debug.WriteLine(App.selectedWeek.WeekNumString);
        }