<Window
    x:Class="CADPythonShell.IronPythonConsole"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
    xmlns:console="clr-namespace:PythonConsoleControl;assembly=PythonConsoleControl"
    Title="IronPython Console"
    Width="850"
    Height="600"
    MinWidth="500"
    MinHeight="350">
    <!--
        Copyright (c) 2010 Joe Moorhouse
    -->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="30*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="0" Grid.Column="0">
            <console:IronPythonConsoleControl Name="consoleControl" />
        </Grid>
        <GridSplitter
            Grid.Row="1"
            Height="10"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Center" />
        <DockPanel Grid.Row="2" Grid.Column="0">
            <ToolBar DockPanel.Dock="Top">
                <ToolBar.Resources>
                    <Style TargetType="{x:Type Image}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                <Setter Property="Opacity" Value="0.30" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ToolBar.Resources>
                <Button Click="newFileClick">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/New.png"
                        ToolTip="Create A New File Python Script" />
                </Button>
                <Button Click="openFileClick">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Open.png"
                        ToolTip="Open Python Script" />
                </Button>
                <Button Click="saveFileClick">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Save.png"
                        ToolTip="Save This Script Into File" />
                </Button>
                <Button Click="saveAsFileClick">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/SaveAs.png"
                        ToolTip="Save This Script Into New File" />
                </Button>
                <Separator />
                <Button Command="Cut">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Cut.png"
                        ToolTip="Cut Selected" />
                </Button>
                <Button Command="Copy">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Copy.png"
                        ToolTip="Copy Selected" />
                </Button>
                <Button Command="Paste">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Paste.png"
                        ToolTip="Paste Into Script Editor" />
                </Button>
                <Button Command="Delete">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Delete.png"
                        ToolTip="Delete Selected" />
                </Button>
                <Separator />
                <Button Command="Undo">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Undo.png"
                        ToolTip="Undo" />
                </Button>
                <Button Command="Redo">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Redo.png"
                        ToolTip="Redo" />
                </Button>
                <Separator />
                <CheckBox IsChecked="{Binding ElementName=textEditor, Path=WordWrap}">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/WordWrap.png"
                        ToolTip="Toggle Word Wrap" />
                </CheckBox>
                <CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Number.png"
                        ToolTip="Toggle Line Numbers" />
                </CheckBox>
                <CheckBox IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Paragraph.png"
                        ToolTip="Toggle Show End of Line" />
                </CheckBox>
                <Separator />
                <Button Click="runClick">
                    <Image
                        Height="16"
                        SnapsToDevicePixels="True"
                        Source="Images/Run.png"
                        ToolTip="Run Script. Results will be displayed in the IronPython prompt." />
                </Button>
            </ToolBar>
            <Grid DockPanel.Dock="Bottom">
                <avalonEdit:TextEditor
                    Name="textEditor"
                    FontFamily="Consolas"
                    FontSize="10pt"
                    GotFocus="textEditor_GotFocus">
                    # IronPython Pad. Write code snippets here and F5 to run.
                </avalonEdit:TextEditor>
            </Grid>
        </DockPanel>
    </Grid>
</Window>