<ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Expressions"
        xmlns:expressions="clr-namespace:Telerik.Windows.Controls.Expressions;assembly=Telerik.Windows.Controls.Expressions"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:c="http://schemas.telerik.com/2008/xaml/compile"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="c">
    <ResourceDictionary.MergedDictionaries>
        <telerik:GreenResourceDictionary/>
    </ResourceDictionary.MergedDictionaries>
    <telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    <Color x:Key="FunctionColor_Foreground">#FF1795E5</Color>
    <Color x:Key="MemberColor_Foreground">#FF8C2CBA</Color>
    <Color x:Key="StringColor_Foreground">#FF31CA34</Color>
    <Color x:Key="DateTimeColor_Foreground">#FFE51717</Color>
    <Color x:Key="CaretBrush">#FF808080</Color>
    <Style x:Key="ExpressionPathStyle" TargetType="Path">
        <Setter Property="Fill" Value="{telerik:GreenResource ResourceKey=StrongBrush}"/>
        <Setter Property="Stretch" Value="Fill"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Width" Value="5"/>
        <Setter Property="Height" Value="5"/>
    </Style>
    <Style x:Key="ExpressionEqualsPathStyle" TargetType="Path">
        <Setter Property="Margin" Value="0 1 0 0"/>
        <Setter Property="Fill" Value="{telerik:GreenResource ResourceKey=StrongBrush}"/>
        <Setter Property="Stretch" Value="Fill"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
    </Style>
    <ControlTemplate x:Key="ExpressionTextBoxTemplate" TargetType="expressions:ExpressionTextBox">
        <telerik:RadRichTextBox x:Name="RichTextBox"
                AcceptsReturn="False"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CaretColor="{StaticResource CaretBrush}"
                IsSpellCheckingEnabled="False"
                IsSelectionMiniToolBarEnabled="False"
                IsContextMenuEnabled="False"
                DocumentInheritsDefaultStyleSettings="True"/>
    </ControlTemplate>
    <Style x:Key="ExpressionTextBoxStyle" TargetType="expressions:ExpressionTextBox">
        <Setter Property="Template" Value="{StaticResource ExpressionTextBoxTemplate}"/>
        <Setter Property="Background" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="SyntaxColors">
            <Setter.Value>
                <expressions:SyntaxColors
                        FunctionColor="{StaticResource FunctionColor_Foreground}"
                        MemberColor="{StaticResource MemberColor_Foreground}"
                        StringColor="{StaticResource StringColor_Foreground}"
                        DateTimeColor="{StaticResource DateTimeColor_Foreground}"
                        DefaultColor="{telerik:GreenResource ResourceKey=DefaultForegroundColor}"/>
            </Setter.Value>
        </Setter>
    </Style>
    <HierarchicalDataTemplate x:Key="CategoryItemTemplate" ItemsSource="{Binding ChildCategories}">
        <TextBlock Text="{Binding Name}"/>
    </HierarchicalDataTemplate>
    <ControlTemplate x:Key="RadExpressionEditorTemplate" TargetType="controls:RadExpressionEditor">
        <Border x:Name="PART_RootElement"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                SnapsToDevicePixels="True">
            <Grid x:Name="PART_ExpressionEditorGrid">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <expressions:ExpressionTextBox x:Name="PART_ExpressionNodeEditor"/>
                <Border
                        Grid.Row="1"
                        MinHeight="30"
                        Background="{telerik:GreenResource ResourceKey=PrimaryBrush}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="0 1"
                        SnapsToDevicePixels="True">
                    <StackPanel x:Name="CalculationPanel" Margin="0 0 13 0" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
                        <telerik:RadPathButton x:Name="Plus"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="+"
                                PathGeometry="M3,0 L5,0 L5,3 L8,3 L8,5 L5,5 L5,8 L3,8 L3,5L 0,5 L0,3 L3,3z"/>
                        <telerik:RadPathButton x:Name="Minus"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="-"
                                PathGeometry="M0,0 L8,0 L8,2 L0,2z"/>
                        <telerik:RadPathButton x:Name="Multiply"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="*"
                                PathGeometry="M1,0 L4,3 L7,0 L8,1 L5,4 L8,7 L7,8 L4,5 L1,8 L0,7 L3,4 L0,1z"/>
                        <telerik:RadPathButton x:Name="Divide"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="/"
                                PathGeometry="M6,0 L8,0 L2,8 L0,8z"/>
                        <telerik:RadPathButton x:Name="Percent"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="%"
                                PathGeometry="M6.5,5 C7.3,5 8,5.6 8,6.5 C8,7.3 7.3,8 6.5,8 C5.6,8 5,7.3 5,6.5 C5,5.6 5.6,5 6.5,5z M6,0 L8,0 L2,8 L0,8z M1.5,0 C2.3,0 3,0.6 3,1.5 C3,2.3 2.3,3 1.5,3 C0.6,3 0,2.3 0,1.5 C0,0.6 0.6,0 1.5,0z"/>
                        <telerik:RadPathButton x:Name="Equals"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                PathStyle="{StaticResource ExpressionEqualsPathStyle}"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="="
                                PathGeometry="M0,2 L5,2 L5,3 L0,3 z M0,0 L5,0 L5,1 L0,1 z"/>
                        <telerik:RadPathButton x:Name="NotEquals"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="&lt;&gt;"
                                PathGeometry="M3.75,0 L5,0 L4.25,1 L5,1 L5,2 L3.5,2 L2.75,3 L5,3 L5,4 L2,4 L1.25,5 L0,5 L0.75,4 L0,4 L0,3 L1.5,3 L2.25,2 L0,2 L0,1 L3,1z"/>
                        <telerik:RadPathButton x:Name="LessThan"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                PathStyle="{StaticResource ExpressionPathStyle}"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="&lt;"
                                PathGeometry="M0,4 L4,0 L5,0 L5,1 L2,4 L5,7 L5,8 L4,8z"/>
                        <telerik:RadPathButton x:Name="LessThanOrEquals"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="&lt;="
                                PathGeometry="M7,3 L12,3 L12,4 L7,4 z M7,1 L12,1 L12,2 L7,2 z M4,0 L5,0 L5,0.625 L2,2.5 L5,4.375 L5,5 L4,5 L0,2.5 z"/>
                        <telerik:RadPathButton x:Name="GreaterThanOrEquals"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="&gt;="
                                PathGeometry="M7,3 L12,3 L12,4 L7,4 z M7,1 L12,1 L12,2 L7,2 z M0,0 L1,0 L5,2.5 L1,5 L0,5 L0,4.375 L3,2.5 L0,0.625 z"/>
                        <telerik:RadPathButton x:Name="GreaterThan"
                                Margin="2 0"
                                Padding="2"
                                MinWidth="18"
                                MinHeight="18"
                                PathStyle="{StaticResource ExpressionPathStyle}"
                                Command="controls:RadExpressionEditorCommands.InsertText"
                                CommandParameter="&gt;"
                                PathGeometry="M0,0 L1,0 L5,4 L1,8 L0,8 L0,7 L3,4 L0,1z"/>
                        <telerik:RadButton x:Name="And" Content="And" Margin="8 0 2 0" Padding="0" MinWidth="30" MinHeight="18" Command="controls:RadExpressionEditorCommands.InsertText" CommandParameter="And"/>
                        <telerik:RadButton x:Name="Or" Content="Or" Margin="2 0" Padding="0" MinWidth="30" MinHeight="18" Command="controls:RadExpressionEditorCommands.InsertText" CommandParameter="Or"/>
                        <telerik:RadButton x:Name="Not" Content="Not" Margin="2 0" Padding="0" MinWidth="30" MinHeight="18" Command="controls:RadExpressionEditorCommands.InsertText" CommandParameter="Not"/>
                    </StackPanel>
                </Border>
                <Grid Grid.Row="2" Background="{telerik:GreenResource ResourceKey=PrimaryBrush}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <telerik:RadTreeView x:Name="PART_EditorCategoriesTree"
                            BorderThickness="0 0 1 0"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            ItemsSource="{Binding Categories}"
                            SelectedItem="{Binding SelectedCategory, Mode=TwoWay}"
                            MinHeight="146"
                            ItemTemplate="{StaticResource CategoryItemTemplate}"
                            IsLineEnabled="True"/>
                    <telerik:RadTreeView x:Name="PART_EditorItemsTree"
                            FontWeight="Bold"
                            MinHeight="146"
                            BorderThickness="0"
                            Grid.Column="1"
                            ItemsSource="{Binding CategoryItems}"
                            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                            DisplayMemberPath="Name"/>
                </Grid>
                <Border x:Name="EditorInfoPanel" Grid.Row="3" BorderThickness="0 1" BorderBrush="{TemplateBinding BorderBrush}" MinHeight="76">
                    <Grid Margin="6">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock
                                Grid.Row="0"
                                Text="{Binding SelectedItem.QuickInfo}"
                                Foreground="{TemplateBinding Foreground}"
                                FontSize="{TemplateBinding FontSize}"
                                FontFamily="{TemplateBinding FontFamily}"
                                FontWeight="Bold"/>
                        <TextBlock
                                Grid.Row="1"
                                Text="{Binding SelectedItem.Description}"
                                Foreground="{TemplateBinding Foreground}"
                                FontSize="{TemplateBinding FontSize}"
                                FontFamily="{TemplateBinding FontFamily}"
                                TextWrapping="Wrap"/>
                    </Grid>
                </Border>
                <Border x:Name="EditorResultsPanel" Grid.Row="4" Background="{telerik:GreenResource ResourceKey=PrimaryBrush}">
                    <StackPanel Orientation="Horizontal" Margin="6">
                        <TextBlock Text="Result preview:" HorizontalAlignment="Right"/>
                        <TextBlock Text="{Binding PreviewResult}" TextAlignment="Right"/>
                    </StackPanel>
                </Border>
            </Grid>
        </Border>
    </ControlTemplate>
    <Style x:Key="RadExpressionEditorStyle" TargetType="controls:RadExpressionEditor">
        <Setter Property="Template" Value="{StaticResource RadExpressionEditorTemplate}"/>
        <Setter Property="FontFamily" Value="{telerik:GreenResource ResourceKey=FontFamily}"/>
        <Setter Property="FontSize" Value="{telerik:GreenResource ResourceKey=FontSize}"/>
        <Setter Property="Foreground" Value="{telerik:GreenResource ResourceKey=MarkerBrush}"/>
        <Setter Property="Background" Value="{telerik:GreenResource ResourceKey=MainBrush}"/>
        <Setter Property="BorderBrush" Value="{telerik:GreenResource ResourceKey=BasicBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
    </Style>
    <Style TargetType="controls:RadExpressionEditor" BasedOn="{StaticResource RadExpressionEditorStyle}"/>
    <Style TargetType="expressions:ExpressionTextBox" BasedOn="{StaticResource ExpressionTextBoxStyle}"/>
</ResourceDictionary>
