Browse Source

Фикс ошибки, из-за которой сигналы не удалялись из процедуры

master
Никита 6 years ago
parent
commit
83433b72e8
  1. 17
      Signal Generator/MainWindow.xaml.cs
  2. 2
      Signal Generator/ProcedureModel.cs
  3. 10
      Signal Generator/Signal/MultiSignal.cs

17
Signal Generator/MainWindow.xaml.cs

@ -23,14 +23,13 @@ namespace Signal_Generator
{ {
AddSignalWindow addSignalWindow_Instance; AddSignalWindow addSignalWindow_Instance;
TaskWindow taskWindow_Instance; TaskWindow taskWindow_Instance;
ObservableCollection<IAnalogSignal> signalCollection; MultiSignal multiSignal = MultiSignal.getInstance();
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
signalCollection = new ObservableCollection<IAnalogSignal>();
signals_ListBox.Items.Clear(); signals_ListBox.Items.Clear();
signals_ListBox.ItemsSource = signalCollection; signals_ListBox.ItemsSource = multiSignal.signals;
} }
private void addSignal_Button_Click(object sender, RoutedEventArgs e) private void addSignal_Button_Click(object sender, RoutedEventArgs e)
@ -52,18 +51,13 @@ namespace Signal_Generator
var signal = null as IAnalogSignal; var signal = null as IAnalogSignal;
signal = (IAnalogSignal) addSignalWindow_Instance.signalType_ComboBox.SelectedItem; signal = (IAnalogSignal) addSignalWindow_Instance.signalType_ComboBox.SelectedItem;
if (addSignalWindow_Instance.signalType_ComboBox.SelectedItem == null) return; if (addSignalWindow_Instance.signalType_ComboBox.SelectedItem == null) return;
signalCollection.Add(signal); multiSignal.Add(signal);
addSignalWindow_Instance.Close(); addSignalWindow_Instance.Close();
} }
private void startProcedure_Button_Click(object sender, RoutedEventArgs e) private void startProcedure_Button_Click(object sender, RoutedEventArgs e)
{ {
IsEnabled = false; IsEnabled = false;
MultiSignal ms = MultiSignal.getInstance();
foreach (IAnalogSignal item in signalCollection)
{
ms.add(item);
}
taskWindow_Instance = new TaskWindow(); taskWindow_Instance = new TaskWindow();
taskWindow_Instance.Show(); taskWindow_Instance.Show();
taskWindow_Instance.Closed += enableMainWindow; taskWindow_Instance.Closed += enableMainWindow;
@ -71,8 +65,9 @@ namespace Signal_Generator
private void removeSignal_Button_Click(object sender, RoutedEventArgs e) private void removeSignal_Button_Click(object sender, RoutedEventArgs e)
{ {
if (signals_ListBox.SelectedIndex == -1) return; if (signals_ListBox.SelectedItem == null) return;
signalCollection.RemoveAt(signals_ListBox.SelectedIndex); var x = signals_ListBox.SelectedItem as IAnalogSignal;
multiSignal.Remove(x);
} }
} }
} }

2
Signal Generator/ProcedureModel.cs

@ -45,7 +45,7 @@ namespace Signal_Generator
var btn = parameters[0] as Button; var btn = parameters[0] as Button;
var ms = MultiSignal.getInstance(); var ms = MultiSignal.getInstance();
if ((ms == null) || (ms.count() == 0)) if ((ms == null) || (ms.Count() == 0))
return false; return false;
switch (btn.Name) switch (btn.Name)
{ {

10
Signal Generator/Signal/MultiSignal.cs

@ -10,11 +10,11 @@ namespace Signal_Generator
public class MultiSignal : IAnalogSignal public class MultiSignal : IAnalogSignal
{ {
private static MultiSignal instance; private static MultiSignal instance;
private List<IAnalogSignal> signals { get; set; } internal ObservableCollection<IAnalogSignal> signals { get; private set; }
private MultiSignal() private MultiSignal()
{ {
signals = new List<IAnalogSignal>(); signals = new ObservableCollection<IAnalogSignal>();
} }
public static MultiSignal getInstance() public static MultiSignal getInstance()
@ -24,17 +24,17 @@ namespace Signal_Generator
return instance; return instance;
} }
internal void add(IAnalogSignal signal) internal void Add(IAnalogSignal signal)
{ {
signals.Add(signal); signals.Add(signal);
} }
internal void remove(IAnalogSignal signal) internal void Remove(IAnalogSignal signal)
{ {
signals.Remove(signal); signals.Remove(signal);
} }
internal int count() internal int Count()
{ {
return signals.Count(); return signals.Count();
} }

Loading…
Cancel
Save