Browse Source

Реализация добавления и удаления сигналов на главном окне

master
Никита 6 years ago
parent
commit
f861b33f86
  1. 4
      Signal Generator/AddSignalWindow.xaml.cs
  2. 5
      Signal Generator/MainWindow.xaml
  3. 41
      Signal Generator/MainWindow.xaml.cs
  4. 20
      Signal Generator/Signal/MultiSignal.cs

4
Signal Generator/AddSignalWindow.xaml.cs

@ -21,9 +21,13 @@ namespace Signal_Generator
public partial class AddSignalWindow : Window public partial class AddSignalWindow : Window
{ {
ObservableCollection<Parameter> signalProps = new ObservableCollection<Parameter>(); ObservableCollection<Parameter> signalProps = new ObservableCollection<Parameter>();
ObservableCollection<IAnalogSignal> typesOfSignal = new ObservableCollection<IAnalogSignal>();
public AddSignalWindow() public AddSignalWindow()
{ {
InitializeComponent(); InitializeComponent();
typesOfSignal.Add(new SinusoidalSignal(0, 0));
typesOfSignal.Add(new FmSignal(0, 0, 0));
signalType_ComboBox.ItemsSource = typesOfSignal;
signalProps_DataGrid.ItemsSource = signalProps; signalProps_DataGrid.ItemsSource = signalProps;
} }

5
Signal Generator/MainWindow.xaml

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Signal_Generator" xmlns:local="clr-namespace:Signal_Generator"
mc:Ignorable="d" mc:Ignorable="d"
Title="Генератор сигналов" Height="450" Width="489"> Title="Генератор сигналов" Height="450" Width="600">
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
@ -39,6 +39,7 @@
Grid.Row="2" Margin="5,0,0,0"/> Grid.Row="2" Margin="5,0,0,0"/>
<Button x:Name="addSignal_Button" Width="20" Content="+" Margin="0,0,5,0" Click="addSignal_Button_Click" Grid.Row="2" <Button x:Name="addSignal_Button" Width="20" Content="+" Margin="0,0,5,0" Click="addSignal_Button_Click" Grid.Row="2"
Grid.Column="2"/> Grid.Column="2"/>
<Button x:Name="removeSignal_Button" Width="20" Margin="0,0,5,0" Content="-" Grid.Row="2" Grid.Column="3"/> <Button x:Name="removeSignal_Button" Width="20" Margin="0,0,5,0" Content="-" Grid.Row="2" Grid.Column="3"
Click="removeSignal_Button_Click"/>
</Grid> </Grid>
</Window> </Window>

41
Signal Generator/MainWindow.xaml.cs

@ -21,44 +21,43 @@ namespace Signal_Generator
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
AddSignalWindow addSignalWindow_Instance = new AddSignalWindow(); AddSignalWindow addSignalWindow_Instance;
TaskWindow taskWindow_Instance = new TaskWindow(); TaskWindow taskWindow_Instance = new TaskWindow();
ObservableCollection<IAnalogSignal> s; ObservableCollection<IAnalogSignal> signalCollection;
ObservableCollection<IAnalogSignal> typesOfSignal = new ObservableCollection<IAnalogSignal>();
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
signalCollection = new ObservableCollection<IAnalogSignal>();
typesOfSignal.Add(new SinusoidalSignal(0, 0));
typesOfSignal.Add(new FmSignal(0, 0, 0));
addSignalWindow_Instance.signalType_ComboBox.ItemsSource = typesOfSignal;
s = new ObservableCollection<IAnalogSignal>();
signals_ListBox.Items.Clear(); signals_ListBox.Items.Clear();
signals_ListBox.ItemsSource = s; signals_ListBox.ItemsSource = signalCollection;
addSignalWindow_Instance.Closed += addSignalWindow_Instance_Closed;
} }
private void addSignalWindow_Instance_Closed(object sender, EventArgs e) private void addSignal_Button_Click(object sender, RoutedEventArgs e)
{ {
addSignalWindow_Instance = new AddSignalWindow();
addSignalWindow_Instance.createItem_Button.Click += addSignalWindow_Instance_Closing;
addSignalWindow_Instance.Show();
} }
private void addSomeExtra() private void addSignalWindow_Instance_Closing(object sender, EventArgs e)
{ {
SinusoidalSignal s1 = new SinusoidalSignal(1, 50); var signal = null as IAnalogSignal;
s.Add(s1); signal = (IAnalogSignal) addSignalWindow_Instance.signalType_ComboBox.SelectedItem;
} if (addSignalWindow_Instance.signalType_ComboBox.SelectedItem == null) return;
signalCollection.Add(signal);
addSignalWindow_Instance.Close();
}
private void addSignal_Button_Click(object sender, RoutedEventArgs e)
{
addSignalWindow_Instance.Show();
}
private void startProcedure_Button_Click(object sender, RoutedEventArgs e) private void startProcedure_Button_Click(object sender, RoutedEventArgs e)
{ {
taskWindow_Instance.Show(); taskWindow_Instance.Show();
} }
private void removeSignal_Button_Click(object sender, RoutedEventArgs e)
{
signalCollection.RemoveAt(signals_ListBox.SelectedIndex);
}
} }
} }

20
Signal Generator/Signal/MultiSignal.cs

@ -9,17 +9,7 @@ namespace Signal_Generator
{ {
class MultiSignal : IAnalogSignal class MultiSignal : IAnalogSignal
{ {
private string paramsToString { get; }
private List<IAnalogSignal> signals { get; set; } private List<IAnalogSignal> signals { get; set; }
private Dictionary<string, double> paramsDict { get; set; }
public string typeToString => throw new NotImplementedException();
string IAnalogSignal.paramsToString => throw new NotImplementedException();
string IAnalogSignal.typeToString => throw new NotImplementedException();
Collection<Parameter> IAnalogSignal.paramsCollection { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public MultiSignal() public MultiSignal()
{ {
@ -46,6 +36,16 @@ namespace Signal_Generator
return summaryAmplitude; return summaryAmplitude;
} }
// Неиспользуемые поля и методы
public string typeToString => throw new NotImplementedException();
string IAnalogSignal.paramsToString => throw new NotImplementedException();
string IAnalogSignal.typeToString => throw new NotImplementedException();
Collection<Parameter> IAnalogSignal.paramsCollection { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
double IAnalogSignal.currentAmplitude(double t) double IAnalogSignal.currentAmplitude(double t)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

Loading…
Cancel
Save