Example #1
0
        private void menuItemSaveAs_Click(object sender, RoutedEventArgs e)
        {
            SerializedFunc sf = new SerializedFunc(pf, textBoxEps.Text, textBoxXMin.Text, textBoxXMax.Text, textBoxYMin.Text, textBoxYMax.Text);

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName         = "points.xml";
            sfd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            sfd.Filter           = "Файлs XML (*.xml)|*.xml|Все файлы (*.*)|*.*";
            sfd.DefaultExt       = "*.xml";

            if (sfd.ShowDialog() == true)
            {
                try
                {
                    sf.Write(sfd.FileName);
                    filePath = sfd.FileName;
                    MessageBox.Show("Файл сохранено");
                }
                catch (Exception)
                {
                    MessageBox.Show("Ошибка записи в файл");
                }
            }
        }
Example #2
0
        private void menuItemSave_Click(object sender, RoutedEventArgs e)
        {
            if (filePath != null && File.Exists(filePath))
            {
                SerializedFunc sf = new SerializedFunc(pf, textBoxEps.Text, textBoxXMin.Text, textBoxXMax.Text, textBoxYMin.Text, textBoxYMax.Text);

                try
                {
                    sf.Write(filePath);
                    MessageBox.Show("Файл сохранено", "Сохранено", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception)
                {
                    MessageBox.Show("Ошибка записи в файл", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                menuItemSaveAs_Click(sender, new RoutedEventArgs());
            }
        }