public static MyLocation Parse(string xmlstring) { if (xmlstring == null || xmlstring.Length <= 0) return null; MyLocation result = new MyLocation(); XDocument hehe = XDocument.Parse(xmlstring); XElement location = hehe.Root.Element("geocoordinate"); result.GeoCoordinate = new System.Device.Location.GeoCoordinate(double.Parse(location.Attribute("lat").Value), double.Parse(location.Attribute("long").Value)); result.Address = hehe.Root.Element("address").Value; return result; }
List<XMLParser.MediaElement> voicesselected = new List<XMLParser.MediaElement>(); //name #endregion Fields #region Constructors public NoteDetailPage() { InitializeComponent(); this.DataContext = App.ViewModel; Pi = new ProgressIndicator(); Pi.IsIndeterminate = true; Pi.IsVisible = false; mylocation = new MyLocation(); LoadNote(App.ViewModel.SelectedNote); buttonAdd = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; buttonDelete = (ApplicationBarIconButton)ApplicationBar.Buttons[3]; }
public static string CreateXmlString(MyLocation location) { if (location == null) return ""; XElement root = new XElement("location"); XElement geo = new XElement("geocoordinate"); geo.SetAttributeValue("lat", location.GeoCoordinate.Latitude); geo.SetAttributeValue("long", location.GeoCoordinate.Longitude); root.Add(geo); XElement address = new XElement("address"); address.Value = location.Address; root.Add(address); return root.ToString(); }
protected void LoadNote(ToDoNote note) { ShowProgressIndicator("Loading note's detail..."); if (note != null) { //title noteTitle.Text = note.NoteTitle; txtTitle.Text = note.NoteTitle; // description if (note.NoteDescription != null) txtDescription.Text = note.NoteDescription; else txtDescription.Text = ""; //tags if (note.NoteTags != null) { listTags.Visibility = System.Windows.Visibility.Visible; txtTags.Visibility = System.Windows.Visibility.Collapsed; listTags.Items.Clear(); txtTags.Text = note.NoteTags; foreach (string tag in note.NoteTags.Split(new char[] { ' ' })) { Button button = new Button(); button.Click += button_Click; button.Content = tag; button.Background = new SolidColorBrush(ColorConverter.MyColorTemplate); button.Height = 72; button.Width = 50 + tag.Length * 14; listTags.Items.Add(button); } } else { listTags.Visibility = System.Windows.Visibility.Collapsed; txtTags.Visibility = System.Windows.Visibility.Visible; txtTags.Text = ""; listTags.Items.Clear(); } //category App.ViewModel.CategorySelected = note.Category; //location mylocation = LocationXmlParser.Parse(note.NoteLocation); if (mylocation != null) txtLocation.Text = mylocation.Address; else txtLocation.Text = ""; // photos if (note.NotePhotos == null || note.NotePhotos.Length <= 0) ; else { photos = new ObservableCollection<XMLParser.MediaElement>(MediaXmlParser.Parse(note.NotePhotos)); } listphoto.ItemsSource = photos; //voices if (note.NoteVoices == null || note.NoteVoices.Length <= 0) ; else { voicespath = new ObservableCollection<XMLParser.MediaElement>(MediaXmlParser.Parse(note.NoteVoices)); } listvoice.ItemsSource = voicespath; //reminder checkboxtime.IsChecked = note.IsTimeReminder; checkboxdis.IsChecked = note.IsDistanceReminder; if (note.TimeReminder != null) { datepicker.Value = DateTime.Parse(note.TimeReminder.ToString()); timepicker.Value = DateTime.Parse(note.TimeReminder.ToString()); } txtDistance.Text = note.NoteDistanceReminder.ToString(); } HideProgressIndicator(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (PhoneApplicationService.Current.State.ContainsKey("location")) { mylocation = new MyLocation(); mylocation.GeoCoordinate = (GeoCoordinate)PhoneApplicationService.Current.State["location"]; mylocation.Address = (string)PhoneApplicationService.Current.State["address"]; txtLocation.Text = mylocation.Address; PhoneApplicationService.Current.State.Clear(); } }