예제 #1
0
        private void CmdWriteToFile_OnClick(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "MIO configuration file|*.mio";
            saveFileDialog.Title = "Сохранить конфигурацию";
            saveFileDialog.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (saveFileDialog.FileName != "")
            {
                FileReaderSaver saver = new FileReaderSaver(saveFileDialog.FileName);
                if (SelectedDevice != null && SelectedDevice.ConfigurationReadFromDevice)
                {
                    ReaderSaverErrors Result = saver.SaveDeviceConfiguration(SelectedDevice);
                    if (Result != ReaderSaverErrors.CodeOk)
                    {
                        СurrentlyProcessed.Text = "Запись конфигурации завершена c ошибкой: " + Result.GetDescription();
                    }
                    else
                    {
                        СurrentlyProcessed.Text = "Запись конфигурации завершена успешно";
                    }
                }
            }
        }
예제 #2
0
        private void CmdReadFromFile_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "MIO configuration file|*.mio";
            openFileDialog.Title = "Прочитать конфигурацию";
            openFileDialog.ShowDialog();
            if (openFileDialog.FileName != "")
            {
                FileReaderSaver reader = new FileReaderSaver(openFileDialog.FileName);
                if (SelectedDevice != null && SelectedDevice.ConfigurationReadFromDevice)
                {
                    ReaderSaverErrors Result = reader.ReadDeviceConfiguration(SelectedDevice);
                    if (Result != ReaderSaverErrors.CodeOk)
                    {
                        СurrentlyProcessed.Text = "Чтение конфигурации завершено c ошибкой: " + Result.GetDescription();
                    }
                    else
                    {
                        UartPots.SelectedIndex = 0;
                        DrawConfigurationTabs();

                        NotifyPropertyChanged("SelectedDevice");
                        NotifyPropertyChanged("SelectedPortConfiguration");
                        NotifyPropertyChanged("SelectedModbusQuery");

                        СurrentlyProcessed.Text = "Чтение конфигурации завершено успешно";
                    }
                }
            }
        }