Пример #1
0
        private void filteringByKeyword()
        {
            CompareInfo compInfo = System.Globalization.CultureInfo.CurrentCulture.CompareInfo;

            if (SearchKeyword != "")
            {
                //PivotItem1.Header = SearchKeyword;
                MyCollection.View.Filter = delegate(object o)
                {
                    PushPinModel pin = (o as PushPinModel);

                    string compString = pin.Name + pin.Address + pin.Note + pin.PhoneNum;

                    if (compInfo.IndexOf(compString, SearchKeyword, 0, CompareOptions.IgnoreCase) != -1)
                    {
                        return(true);
                    }
                    else if (compInfo.IndexOf(compString, SearchKeyword, 0, CompareOptions.IgnoreKanaType) != -1)
                    {
                        return(true);
                    }
                    return(false);
                };
                //Button_ResetSearch.Visibility = Visibility.Visible;
            }
            else
            {
                //PivotItem1.Header = "List";
                MyCollection.View.Filter = null;
                //Button_ResetSearch.Visibility = Visibility.Collapsed;
            }
        }
Пример #2
0
        private void Pushpin_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            pin_hold_flag = true;

            var holdedPin = (sender as Pushpin).DataContext as PushPinModel;

            var result = MessageBox.Show("Are you sure to delete ''" + holdedPin.Name + "'' ?", "Delete", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                if (holdedPin.Target == true)
                {
                    Target = null;

                    refreshLine();
                    refreshDistanceTextBlock();
                    TextBlock_TargetName.Text = "";
                }

                TP.Clear();
                refreshTwoPointLine();

                PushPinView.PushPins.Remove(holdedPin);

                //DB.SaveInfoToIsoStrage(PushPinView);
            }
        }
Пример #3
0
        void Pin_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var pin = sender as PushPinModel;

            if (e.PropertyName == "Target")
            {
                Target = pin;

                if (Target.Location.IsUnknown == false)
                {
                    Distance = Utility.CalcDistanceTo_Hubeny(Sensor.Location, Target.Location);
                    ETA      = Utility.CalcETA(Distance, Sensor.AvgSpeed);
                }
                TextBlock_TargetName.Text = Target.Name;
                refreshDistanceTextBlock();
                refreshLine();
            }
            if (e.PropertyName == "Location")
            {
                if (pin.Target == true)
                {
                    Target = pin;
                    if (Target.Location.IsUnknown == false)
                    {
                        Distance = Utility.CalcDistanceTo_Hubeny(Sensor.Location, Target.Location);
                        ETA      = Utility.CalcETA(Distance, Sensor.AvgSpeed);
                    }


                    refreshDistanceTextBlock();
                    refreshLine();
                }
                refreshTwoPointLine();
            }
        }
Пример #4
0
 public void SetTarget(PushPinModel item)
 {
     if (item == null)
     {
         return;
     }
     this.ClearTarget();
     item.Target = true;
     item.Color  = new SolidColorBrush(Utility.GetColorFromHexString(TargetColor_Hex));
 }
Пример #5
0
        //メインページから離脱した時の処理。
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            if (doNotResume == true)
            {
                resume = null;
            }
            else
            {
                resume = new PushPinModel();
                if (TextBox_Latitude.Text != "")
                {
                    resume.Location.Latitude = Convert.ToDouble(TextBox_Latitude.Text);
                }
                else
                {
                    resume.Location.Latitude = Double.NaN;
                }
                if (TextBox_Longitude.Text != "")
                {
                    resume.Location.Longitude = Convert.ToDouble(TextBox_Longitude.Text);
                }
                else
                {
                    resume.Location.Longitude = Double.NaN;
                }
                resume.Name     = TextBox_Name.Text;
                resume.Color    = new SolidColorBrush(Utility.GetColorFromHexString(PushPinView.DefaultColor_Hex));
                resume.Address  = TextBox_Address.Text;
                resume.PhoneNum = TextBox_PhoneNum.Text;
                resume.Note     = TextBox_Note.Text;

                if (CheckBox_IsVisible.IsChecked == true)
                {
                    resume.Visibility = Visibility.Visible;
                }
                else
                {
                    resume.Visibility = Visibility.Collapsed;
                }

                if (CheckBox_IsTarget.IsChecked == true)
                {
                    resume.Target = true;
                }
                else
                {
                    resume.Target = false;
                }

                resume.CreateDate = DateTime.Parse(TextBlock_CreateDate.Text);
            }

            //DB.SaveInfoToIsoStrage(PushPinView);
            base.OnNavigatedFrom(e);
        }
