コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: yuqiqian/Copacescc
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
     var sampleDataGroups = await MainPageItemsSource.GetGroupsAsync();
     this.DefaultViewModel["Groups"] = sampleDataGroups;
 }
コード例 #2
0
 /// <summary>
 ///     To load data when the page starts
 /// </summary>
 private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
     if (e.PageState == null)
     {
         var param = e.NavigationParameter as NewSurveyPageNavParameter;
         DefaultViewModel.RoadSurvey = param.RoadSurvey;
         DefaultViewModel.Segments = param.Segments;
         lastSurveyIndex = 0;
         surveyedIndex = new LinkedList<Int32>();
         //CheckBoxCopyFromLastSegment.IsChecked = GlobalPreferences.CopyFromLastSegment;
         //CheckBoxCopyFromLastSurvey.IsChecked = GlobalPreferences.CopyFromLastSurvey;
         try
         {
             if (!UsingLogicalPageNavigation() && SegmentViewSource.View != null)
             {
                 SegmentViewSource.View.MoveCurrentToFirst();
             }
         }
         catch (Exception excep)
         {
             NotificationHelper.ShowErrorMessage(excep.ToString());
         }
     }
     else
     {
         if (e.PageState.ContainsKey("SelectedItem") && SegmentViewSource.View != null)
         {
             SegmentViewSource.View.MoveCurrentTo(e.PageState["SelectedItem"]);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            ButtonEditSurvey.IsEnabled = false;
            ViewModel.AllRoads = await SyncHelper.GetLocalRoads();
            try
            {
                var selectedRoads = from rd in ViewModel.AllRoads
                                    where rd.PlaceId.Equals(DbHelper.Place.Id)
                                    where rd.isDeleted.Equals(false)
                                    select rd;
                ViewModel.Roads = selectedRoads;
                //ViewModel.Roads = ViewModel.AllRoads;
                if (ViewModel.AllRoads == null || ViewModel.AllRoads.FirstOrDefault() == null)
                {
                    NotificationHelper.ShowErrorMessage(
                        "Cannot found local copy of the road data. Please download the data by click the 'Sync Data' button");
                    return;
                }

                if (!UsingLogicalPageNavigation() && RoadsViewSource.View != null)
                {
                    RoadsViewSource.View.MoveCurrentToFirst();
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }

        }
コード例 #4
0
        /// <summary>
        ///     Used to create states when the page is first loaded
        /// </summary>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            
                if (e.PageState == null)
                {
                    var _road = await SyncHelper.GetLocalRoads();
                    ViewModel.AllRoads = _road.Where(rd => rd.isDeleted == false);
                    //var selectedRoads = from rd in ViewModel.AllRoads
                    //                    where rd.PlaceId.Equals(DbHelper.Place.Id)
                    //                    select rd;


                    //ViewModel.Roads = selectedRoads;
                    ViewModel.Roads = ViewModel.AllRoads;
                    if (ViewModel.AllRoads == null || ViewModel.AllRoads.FirstOrDefault() == null)
                    {
                        NotificationHelper.ShowErrorMessage(
                            "Cannot found local copy of the road data. Please download the data by click the 'Sync Data' button");

                        //ButtonStartNewSurvey.IsEnabled = false;
                        ButtonStartNewSurvey.IsEnabled = true;
                        ButtonContinueLastSurvey.IsEnabled = false;
                        return;
                    }

                    if (!UsingLogicalPageNavigation() && RoadsViewSource.View != null)
                    {
                        RoadsViewSource.View.MoveCurrentToFirst();
                    }
                }
                else
                {
                    SearchBox.QueryText = (string)e.PageState["QueryText"];
                    RoadListUnfinishedFilterCheckBox.IsChecked = (bool)e.PageState["UnfinishedFilterState"];
                    RoadListDateFilterCheckBox.IsChecked = (bool)e.PageState["DateFilterState"];
                    if (RoadListDateFilterCheckBox.IsChecked == true)
                        RoadListDateFilterDatePicker.Date = (DateTimeOffset)e.PageState["DateFilterData"];

                    if (String.IsNullOrEmpty(SearchBox.QueryText) &&
                        RoadListUnfinishedFilterCheckBox.IsChecked == false &&
                        RoadListDateFilterCheckBox.IsChecked == false)
                    {
                        ViewModel.AllRoads = await SyncHelper.GetLocalRoads();
                        var selectedRoads = from rd in ViewModel.AllRoads
                                            where rd.PlaceId.Equals(DbHelper.Place.Id)
                                            select rd;
                        ViewModel.Roads = selectedRoads;
                    }
                    else
                    {
                        SearchBox_OnQuerySubmitted(SearchBox, null);
                    }
                }

        }