From e10042916266b3e659d3dff4d5e4e07a51a0118e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Sun, 11 Nov 2018 21:01:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0,=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B2=D0=BE=D0=B4=D1=8F=D1=89=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BA=20=D0=BA=D1=80=D0=B0=D1=85=D1=83=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B,=20=D0=B8=D0=B7-=D0=B7?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Signal Generator/Settings.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Signal Generator/Settings.cs b/Signal Generator/Settings.cs index 3a3bfc7..0348885 100644 --- a/Signal Generator/Settings.cs +++ b/Signal Generator/Settings.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; using System.IO; using System.Runtime.Serialization.Formatters.Binary; +using System.Windows; namespace Signal_Generator.Properties { @@ -16,9 +17,9 @@ namespace Signal_Generator.Properties { public Settings() { // // Для добавления обработчиков событий для сохранения и изменения параметров раскомментируйте приведенные ниже строки: // - this.SettingChanging += this.SettingChangingEventHandler; + //this.SettingChanging += this.SettingChangingEventHandler; // - this.SettingsSaving += this.SettingsSavingEventHandler; + //this.SettingsSaving += this.SettingsSavingEventHandler; // } @@ -32,10 +33,17 @@ namespace Signal_Generator.Properties { public static void SaveSignals(ObservableCollection signals) { - BinaryFormatter formatter = new BinaryFormatter(); - using (FileStream fs = new FileStream("settings.dat", FileMode.OpenOrCreate)) + try + { + BinaryFormatter formatter = new BinaryFormatter(); + using (FileStream fs = new FileStream("settings.dat", FileMode.OpenOrCreate)) + { + formatter.Serialize(fs, signals); + } + } + catch (Exception ex) { - formatter.Serialize(fs, signals); + MessageBox.Show(ex.Message, "Не удалось сохранить результаты работы"); } }