Пример #6
0
 public void SetSelected(PushPinModel item)
 {
     this.ClearSelected();
     if (item == null)
     {
         return;
     }
     item.Selected  = true;
     item.Color     = new SolidColorBrush(Utility.GetColorFromHexString(SelectedColor_Hex));
     item.ListColor = new SolidColorBrush(Utility.ConvertToFullOpacityColor(item.Color.Color));
 }
Пример #7
0
 public void Add(PushPinModel pin)
 {
     if (Point1.Location.IsUnknown == true)
     {
         Point1 = pin;
     }
     else if (Point2.Location.IsUnknown == true)
     {
         Point2 = pin;
     }
     else
     {
         Point1 = Point2;
         Point2 = pin;
     }
 }
Пример #8
0
        private void Pushpin_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            MyMap.IsEnabled = false;

            var doubleTappedPin = (sender as Pushpin).DataContext as PushPinModel;

            PushPinView.SetTarget(doubleTappedPin);
            Target = PushPinView.GetTarget();

            refreshLine();
            refreshDistanceTextBlock();
            TextBlock_TargetName.Text = Target.Name;

            var vc = VibrateController.Default;

            vc.Start(TimeSpan.FromMilliseconds(50));

            System.Threading.Thread.Sleep(500);

            MyMap.IsEnabled = true;
        }
Пример #9
0
        private void AddNewPin(GeoCoordinate location)
        {
            PushPinModel pin = new PushPinModel();

            pin.Location   = location; //new GeoCoordinate(holdLocation.Latitude, holdLocation.Longitude),
            pin.Name       = "New Place";
            pin.Color      = new SolidColorBrush(Utility.GetColorFromHexString(PushPinView.DefaultColor_Hex));
            pin.Note       = "";
            pin.IsEnabled  = true;
            pin.Selected   = false;
            pin.Target     = false;
            pin.Visibility = System.Windows.Visibility.Visible;
            pin.CreateDate = DateTime.Now;

            pin.PropertyChanged += Pin_PropertyChanged;

            PushPinView.PushPins.Add(pin);

            bool darkTheme = ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible);

            if (darkTheme == true)//darkの時は白抜きの画像
            {
                pin.ArrowURI  = "/Icons/appbar.next.rest.png";
                pin.CircleURI = "/Icons/appbar.basecircle.rest.png";
            }
            else
            {
                pin.ArrowURI  = "/Icons/appbar.next.rest.light.png";
                pin.CircleURI = "/Icons/appbar.base.png";
            }

            Dispatcher.BeginInvoke(() =>
            {
                //var holdLocation = MyMap.ViewportPointToLocation(e.GetPosition(MyMap));

                GeoCoding geoCode = new GeoCoding();
                geoCode.DownloadGeoCodeResultCompleted += geoCode_DownloadGeoCodeResultCompleted;
                geoCode.GetAddressFromGeoCoordinate(location);
            });
        }
