コード例 #1
0
 /// <summary>
 /// Handles the Click event of the saveButton control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
 private void saveButton_Click(object sender, RoutedEventArgs e)
 {
     Location location = new Location();
     location.Map = true;
     location.Date = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
     location.Coordinate = pushpin.Location;
     LocationSettings.Add(location);
     NavigationService.GoBack();
 }
コード例 #2
0
        /// <summary>
        /// Called when a page becomes the active page in a frame.
        /// </summary>
        /// <param name="e">An object that contains the event data.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (goBack)
                NavigationService.GoBack();
            string selectedIndex = "";
            if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex) && !isLoaded)
            {
                map1.ZoomLevel = 18;
                map1.Mode = new AerialMode();
                int index = int.Parse(selectedIndex);
                List<Location> list = LocationSettings.Get();

                foreach (var Location in list)
                {
                    if (Location.ID.ToString() == selectedIndex)
                    {
                        location = Location;
                        break;
                    }
                }
                if (location.Coordinate != null)
                {
                    map1.Center = location.Coordinate;
                    pushpin.Location = location.Coordinate;
                    pushpin.Background = new SolidColorBrush(Colors.LightGray);

                    try
                    {
                        map1.Children.Add(pushpin);
                    }
                    catch
                    {
                        //pin is already on the map.
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles the Tap event of the saveButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GestureEventArgs" /> instance containing the event data.</param>
        private void saveButton_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Location location = new Location();

            location.LocationName = textBoxLocation.Text;
            location.Square = textBoxSquare.Text;
            location.Date = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

            LocationSettings.Add(location);
            NavigationService.GoBack();
        }
コード例 #4
0
        /// <summary>
        /// Handles the SelectionChanged event of the ListBox control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SelectionChangedEventArgs" /> instance containing the event data.</param>
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If selected index is -1 (no selection) do nothing
            if (MainListBox.SelectedIndex == -1)
                return;

            // Navigate to the new page
            List<Location> list = LocationSettings.Get();
            ItemViewModel dc = new ItemViewModel();
            dc = App.ViewModel.Items[MainListBox.SelectedIndex];
            int link = dc.Link;
            if (link == -2)
            {
                var result = MessageBox.Show("Do you want to remove all locations?", "Attention!",
                                   MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.OK)
                {
                    LocationSettings.Clear();
                    App.ViewModel.LoadData();
                    return;
                }
            }
            Location location = new Location();
            location.Map = false;
            try
            {
                foreach (var Location in list)
                {
                    if (Location.ID == link)
                    {
                        location = Location;
                        break;
                    }
                }
            }
            catch
            {

            }
            if (location.Map)
                NavigationService.Navigate(new Uri("/ViewDetails.xaml?selectedItem=" + link, UriKind.Relative));

            // Reset selected index to -1 (no selection)
            MainListBox.SelectedIndex = -1;
        }