Browse Source

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

master
Никита 6 years ago
parent
commit
f861b33f86
  1. 4
      Signal Generator/AddSignalWindow.xaml.cs
  2. 5
      Signal Generator/MainWindow.xaml
  3. 37
      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
{
ObservableCollection<Parameter> signalProps = new ObservableCollection<Parameter>();
ObservableCollection<IAnalogSignal> typesOfSignal = new ObservableCollection<IAnalogSignal>();
public AddSignalWindow()
{
InitializeComponent();
typesOfSignal.Add(new SinusoidalSignal(0, 0));
typesOfSignal.Add(new FmSignal(0, 0, 0));
signalType_ComboBox.ItemsSource = typesOfSignal;
signalProps_DataGrid.ItemsSource = signalProps;
}

5
Signal Generator/MainWindow.xaml

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Signal_Generator"
mc:Ignorable="d"
Title="Генератор сигналов" Height="450" Width="489">
Title="Генератор сигналов" Height="450" Width="600">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -39,6 +39,7 @@
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"
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>
</Window>

37
Signal Generator/MainWindow.xaml.cs

@ -21,44 +21,43 @@ namespace Signal_Generator
/// </summary>
public partial class MainWindow : Window
{
AddSignalWindow addSignalWindow_Instance = new AddSignalWindow();
AddSignalWindow addSignalWindow_Instance;
TaskWindow taskWindow_Instance = new TaskWindow();
ObservableCollection<IAnalogSignal> s;
ObservableCollection<IAnalogSignal> typesOfSignal = new ObservableCollection<IAnalogSignal>();
ObservableCollection<IAnalogSignal> signalCollection;
public MainWindow()
{
InitializeComponent();
typesOfSignal.Add(new SinusoidalSignal(0, 0));
typesOfSignal.Add(new FmSignal(0, 0, 0));
addSignalWindow_Instance.signalType_ComboBox.ItemsSource = typesOfSignal;
s = new ObservableCollection<IAnalogSignal>();
signalCollection = new ObservableCollection<IAnalogSignal>();
signals_ListBox.Items.Clear();
signals_ListBox.ItemsSource = s;
addSignalWindow_Instance.Closed += addSignalWindow_Instance_Closed;
signals_ListBox.ItemsSource = signalCollection;
}
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);
s.Add(s1);
var signal = null as IAnalogSignal;
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)
private void startProcedure_Button_Click(object sender, RoutedEventArgs e)
{
addSignalWindow_Instance.Show();
taskWindow_Instance.Show();
}
private void startProcedure_Button_Click(object sender, RoutedEventArgs e)
private void removeSignal_Button_Click(object sender, RoutedEventArgs e)
{
taskWindow_Instance.Show();
signalCollection.RemoveAt(signals_ListBox.SelectedIndex);
}
}
}

20
Signal Generator/Signal/MultiSignal.cs

@ -9,17 +9,7 @@ namespace Signal_Generator
{
class MultiSignal : IAnalogSignal
{
private string paramsToString { get; }
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()
{
@ -46,6 +36,16 @@ namespace Signal_Generator
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)
{
throw new NotImplementedException();

Loading…
Cancel
Save