Пример #10
0
        private void CurrentLocationContextMenuItemPintoMap_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            /*
             * if (Sensor.GpsStatus != GeoPositionStatus.Ready)
             *  return;
             */
            if (Sensor.Location.IsUnknown)
            {
                return;
            }
            PushPinModel pin = new PushPinModel
            {
                Location   = Sensor.Location, //new GeoCoordinate(holdLocation.Latitude, holdLocation.Longitude),
                Name       = "New Place",
                Color      = new SolidColorBrush(Utility.GetColorFromHexString(PushPinView.DefaultColor_Hex)),
                Note       = "",
                IsEnabled  = true,
                Selected   = false,
                Target     = false,
                Visibility = System.Windows.Visibility.Visible,
                CreateDate = DateTime.Now
            };

            bool darkTheme = ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible);

            if (darkTheme == true)//darkの時は白抜きの画像
            {
                pin.ArrowURI  = "/Icons/appbar.next.rest.png";
                pin.CircleURI = "/Icons/appbar.basecircle.rest.png";
            }
            else
            {
                pin.ArrowURI  = "/Icons/appbar.next.rest.light.png";
                pin.CircleURI = "/Icons/appbar.base.png";
            }


            PushPinView.PushPins.Add(pin);
            //DB.SaveInfoToIsoStrage(PushPinView);
        }
Пример #11
0
        private void Pushpin_OnDragStarted(object sender, DragStartedGestureEventArgs e)
        {
            MyMap.IsEnabled = false; // prevents the map from dragging w/ pushpin}

            #region  更前のコード

            /*
             * Pushpin draggingPin = sender as Pushpin;
             *
             * //MessageBox.Show(draggingPin.Parent.ToString());
             *
             * Point p = MyMap.LocationToViewportPoint(draggingPin.Location);
             * PushPin_Point.X = p.X;
             * PushPin_Point.Y = p.Y;
             *
             * var pins = from pin in PushPinViewModel.PushPins
             *         where pin.Location == (sender as Pushpin).Location
             *         select pin;
             * if (pins.Count() != 0)
             * {
             *  pin = pins.First();
             * }
             */
            #endregion

            //これをnewしておくと、ピンがかさなっていても一緒に動かない。
            //ただし、移動量は相変わらず重なっているピンの数に比例して2倍、3倍となる。
            PushPin_Point         = new Point();
            PushPin_GeoCoordinate = new GeoCoordinate();
            DraggingPin           = new PushPinModel();

            DraggingPin = (sender as Pushpin).DataContext as PushPinModel;
            //DraggingPin.Selected = true;
            PinName = DraggingPin.Name;
            Point p = MyMap.LocationToViewportPoint(DraggingPin.Location);
            PushPin_Point.X = p.X + 80;
            PushPin_Point.Y = p.Y - 120;
        }
Пример #12
0
 public void Clear()
 {
     Point1 = new PushPinModel();
     Point2 = new PushPinModel();
 }
Пример #13
0
        //ページに移動してきた時の処理。
        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);
        }
