Пример #1
0
        private void Exit_OnClick(object sender, RoutedEventArgs e)
        {
            if (ltw1 != null)
            {
                ltw1.Close();
            }

            if (ltw != null)
            {
                ltw.Close();
            }

            if (lw != null)
            {
                lw.Close();
            }

            if (llw != null)
            {
                llw.Close();
            }

            MessageBoxResult mbr1 = MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (mbr1 == MessageBoxResult.Yes)
            {
                if (notSaved)
                {
                    MessageBoxResult mbr = MessageBox.Show("You have not saved your data. \nDo you want to save first?", "Save", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                    if (mbr == MessageBoxResult.Yes)
                    {
                        saveAll();
                    }
                }

                doNotShow = true;
                this.Close();
            }
        }
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            if (!ID_Field.Text.Equals("") && !Name_Field.Text.Equals("") && DateDiscovery.SelectedDate != null && ChosenType != null)
            {
                List <Tag> ttags = tags.ToList <Tag>();

                if (tempPosition == null)
                {
                    l = new Landmark(ID_Field.Text, Name_Field.Text, Description_Field.Text, ChosenType, ttags,
                                     Climate_Field.SelectedValue.ToString(),
                                     TouristStatus_Field.SelectedValue.ToString(), Double.Parse(AnnualRevenue_Field.Text),
                                     DateDiscovery.SelectedDate.Value.Date.ToShortDateString(),
                                     _image, (bool)Eco.IsChecked, (bool)Danger.IsChecked, (bool)Habitated.IsChecked,
                                     new Point(-100, -100));
                }
                else
                {
                    l = new Landmark(ID_Field.Text, Name_Field.Text, Description_Field.Text, ChosenType, ttags,
                                     Climate_Field.SelectedValue.ToString(),
                                     TouristStatus_Field.SelectedValue.ToString(), Double.Parse(AnnualRevenue_Field.Text),
                                     DateDiscovery.SelectedDate.Value.Date.ToShortDateString(),
                                     _image, (bool)Eco.IsChecked, (bool)Danger.IsChecked, (bool)Habitated.IsChecked,
                                     (Point)tempPosition);
                }

                if (llw != null)
                {
                    if (llw.AddALandmark(l))
                    {
                        if (ltw1 != null)
                        {
                            ltw1.Close();
                        }
                        if (ltw != null)
                        {
                            ltw.Close();
                        }

                        LandmarkListWindow.notSaved = true;
                        llw.Search.Text             = "";
                        doNotShow = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Landmark with entered code already exists. \nPlease try again.", "Landmark Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    if (map.addLandmark(l))
                    {
                        if (ltw1 != null)
                        {
                            ltw1.Close();
                        }
                        if (ltw != null)
                        {
                            ltw.Close();
                        }

                        MapWindow.notSaved = true;
                        doNotShow          = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Landmark with entered code already exists. \nPlease try again.", "Landmark Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter ID, name and select date of \ndiscovery and landmark type for your landmark", "Landmark Data Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }