示例#1
0
        //メインページに移動してきた時の処理。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(this.Foreground);

            if ((bool)IsolatedStorageSettings.ApplicationSettings["FirstTimeMessagePop"] == false)
            {
                var result = MessageBox.Show("In order to display your location and provide optimal user experience, we need access to your current location.Your location information will not be stored or shared, and you can always disable this feature in the settings page. Do you want to enable access to location service?", "Location Service", MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.OK)
                {
                    IsolatedStorageSettings.ApplicationSettings["LocationService"] = true;
                }
                IsolatedStorageSettings.ApplicationSettings["FirstTimeMessagePop"] = true;
            }

            PermissionOfLocationService = (bool)IsolatedStorageSettings.ApplicationSettings["LocationService"];

            //センサーとデータベースのインスタンス作成
            if (Sensor == null)
            {
                Sensor = new MySensors();
            }
            //if (DB == null)
            //    DB = new AppDB();


            Sensor.UserPermission = PermissionOfLocationService;


            //分離ストレージの設定情報読み込み
            TimeSpanRefreshCompass_main   = (double)IsolatedStorageSettings.ApplicationSettings["TimeSpanRefreshCompass_main"];
            FactorToCorrectDirection_main = (double)IsolatedStorageSettings.ApplicationSettings["FactorToCorrectDirection_main"];
            PreferredEmail = (string)IsolatedStorageSettings.ApplicationSettings["PreferredEmail"];



            //センサー初期化
            Sensor.GpsMovementThreshold  = (double)IsolatedStorageSettings.ApplicationSettings["DistanceUpdateGPS_sensor"];
            Sensor.UpdateCompassTimeSpan = (double)IsolatedStorageSettings.ApplicationSettings["TimeSpanUpdateCompass_sensor"];
            //Sensor.AvgSpeed = (double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"];
            //平均速度のリセット
            if ((bool)IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] == true)
            {
                Sensor.ResetAvgSpeed((double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"]);
                IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] = false;
            }
            else
            {
                Sensor.AvgSpeed = (double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"];
            }
            Sensor.CompassDataChanged += sensor_CompassDataChanged;
            Sensor.GPSDataChanged     += sensor_GPSDataChanged;
            Sensor.GPSStatusChanged   += sensor_GPSStatusChanged;
            Sensor.Start();

            //タイマー初期化
            initTimer();

            //ピンデータの読み込み
            //PushPinView = DB.LoadInfoFromXML();
            PushPinView = MyApp.PushPinView;
            Target      = PushPinView.GetTarget();



            //状態確認
            //GPS情報を受信しているか。statusがreadyかどうか。
            //されていなければ、現在地経緯度、目的地方位、目的地距離、ETA、所要時間は非表示
            //目的地は設定されているか。Targetがnullではないかどうか。
            //されていなければ、目的地名、目的地経緯度、目的地方位、目的地距離、ETA、所要時間は非表示
            initDisplay();

            base.OnNavigatedTo(e);
        }
        //ページに移動してきた時の処理。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Grid_SearchBox.Visibility = Visibility.Collapsed;

            PermissionOfLocationService = (bool)IsolatedStorageSettings.ApplicationSettings["LocationService"];
            if (Sensor == null)
            {
                Sensor = new MySensors();
            }
            //if (DB == null)
            //    DB = new AppDB();

            Sensor.UserPermission = PermissionOfLocationService;

            //現在地マークの初期化
            CurrentMark.PositionOrigin = PositionOrigin.Center;
            CurrentMark.Visibility     = Visibility.Collapsed;

            //候補地ピンの初期化。配置はしない。
            candidatePin.Content = new TextBlock()
            {
                Text = "", Margin = new Thickness(3)
            };
            var candidate_color = Utility.GetColorFromHexString(CandidateColor_Hex);

            candidatePin.Background = new SolidColorBrush(candidate_color);



            LineTwoPoint.Locations.Clear();
            TP = new TwoPoint();
            Grid_TwoPoint_Distance.Visibility = Visibility.Collapsed;
            TP.Clear();
            refreshTwoPointLine();

            MapKind = (string)IsolatedStorageSettings.ApplicationSettings["Map"];
            if (MapKind == "gMap")
            {
                MapTileLayer_gMap.Width = 480;
            }
            else
            {
                MapTileLayer_gMap.Width = 0;
            }

            if ((bool)isolateStore["MapPageLockPin"] == true)
            {
                TextBlock_LockPin.Text             = "Lock";
                MapItemsControl_PushPins.IsEnabled = false;
            }
            else
            {
                TextBlock_LockPin.Text             = "Unlock";
                MapItemsControl_PushPins.IsEnabled = true;
            }

            //平均速度のリセット
            if ((bool)IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] == true)
            {
                Sensor.ResetAvgSpeed((double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"]);
                IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] = false;
            }
            else
            {
                Sensor.AvgSpeed = (double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"];
            }

            DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler <NetworkNotificationEventArgs>(DeviceNetworkInformation_NetworkAvailabilityChanged);
            TimeSpanRefreshCompass_map   = (double)IsolatedStorageSettings.ApplicationSettings["TimeSpanRefreshCompass_map"];
            FactorToCorrectDirection_map = (double)IsolatedStorageSettings.ApplicationSettings["FactorToCorrectDirection_map"];

            Sensor.GpsMovementThreshold  = (double)IsolatedStorageSettings.ApplicationSettings["DistanceUpdateGPS_sensor"];
            Sensor.UpdateCompassTimeSpan = (double)IsolatedStorageSettings.ApplicationSettings["TimeSpanUpdateCompass_sensor"];

            Sensor.GPSDataChanged     += Sensor_GPSDataChanged;
            Sensor.GPSStatusChanged   += Sensor_GPSStatusChanged;
            Sensor.CompassDataChanged += Sensor_CompassDataChanged;
            Sensor.Start();

            //PushPinView = DB.LoadInfoFromXML();
            PushPinView = MyApp.PushPinView;
            Target      = PushPinView.GetTarget();

            //プロパティ変更イベントハンドラを設定
            foreach (var item in PushPinView.PushPins)
            {
                item.PropertyChanged += new PropertyChangedEventHandler(Pin_PropertyChanged);
            }
            DataContext = PushPinView;


            var    centerLocation = new GeoCoordinate();
            double currentZoomLevel;

            if (NavigationContext.QueryString.Count > 0 && e.NavigationMode == NavigationMode.New)
            {
                //System.Diagnostics.Debug.WriteLine(NavigationContext.QueryString.ToString());
                centerLocation.Latitude  = Convert.ToDouble(NavigationContext.QueryString["Latitude"]);
                centerLocation.Longitude = Convert.ToDouble(NavigationContext.QueryString["Longitude"]);
                currentZoomLevel         = MyMap.ZoomLevel;
            }
            else
            {
                centerLocation.Latitude  = (double)isolateStore["CenterLatitude"];
                centerLocation.Longitude = (double)isolateStore["CenterLongitude"];
                currentZoomLevel         = (double)isolateStore["ZoomLevel"];
            }



            MyMap.SetView(centerLocation, currentZoomLevel);


            initTimer();

            initDisplay();

            refreshLine();
            refreshTwoPointLine();

            base.OnNavigatedTo(e);
        }
示例#3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            PermissionOfLocationService = (bool)IsolatedStorageSettings.ApplicationSettings["LocationService"];
            if (Sensor == null)
            {
                Sensor = new MySensors();
            }
            //if (DB == null)
            //    DB = new AppDB();

            Sensor.UserPermission = PermissionOfLocationService;

            calcOnceFlag = false;

            //いろいろ非表示に
            //Grid_SearchBox.Visibility = Visibility.Collapsed;//検索ボックスは非表示に
            //Grid_SortOption.Visibility = Visibility.Collapsed;
            //Button_ResetSearch.Visibility = Visibility.Collapsed;

            PreferredEmail = (string)IsolatedStorageSettings.ApplicationSettings["PreferredEmail"];
            SortBy         = (string)IsolatedStorageSettings.ApplicationSettings["Sort"];
            SearchKeyword  = (string)IsolatedStorageSettings.ApplicationSettings["SearchKeyword"];


            //PushPinView = DB.LoadInfoFromXML();//データ読み込み
            PushPinView = MyApp.PushPinView;

            if (PushPinView.PushPins.Count == 0)
            {
                TextBlock_NoItemSign.Visibility = Visibility.Visible;
            }
            else
            {
                TextBlock_NoItemSign.Visibility = Visibility.Collapsed;
            }

            //DataContext = Source;
            MyCollection.Source      = PushPinView.PushPins;//collectionViewSourceに目的地情報をセット
            MyCollection.View.Filter = null;
            //MyCollection.View.SortDescriptions.Clear();

            initList();

            TextBox_SearchBox.Text = SearchKeyword;

            setOpacityAndColorForList();

            //センサーインスタンスの初期化
            //平均速度のリセット
            if ((bool)IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] == true)
            {
                Sensor.ResetAvgSpeed((double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"]);
                IsolatedStorageSettings.ApplicationSettings["AverageSpeedChanged"] = false;
            }
            else
            {
                Sensor.AvgSpeed = (double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"];
            }
            //Sensor.AvgSpeed = (double)IsolatedStorageSettings.ApplicationSettings["AverageSpeed"];
            Sensor.GpsMovementThreshold  = (double)IsolatedStorageSettings.ApplicationSettings["DistanceUpdateGPS_sensor"];
            Sensor.UpdateCompassTimeSpan = (double)IsolatedStorageSettings.ApplicationSettings["TimeSpanUpdateCompass_sensor"];
            Sensor.GPSDataChanged       += Sensor_GPSDataChanged;
            Sensor.Start();

            TextBox_SearchBox.Text = SearchKeyword;

            base.OnNavigatedTo(e);
        }