Пример #14
0
        //ページに移動してきた時の処理。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //if (DB == null)
            //    DB = new AppDB();

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

            //テーマがlightかdarkによって、電話マークの白、黒を切り替える。
            bool darkTheme = ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible);

            if (darkTheme == true)//darkの時は白抜きの画像
            {
                Image_Phone.Source      = new BitmapImage(new Uri("/Icons/MB_0008_phone.png", UriKind.RelativeOrAbsolute));
                Image_BaseCircle.Source = new BitmapImage(new Uri("/Icons/appbar.basecircle.rest.png", UriKind.RelativeOrAbsolute));
            }
            else//lightの時は黒抜きの画像
            {
                Image_Phone.Source      = new BitmapImage(new Uri("/Icons/MB_0008_phone2.png", UriKind.RelativeOrAbsolute));
                Image_BaseCircle.Source = new BitmapImage(new Uri("/Icons/appbar.base.png", UriKind.RelativeOrAbsolute));
            }

            TimeNow = DateTime.Now;

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

            edittype = NavigationContext.QueryString["EditingType"];
            if (NavigationContext.QueryString["EditingType"] == "New")//新規登録か登録済みか
            {
                newItemFlag = true;
            }
            else
            {
                newItemFlag = false;
            }

            if (resume != null)//レジュームデータから復元
            {
                TextBox_Name.Text = resume.Name;
                if (Double.IsNaN(resume.Location.Latitude) == false)
                {
                    TextBox_Latitude.Text = resume.Location.Latitude.ToString();
                }
                else
                {
                    TextBox_Latitude.Text = "";
                }
                if (Double.IsNaN(resume.Location.Longitude) == false)
                {
                    TextBox_Longitude.Text = resume.Location.Longitude.ToString();
                }
                else
                {
                    TextBox_Longitude.Text = "";
                }

                TextBox_Address.Text  = resume.Address;
                TextBox_PhoneNum.Text = resume.PhoneNum;
                TextBox_Note.Text     = resume.Note;

                if (resume.Target == true)
                {
                    CheckBox_IsTarget.IsChecked = true;
                }
                else
                {
                    CheckBox_IsTarget.IsChecked = false;
                }

                if (resume.Visibility == System.Windows.Visibility.Visible)
                {
                    CheckBox_IsVisible.IsChecked = true;
                }
                else
                {
                    CheckBox_IsVisible.IsChecked = false;
                }

                TextBlock_CreateDate.Text      = resume.CreateDate.ToString();
                TextBlock_CreateDayOfWeek.Text = resume.CreateDate.DayOfWeek.ToString();

                resume      = null;
                doNotResume = false;
            }
            else if (newItemFlag == true)//新規登録
            {
                TextBox_Name.Text            = "New Place";
                TextBox_Latitude.Text        = NavigationContext.QueryString["Latitude"];
                TextBox_Longitude.Text       = NavigationContext.QueryString["Longitude"];
                CheckBox_IsVisible.IsChecked = true;
                TextBlock_CreateDate.Text    = TimeNow.ToString();
            }
            else//登録済みアイテムの修正
            {
                PushPinModel selctedItem = PushPinView.GetSelcted();

                if (selctedItem != null)
                {
                    TextBox_Name.Text      = selctedItem.Name;
                    TextBox_Latitude.Text  = selctedItem.Location.Latitude.ToString();
                    TextBox_Longitude.Text = selctedItem.Location.Longitude.ToString();
                    TextBox_Address.Text   = selctedItem.Address;
                    TextBox_PhoneNum.Text  = selctedItem.PhoneNum;
                    TextBox_Note.Text      = selctedItem.Note;

                    if (selctedItem.Target == true)
                    {
                        CheckBox_IsTarget.IsChecked = true;
                    }
                    else
                    {
                        CheckBox_IsTarget.IsChecked = false;
                    }

                    if (selctedItem.Visibility == System.Windows.Visibility.Visible)
                    {
                        CheckBox_IsVisible.IsChecked = true;
                    }
                    else
                    {
                        CheckBox_IsVisible.IsChecked = false;
                    }
                    TextBlock_CreateDate.Text      = selctedItem.CreateDate.ToString();
                    TextBlock_CreateDayOfWeek.Text = selctedItem.CreateDate.DayOfWeek.ToString();
                }
            }


            Panorama.Title = TextBox_Name.Text;

            //住所が空欄だったら住所を取得する。
            if (PermissionOfLocationService == true)
            {
                /*
                 * if (TextBox_Address.Text == "" || TextBox_Address.Text == "Address")
                 * {
                 *  GeoCoding geoCode = new GeoCoding();
                 *
                 *  geoCode.DownloadGeoCodeResultCompleted += geoCode_DownloadGeoCodeResultCompleted;
                 *  GeoCoordinate location = new GeoCoordinate(Convert.ToDouble(TextBox_Latitude.Text), Convert.ToDouble(TextBox_Longitude.Text));
                 *  geoCode.GetAddressFromGeoCoordinate(location);
                 * }
                 */
                if (TextBox_Latitude.Text != "" && TextBox_Longitude.Text != "" && (TextBox_Address.Text == "" || TextBox_Address.Text == "Address"))
                {
                    GeoCoding geoCode = new GeoCoding();

                    geoCode.DownloadGeoCodeResultCompleted += geoCode_DownloadGeoCodeResultCompleted;
                    GeoCoordinate location = new GeoCoordinate(Convert.ToDouble(TextBox_Latitude.Text), Convert.ToDouble(TextBox_Longitude.Text));
                    geoCode.GetAddressFromGeoCoordinate(location);
                }
                else if ((TextBox_Latitude.Text == "" || TextBox_Longitude.Text == "") && (TextBox_Address.Text != "" && TextBox_Address.Text != "Address"))
                {
                    GeoCoding geoCode = new GeoCoding();

                    geoCode.DownloadGeoCodeResultCompleted += geoCode_DownloadReverseGeoCodeResultCompleted;
                    string address = TextBox_Address.Text;
                    geoCode.GetGeoCoordintateFromAddress(address);
                }
            }

            getAddressAndLocation();

            base.OnNavigatedTo(e);
        }
