<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="Stimuli_Creator.MainWindow"
        Title="Stimuli creator" Height="949" Width="1309" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" ResizeMode="NoResize">
    <Grid Margin="0,14,80,-14">
        <Label Content="MHz" HorizontalAlignment="Left" Margin="60,36,0,0" VerticalAlignment="Top" RenderTransformOrigin="-4.62,-0.512" Height="26" Width="35"/>
        <TextBox x:Name="MHz" HorizontalAlignment="Left" Height="23" Margin="10,39,0,0" TextWrapping="Wrap" Text="8" VerticalAlignment="Top" Width="50" MaxLines="1" MaxLength="6" TextChanged="MHz_TextChanged"/>
        <Label Content="MCU speed" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" Width="90" Height="26"/>

        <ComboBox x:Name="registerSelection" HorizontalAlignment="Left" Margin="10,88,0,0" VerticalAlignment="Top" Width="120" Height="22" IsEditable="True" SelectionChanged="registerSelection_SelectionChanged">
            <ComboBoxItem Content="PINA"/>
            <ComboBoxItem Content="PINB"/>
            <ComboBoxItem Content="PINC"/>
            <ComboBoxItem Content="PIND"/>
            <ComboBoxItem Content="PINE"/>
            <ComboBoxItem Content="PINF"/>
        </ComboBox>
        <Button x:Name="createBtn" Content="Create stimuli file" HorizontalAlignment="Left" Margin="10,285,0,0" VerticalAlignment="Top" Width="130" Click="createBtn_Click" RenderTransformOrigin="0.5,0.5" IsEnabled="False" ToolTip="Creates stimuli file and saves it. PORT must be selected" ToolTipService.ShowOnDisabled="True">
        </Button>
        <Button x:Name="clrBtn" Content="Clear" HorizontalAlignment="Left" Margin="10,320,0,0" VerticalAlignment="Top" Width="80" Click="clrBtn_Click" >        
        </Button>
        <Button x:Name="nextPage" Content="Ø" HorizontalAlignment="Left" Height="24" Margin="1215,760,-37,0" VerticalAlignment="Top" Width="45" FontFamily="Wingdings" Click="pageChange"/>
        <Button x:Name="prevPage" Content="×" HorizontalAlignment="Left" Height="24" Margin="215,760,0,0" VerticalAlignment="Top" Width="45" FontFamily="Wingdings" Click="pageChange"/>

        <Grid x:Name="PortGrid" HorizontalAlignment="Left" Height="800" Margin="145,10,-36,0" VerticalAlignment="Top" Width="1140">

            <Canvas x:Name="myCanvas0" HorizontalAlignment="Left" Height="720" Margin="84,10,0,0" VerticalAlignment="Top" Width="1081" MouseLeftButtonDown="Canvas_MouseLeftButtonDown">
                <Rectangle x:Name="PlotGraph0" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="10" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph1" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="100" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="190" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2_Copy" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="280" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2_Copy1" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="370" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2_Copy2" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="460" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2_Copy3" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="550" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle x:Name="PlotGraph2_Copy4" Stroke="Black" Height="80" StrokeThickness="0" Canvas.Top="640" Width="1001" Canvas.Left="10" Canvas.Bottom="10" VerticalAlignment="Top" Loaded="canvasFormat">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile" Stretch="None" Viewport="0,0,50,80" ViewportUnits="Absolute" Opacity="1" >
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="LightGray">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <!--<RectangleGeometry Rect="10,10,50,100"/>-->

                                            <LineGeometry StartPoint="0,0" EndPoint="0,60" />
                                            <LineGeometry StartPoint="0,60" EndPoint="50,60" />

                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen Thickness="1">
                                            <Pen.Brush>
                                                <!-- Test
                                        <LinearGradientBrush>
                                            <GradientStop Offset="0.0" Color="Blue" />
                                            <GradientStop Offset="2.0" Color="Black" />
                                        </LinearGradientBrush>
                                        -->
                                                <SolidColorBrush>RED</SolidColorBrush>
                                            </Pen.Brush>
                                        </Pen>
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </Canvas>
            <TextBlock x:Name="stepStart" HorizontalAlignment="Left" Height="20" Margin="45,725,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="95" TextAlignment="Center"><Run Text="0"/><Run Text=" ms"/></TextBlock>
            <TextBlock x:Name="stepStop" HorizontalAlignment="Left" Height="20" Margin="1055,725,0,0" TextWrapping="Wrap" Text="80 ms" VerticalAlignment="Top" Width="75" TextAlignment="Center"/>
        </Grid>
        <ComboBox x:Name="seconds" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Margin="90,175,0,0" SelectedIndex="1" SelectionChanged="seconds_SelectionChanged" >
            <ListBoxItem Content="s" />
            <ListBoxItem Content="ms"/>
            <ListBoxItem Content="µs"/>

        </ComboBox>
        <TextBox x:Name="stepSize" HorizontalAlignment="Left" Height="23" Margin="10,174,0,0" TextWrapping="Wrap" Text="5" VerticalAlignment="Top" Width="75" MaxLines="1" MaxLength="5" TextChanged="stepSize_TextChanged"/>
        <Label Content="Register" HorizontalAlignment="Left" Margin="10,62,0,0" VerticalAlignment="Top" Width="90" Height="26"/>
        <TextBlock x:Name="errorLabel" HorizontalAlignment="Left" Margin="145,10,0,0" TextWrapping="Wrap" Text=" " VerticalAlignment="Top" Width="225" Foreground="Red"/>
        <TextBlock HorizontalAlignment="Left" Margin="11,153,0,0" TextWrapping="Wrap" Text="Step size" VerticalAlignment="Top" Width="119" Foreground="Black"/>
        <TextBox x:Name="loopCount" HorizontalAlignment="Left" Height="23" Margin="11,244,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="29" MaxLines="1" MaxLength="5" TextChanged="stepSize_TextChanged"/>
        <TextBlock x:Name="___No_Name__Copy2" HorizontalAlignment="Left" Margin="11,223,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="164" Foreground="Black"><Run Text="Loop count"/><Run Text=" set to 0 for infinite"/></TextBlock>
        <CheckBox x:Name="loopSelection" Content="Loop" HorizontalAlignment="Left" Height="18" Margin="11,205,0,0" VerticalAlignment="Top" Width="70"/>
        <CheckBox x:Name="defaultBitState" Content="Default high" HorizontalAlignment="Left" Height="18" Margin="10,115,0,0" VerticalAlignment="Top" Width="120" Checked="defaultBitState_Checked"/>
    </Grid>
</Window>

    