コード例 #1
1
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            _isNewPageInstance = true;
            mainPageModel = new MainPageModel();


            DateTime dateTemp = (DateTime)datePicker1.Value;
            date = dateTemp.ToString("yyyyMMdd");
            System.Diagnostics.Debug.WriteLine("date in Constructor: " + date + ", " + dateTemp.ToString());

            DateTime timeTemp = (DateTime)timePicker1.Value;
            time = timeTemp.ToString("HHmm");
            System.Diagnostics.Debug.WriteLine("time in Constructor: " + time + ", " + timeTemp.ToString());
           
            timetype = "departure";

            isFromTextBox = true;
            System.Diagnostics.Debug.WriteLine("isFromTextBox in constructor: " + isFromTextBox);

            fromToAddressRequestResult = new List<Geocoding>();
            stopsInAreaRequestResult = new List<StopsInArea>();

            coordsList = new List<String>();

            //location
            if (watcher == null)
            {
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
                watcher.MovementThreshold = 20;
                watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
                watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
                watcher.Start();
            }
        }
コード例 #2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);


            if (_isNewPageInstance)
            {
                
                System.Diagnostics.Debug.WriteLine(PhoneApplicationService.Current.State.Count);
                if (PhoneApplicationService.Current.State.Count > 0)
                {
                    if(PhoneApplicationService.Current.State.ContainsKey("mainPageModel"))
                    {
                        mainPageModel = (MainPageModel)PhoneApplicationService.Current.State["mainPageModel"];
                        fromTextBox.Text = (String)mainPageModel.fromTextBoxText;
                        toTextBox.Text = (String)mainPageModel.toTextBoxText;
                        coordsList = (List<String>)mainPageModel.fromToCoordsList;
                        fromCoords = (String)mainPageModel.fromCoords;
                        toCoords = (String)mainPageModel.toCoords;
                        date = (String)mainPageModel.date;
                        time = (String)mainPageModel.time;
                        isFromTextBox = (Boolean)mainPageModel.isFromTextBox;
                        pivotSelectedIndex = (int)mainPageModel.pivotSelectedIndex;

                        System.Diagnostics.Debug.WriteLine("isFromTextBox in Navigation: " + mainPageModel.isFromTextBox);
                    }
                    else
                        System.Diagnostics.Debug.WriteLine("no key ");
                }

                PhoneApplicationService.Current.State.Clear();
            }
            _isNewPageInstance = false;

            //Pivot Item: Route Search
            if (pivotSelectedIndex == 0)
            {
                //get value from one page's name
                string addressChosed = "";
                string itemIndexStr;
                if (NavigationContext.QueryString.TryGetValue("selectedItem", out addressChosed))
                {
                    if (isFromTextBox == true)
                    {
                        fromTextBox.Text = addressChosed;
                    }
                    else
                    {
                        toTextBox.Text = addressChosed;
                    }
                }
                //get value from another name from same or another page 
                if (NavigationContext.QueryString.TryGetValue("itemIndex", out itemIndexStr))
                {
                    itemIndex = Convert.ToInt32(itemIndexStr);
                    System.Diagnostics.Debug.WriteLine("received itemIndex: " + itemIndex + "coordsList length: " + coordsList.Count);

                    if (isFromTextBox == true)
                    {
                        fromCoords = coordsList[itemIndex];
                        System.Diagnostics.Debug.WriteLine("fromCoords: " + fromCoords);
                    }
                    else
                    {
                        toCoords = coordsList[itemIndex];
                        System.Diagnostics.Debug.WriteLine("toCoords: " + toCoords);
                    }
                }
            }

            //Pivot Item:
            if (pivotSelectedIndex == 1)
            {
            }

            //Pivot Item:
            if (pivotSelectedIndex == 2)
            {
            }

            //Pivot Item:
            if (pivotSelectedIndex == 3)
            {
            }

            //Pivot Item:
            if (pivotSelectedIndex == 4)
            {
            }

        }