Пример #15
0
        //UIに表示されている情報をPushPinModel→PushPinViewに格納
        private void UIToPushPinView()
        {
            if (newItemFlag == true)//新規登録
            {
                #region 新規登録
                PushPinModel newPlace = new PushPinModel();

                newPlace.Location  = new GeoCoordinate(Convert.ToDouble(TextBox_Latitude.Text), Convert.ToDouble(TextBox_Longitude.Text));
                newPlace.Name      = TextBox_Name.Text;
                newPlace.Color     = new SolidColorBrush(Utility.GetColorFromHexString(PushPinView.DefaultColor_Hex));
                newPlace.Address   = TextBox_Address.Text;
                newPlace.PhoneNum  = TextBox_PhoneNum.Text;
                newPlace.Note      = TextBox_Note.Text;
                newPlace.IsEnabled = true;
                newPlace.Selected  = false;
                newPlace.Target    = false;


                if (CheckBox_IsVisible.IsChecked == true)
                {
                    newPlace.Visibility = Visibility.Visible;
                }
                else
                {
                    newPlace.Visibility = Visibility.Collapsed;
                }

                PushPinView.PushPins.Add(newPlace);


                if (CheckBox_IsTarget.IsChecked == true)
                {
                    PushPinView.SetTarget(newPlace);
                }

                newPlace.CreateDate = TimeNow;

                bool darkTheme = ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible);
                if (darkTheme == true)//darkの時は白抜きの画像
                {
                    newPlace.ArrowURI  = "/Icons/appbar.next.rest.png";
                    newPlace.CircleURI = "/Icons/appbar.basecircle.rest.png";
                }
                else
                {
                    newPlace.ArrowURI  = "/Icons/appbar.next.rest.light.png";
                    newPlace.CircleURI = "/Icons/appbar.base.png";
                }

                #endregion
            }
            else//登録済みアイテムの修正
            {
                #region 登録済みアイテムの変更
                PushPinModel selectedItem;

                selectedItem = PushPinView.GetSelcted();
                //PushPinModel targetItem=PushPinView.GetTarget();
                bool isTargetFlag = false;

                if (selectedItem.Target == true)
                {
                    isTargetFlag = true;
                }

                selectedItem.Name = TextBox_Name.Text;

                /*
                 * //経緯度の格納
                 * //経緯度が両方共入力されている場合
                 * if (TextBox_Latitude.Text != "" && TextBox_Longitude.Text != "")
                 * {
                 *  try
                 *  {//有効な値かどうかを例外発行の有無で確認
                 *      selectedItem.Location = new GeoCoordinate(Convert.ToDouble(TextBox_Latitude.Text), Convert.ToDouble(TextBox_Longitude.Text));
                 *  }
                 *  catch
                 *  {
                 *      //formatexceptionだったと思う、が出た場合、メッセージを出して入力を促す。
                 *      //selectedItem.Location = GeoCoordinate.Unknown;
                 *      MessageBox.Show("Latitude or Longitude is out of range." + System.Environment.NewLine + "Location data must be..." + System.Environment.NewLine + "-90 < Latitude < 90" + System.Environment.NewLine + "-180 < Longitude < 180");
                 *  }
                 * }
                 * else
                 * {
                 *  //どちらかが空欄の場合、何もしない
                 *  //MessageBox.Show("");
                 *  //selectedItem.Location = GeoCoordinate.Unknown;
                 * }
                 */
                //このメソッドが呼び出される前段階で、経緯度が有効かチェックされている
                selectedItem.Location = new GeoCoordinate(Convert.ToDouble(TextBox_Latitude.Text), Convert.ToDouble(TextBox_Longitude.Text));
                selectedItem.Address  = TextBox_Address.Text;
                selectedItem.PhoneNum = TextBox_PhoneNum.Text;
                selectedItem.Note     = TextBox_Note.Text;

                if (CheckBox_IsTarget.IsChecked == true)
                {
                    if (isTargetFlag == true)
                    {
                        //
                    }
                    else
                    {
                        PushPinView.SetTarget(selectedItem);
                    }
                }
                else
                {
                    if (isTargetFlag == true)
                    {
                        selectedItem.Target = false;
                    }
                    else
                    {
                        //
                    }
                }

                if (CheckBox_IsVisible.IsChecked == true)
                {
                    selectedItem.Visibility = Visibility.Visible;
                }
                else
                {
                    selectedItem.Visibility = Visibility.Collapsed;
                }
                #endregion
            }
        }
