private void getAddressAndLocation() { //住所が空欄だったら住所を取得する。 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); } } }
private void TextBox_Search_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key.Equals(Key.Enter)) { e.Handled = true; this.Focus(); GeoCoding geoCode = new GeoCoding(); geoCode.DownloadGeoCodeResultCompleted += geoCode_DownloadReverseGeoCodeResultCompleted; geoCode.GetGeoCoordintateFromAddress(TextBox_SearchBox.Text); } }
//ページに移動してきた時の処理。 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); }