Example #1
0
        private void Button_Export_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Файл настроек(*.txt)|*.txt";
            string fileName = "";
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    List<TbParamsXml> saveCollection = (List<TbParamsXml>) DataGrid.Items.SourceCollection;
                    fileName = saveFileDialog.FileName;
                    ImportExportTbParamsXml saveFile = new ImportExportTbParamsXml();
                    saveFile.SaveParamsCollection(_mainCollection, fileName);
                }
                catch (Exception)
                {
                    MessageBox.Show("Неверные данные", "Ошибка Записи");
                }
               
            }


        }
Example #2
0
        private void Button_Import_Click(object sender, RoutedEventArgs e)
        {
            string fileName = "";
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Файл настроек(*.txt)|*.txt";
            openFileDialog.CheckFileExists = true;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                fileName = openFileDialog.FileName;


            ImportExportTbParamsXml loadFile = new ImportExportTbParamsXml();
            loadFile.LoadParamsCollection(fileName);
            _mainCollection = loadFile.GetParamsCollection();
            DataGrid.ItemsSource = _mainCollection;
        }