Пример #16
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);
        }
Пример #17
0
        //
        public ViewModel LoadInfoFromXML()
        {
            //目的地データの読み込み。
            IsolatedStorageFile       isoFile = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream strm    = new IsolatedStorageFileStream(DBFileName, FileMode.Open, FileAccess.Read, isoFile);
            XDocument xmlDoc = XDocument.Load(strm);

            strm.Dispose();
            isoFile.Dispose();

            var destinations = from destination in xmlDoc.Descendants("Destination")
                               orderby destination.Element("Name").Value
                               select destination;


            ViewModel    PushPinView = new ViewModel();
            PushPinModel pin;//=new PushPinModel();

            bool darkTheme = ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible);

            foreach (var dest in destinations)
            {
                pin = new PushPinModel();
                // if (dest.Element("Latitude").Value == "NaN")
                //   pin.Location = new GeoCoordinate(34,140);
                //else
                if (dest.Element("Latitude").Value != "NaN")
                {
                    pin.Location   = new GeoCoordinate(Convert.ToDouble(dest.Element("Latitude").Value), Convert.ToDouble(dest.Element("Longitude").Value));
                    pin.Name       = dest.Element("Name").Value;
                    pin.IsEnabled  = Convert.ToBoolean(dest.Element("IsEnable").Value);
                    pin.Target     = Convert.ToBoolean(dest.Element("Target").Value);
                    pin.Selected   = Convert.ToBoolean(dest.Element("Selected").Value);
                    pin.Note       = dest.Element("Note").Value;
                    pin.Color      = new SolidColorBrush(Utility.GetColorFromHexString(dest.Element("Color").Value));
                    pin.Visibility = Utility.GetVisibilityFromString(dest.Element("Visibility").Value);
                    try
                    {
                        pin.CreateDate = DateTime.FromFileTime((long)Convert.ToDouble(dest.Element("CreateDate").Value));
                    }
                    catch
                    {
                        pin.CreateDate = DateTime.Parse(dest.Element("CreateDate").Value);
                    }
                    pin.Address  = (dest.Descendants("Address").Count() == 0) ? "" : dest.Element("Address").Value;
                    pin.PhoneNum = (dest.Descendants("PhoneNum").Count() == 0) ? "" : dest.Element("PhoneNum").Value;

                    if (darkTheme == true)//darkの時は白抜きの画像
                    {
                        pin.ArrowURI  = "/Icons/appbar.next.rest.png";
                        pin.CircleURI = "/Icons/appbar.basecircle.rest.png";
                    }
                    else
                    {
                        pin.ArrowURI  = "/Icons/appbar.next.rest.light.png";
                        pin.CircleURI = "/Icons/appbar.base.png";
                    }

                    //MessageBox.Show("l "+pin.Visibility.ToString());
                    PushPinView.PushPins.Add(pin);
                }
            }

            return(PushPinView);
        }
Пример #18
0
 //コンストラクタ
 public TwoPoint()
 {
     Point1 = new PushPinModel();
     Point2 = new PushPinModel();
 }