Browse Source

Сделана новая нормальная верстка на grid'e

master
Никита 6 years ago
parent
commit
1b8dd22f55
  1. 31
      Signal Generator/AddSignalWindow.xaml
  2. 65
      Signal Generator/MainWindow.xaml
  3. 15
      Signal Generator/MainWindow.xaml.cs
  4. 40
      Signal Generator/TaskWindow.xaml

31
Signal Generator/AddSignalWindow.xaml

@ -5,15 +5,26 @@
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="AddSignalWindow" Height="200" Width="400"> Title="Добавить новый сигнал" Height="200" Width="400">
<Grid> <Grid Margin="10">
<DockPanel Margin="10"> <Grid.RowDefinitions>
<DockPanel DockPanel.Dock="Top"> <RowDefinition Height="Auto"/>
<TextBlock x:Name="signalType_TextBlock" Margin="0,0,10,0">Тип сигнала:</TextBlock> <RowDefinition Height="*"/>
<ComboBox x:Name="signalType_ComboBox" HorizontalAlignment="Stretch"/> <RowDefinition Height="Auto"/>
</DockPanel> </Grid.RowDefinitions>
<DockPanel DockPanel.Dock="Top"> <Grid.ColumnDefinitions>
</DockPanel> <ColumnDefinition Width="Auto"/>
</DockPanel> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="signalType_TextBlock" Margin="0,0,10,5" Grid.Row="0" Grid.Column="0">Тип сигнала:</TextBlock>
<ComboBox x:Name="signalType_ComboBox" Margin="0,0,0,5" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="1"/>
<DataGrid x:Name="signalProps_DataGrid" Margin="0,0,0,5" HorizontalAlignment="Stretch" Grid.Row="1" Grid.ColumnSpan="2">
<DataGrid.Columns>
<DataGridTextColumn Header="Название" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="Параметр" />
</DataGrid.Columns>
</DataGrid>
<Button x:Name="createItem_Button" Height="20" Width="120" Content="Создать элемент" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"/>
</Grid> </Grid>
</Window> </Window>

65
Signal Generator/MainWindow.xaml

@ -5,35 +5,40 @@
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="Signal Generator" Height="450" Width="489"> Title="Генератор сигналов" Height="450" Width="489">
<Grid> <Grid Margin="10">
<DockPanel LastChildFill="True" Margin="10,10,10,10"> <Grid.RowDefinitions>
<ListBox x:Name="signals_ListBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" <RowDefinition Height="*"/>
DockPanel.Dock="Top" ItemsSource="{Binding}" Margin="0,0,0,20"> <RowDefinition Height="Auto"/>
<ListBox.ItemTemplate> </Grid.RowDefinitions>
<DataTemplate> <Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal"> <ColumnDefinition Width="Auto"/>
<TextBlock> <ColumnDefinition Width="*"/>
<TextBlock.Text> <ColumnDefinition Width="Auto"/>
<MultiBinding StringFormat=" {0} {1}"> <ColumnDefinition Width="Auto"/>
<Binding Path="typeToString"/> </Grid.ColumnDefinitions>
<Binding Path="paramsToString"/>
</MultiBinding> <ListBox x:Name="signals_ListBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
</TextBlock.Text> DockPanel.Dock="Top" ItemsSource="{Binding}" Margin="0,0,0,5" Grid.ColumnSpan="4">
</TextBlock> <ListBox.ItemTemplate>
</StackPanel> <DataTemplate>
</DataTemplate> <StackPanel Orientation="Horizontal">
</ListBox.ItemTemplate> <TextBlock>
</ListBox> <TextBlock.Text>
</DockPanel> <MultiBinding StringFormat=" {0} {1}">
<DockPanel x:Name="buttons_DockPanel" IsEnabled="True" Margin="10,0,10,10" VerticalAlignment="Bottom"> <Binding Path="typeToString"/>
<DockPanel DockPanel.Dock="Left"> <Binding Path="paramsToString"/>
<Button x:Name="startProcedure_Button" Width="120" Content="Запустить процедуру" /> </MultiBinding>
</DockPanel> </TextBlock.Text>
<DockPanel HorizontalAlignment="Right"> </TextBlock>
<Button x:Name="addSignal_Button" Width="20" Content="+" Click="addSignal_Button_Click"/> </StackPanel>
<Button x:Name="removeSignal_Button" Width="20" Content="-"/> </DataTemplate>
</DockPanel> </ListBox.ItemTemplate>
</DockPanel> </ListBox>
<Button x:Name="startProcedure_Button" Content="Запустить процедуру" Click="startProcedure_Button_Click"
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"/>
</Grid> </Grid>
</Window> </Window>

