From 83433b72e82636706dd83be2570326d95f3f2bae 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 11:11:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B8,=20=D0=B8=D0=B7-=D0=B7=D0=B0=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BE=D0=B9=20=D1=81=D0=B8=D0=B3=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB=D1=8B=20=D0=BD=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D1=8F?= =?UTF-8?q?=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B8=D0=B7=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=86=D0=B5=D0=B4=D1=83=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Signal Generator/MainWindow.xaml.cs | 17 ++++++----------- Signal Generator/ProcedureModel.cs | 2 +- Signal Generator/Signal/MultiSignal.cs | 10 +++++----- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Signal Generator/MainWindow.xaml.cs b/Signal Generator/MainWindow.xaml.cs index f9eeeec..74253d3 100644 --- a/Signal Generator/MainWindow.xaml.cs +++ b/Signal Generator/MainWindow.xaml.cs @@ -23,14 +23,13 @@ namespace Signal_Generator { AddSignalWindow addSignalWindow_Instance; TaskWindow taskWindow_Instance; - ObservableCollection signalCollection; + MultiSignal multiSignal = MultiSignal.getInstance(); public MainWindow() { InitializeComponent(); - signalCollection = new ObservableCollection(); signals_ListBox.Items.Clear(); - signals_ListBox.ItemsSource = signalCollection; + signals_ListBox.ItemsSource = multiSignal.signals; } private void addSignal_Button_Click(object sender, RoutedEventArgs e) @@ -52,18 +51,13 @@ namespace Signal_Generator var signal = null as IAnalogSignal; signal = (IAnalogSignal) addSignalWindow_Instance.signalType_ComboBox.SelectedItem; if (addSignalWindow_Instance.signalType_ComboBox.SelectedItem == null) return; - signalCollection.Add(signal); + multiSignal.Add(signal); addSignalWindow_Instance.Close(); } private void startProcedure_Button_Click(object sender, RoutedEventArgs e) { IsEnabled = false; - MultiSignal ms = MultiSignal.getInstance(); - foreach (IAnalogSignal item in signalCollection) - { - ms.add(item); - } taskWindow_Instance = new TaskWindow(); taskWindow_Instance.Show(); taskWindow_Instance.Closed += enableMainWindow; @@ -71,8 +65,9 @@ namespace Signal_Generator private void removeSignal_Button_Click(object sender, RoutedEventArgs e) { - if (signals_ListBox.SelectedIndex == -1) return; - signalCollection.RemoveAt(signals_ListBox.SelectedIndex); + if (signals_ListBox.SelectedItem == null) return; + var x = signals_ListBox.SelectedItem as IAnalogSignal; + multiSignal.Remove(x); } } } diff --git a/Signal Generator/ProcedureModel.cs b/Signal Generator/ProcedureModel.cs index 3a1a45d..2b3fcf2 100644 --- a/Signal Generator/ProcedureModel.cs +++ b/Signal Generator/ProcedureModel.cs @@ -45,7 +45,7 @@ namespace Signal_Generator var btn = parameters[0] as Button; var ms = MultiSignal.getInstance(); - if ((ms == null) || (ms.count() == 0)) + if ((ms == null) || (ms.Count() == 0)) return false; switch (btn.Name) { diff --git a/Signal Generator/Signal/MultiSignal.cs b/Signal Generator/Signal/MultiSignal.cs index 2e954b8..4f3682f 100644 --- a/Signal Generator/Signal/MultiSignal.cs +++ b/Signal Generator/Signal/MultiSignal.cs @@ -10,11 +10,11 @@ namespace Signal_Generator public class MultiSignal : IAnalogSignal { private static MultiSignal instance; - private List signals { get; set; } + internal ObservableCollection signals { get; private set; } private MultiSignal() { - signals = new List(); + signals = new ObservableCollection(); } public static MultiSignal getInstance() @@ -24,17 +24,17 @@ namespace Signal_Generator return instance; } - internal void add(IAnalogSignal signal) + internal void Add(IAnalogSignal signal) { signals.Add(signal); } - internal void remove(IAnalogSignal signal) + internal void Remove(IAnalogSignal signal) { signals.Remove(signal); } - internal int count() + internal int Count() { return signals.Count(); }