15
Signal Generator/MainWindow.xaml.cs

@ -21,13 +21,21 @@ namespace Signal_Generator
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
AddSignalWindow addSignalWindow_Instance = new AddSignalWindow();
TaskWindow taskWindow_Instance = new TaskWindow();
ObservableCollection<IAnalogSignal> s; ObservableCollection<IAnalogSignal> s;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
s = new ObservableCollection<IAnalogSignal>(); s = new ObservableCollection<IAnalogSignal>();
signals_ListBox.Items.Clear(); signals_ListBox.Items.Clear();
signals_ListBox.ItemsSource = s; signals_ListBox.ItemsSource = s;
addSignalWindow_Instance.Closed += addSignalWindow_Instance_Closed;
}
private void addSignalWindow_Instance_Closed(object sender, EventArgs e)
{
} }
private void addSomeExtra() private void addSomeExtra()
@ -40,7 +48,12 @@ namespace Signal_Generator
private void addSignal_Button_Click(object sender, RoutedEventArgs e) private void addSignal_Button_Click(object sender, RoutedEventArgs e)
{ {
addSomeExtra(); addSignalWindow_Instance.Show();
}
private void startProcedure_Button_Click(object sender, RoutedEventArgs e)
{
taskWindow_Instance.Show();
} }
} }
} }

40
Signal Generator/TaskWindow.xaml

@ -5,24 +5,28 @@
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="TaskWindow" Height="127" Width="284" Title="Моделирование работы группы сигналов" Height="250" Width="500"
ResizeMode="NoResize"> ResizeMode="NoResize">
<Grid> <Grid Margin="10">
<DockPanel VerticalAlignment="Top" Margin="10,10,10,0"> <Grid.RowDefinitions>
<DockPanel> <RowDefinition Height="*"/>
<TextBlock x:Name="currentTime_TextBlock" TextWrapping="Wrap" DockPanel.Dock="Top" Height="18"> <RowDefinition Height="Auto"/>
Время выполения: <RowDefinition Height="Auto"/>
</TextBlock> <RowDefinition Height="Auto"/>
<TextBlock x:Name="currentAmplitude_TextBlock" TextWrapping="Wrap"> </Grid.RowDefinitions>
Текущий сигнал: <Grid.ColumnDefinitions>
</TextBlock> <ColumnDefinition Width="*"/>
</DockPanel> <ColumnDefinition Width="Auto"/>
<TextBox x:Name="currentTime_TextBox" TextWrapping="Wrap" DockPanel.Dock="Top"/> <ColumnDefinition Width="*"/>
<TextBox x:Name="currentAmplitude_TextBox" TextWrapping="Wrap" DockPanel.Dock="Top"/> <ColumnDefinition Width="*"/>
<DockPanel HorizontalAlignment="Center"> </Grid.ColumnDefinitions>
<Button x:Name="start_Button" Width="60" Content="Старт" Margin="5,0"/>
<Button x:Name="pause_Button" Width="60" Content="Пауза" Margin="5,0"/> <Canvas x:Name="signalGraph_Canvas" Grid.ColumnSpan="4" Margin="0,0,0,5"></Canvas>
</DockPanel> <TextBlock x:Name="currentTime_TextBlock" Margin="0,0,5,5" Grid.Row="1" Grid.Column="1">Время выполения:</TextBlock>
</DockPanel> <TextBox x:Name="currentTime_TextBox" Margin="0,0,0,5" Grid.Row="1" Grid.Column="2"/>
<TextBlock x:Name="currentAmplitude_TextBlock" Margin="0,0,5,5" Grid.Row="2" Grid.Column="1">Текущий сигнал:</TextBlock>
<TextBox x:Name="currentAmplitude_TextBox" Margin="0,0,0,5" Grid.Row="2" Grid.Column="2"/>
<Button x:Name="start_Button" Width="60" Content="Старт" Margin="5,0" Grid.Row="3" Grid.Column="1"/>
<Button x:Name="pause_Button" Width="60" Content="Пауза" Margin="5,0" Grid.Row="3" Grid.Column="2"/>
</Grid> </Grid>
</Window> </Window>

Loading…
Cancel
Save