ExpressionEditorWindow.xaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <Window x:Class="InABox.DynamicGrid.ExpressionEditorWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:InABox.DynamicGrid"
  7. mc:Ignorable="d"
  8. Title="Expression Editor" Height="650" Width="800"
  9. Loaded="ExpressionWindow_Loaded"
  10. x:Name="ExpressionWindow">
  11. <Window.Resources>
  12. <Style x:Key="tooltipDescriptionStyle" TargetType="TextBlock">
  13. <Style.Triggers>
  14. <DataTrigger Binding="{Binding Path=Description}" Value="">
  15. <Setter Property="Visibility" Value="Collapsed" />
  16. </DataTrigger>
  17. </Style.Triggers>
  18. </Style>
  19. </Window.Resources>
  20. <Grid Margin="5">
  21. <Grid.ColumnDefinitions>
  22. <ColumnDefinition Width="*"/>
  23. <ColumnDefinition Width="250"/>
  24. </Grid.ColumnDefinitions>
  25. <Grid.RowDefinitions>
  26. <RowDefinition Height="*"/>
  27. <RowDefinition Height="Auto"/>
  28. </Grid.RowDefinitions>
  29. <TextBox x:Name="Editor"
  30. Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
  31. Background="LightYellow"
  32. BorderThickness="1,1,0,1"
  33. Padding="5"
  34. FontFamily="Consolas" FontSize="12"
  35. TextWrapping="Wrap"
  36. PreviewLostKeyboardFocus="Editor_PreviewLostKeyboardFocus"
  37. PreviewTextInput="Editor_PreviewTextInput"
  38. KeyDown="Editor_KeyDown"/>
  39. <Border Grid.Column="1" Grid.Row="0"
  40. BorderBrush="DarkGray" BorderThickness="1,0,0,0">
  41. <ScrollViewer VerticalScrollBarVisibility="Auto">
  42. <StackPanel>
  43. <Border BorderThickness="0,0,0,1" BorderBrush="LightGray"
  44. Padding="5">
  45. <Expander Header="Functions">
  46. <ItemsControl ItemsSource="{x:Static local:ExpressionEditorWindow.FunctionTemplates}">
  47. <ItemsControl.ItemTemplate>
  48. <DataTemplate>
  49. <Border BorderThickness="1,0,0,1" BorderBrush="WhiteSmoke"
  50. Padding="5">
  51. <Expander Header="{Binding Item1}">
  52. <ListBox ItemsSource="{Binding Item2}"
  53. HorizontalContentAlignment="Stretch"
  54. BorderThickness="0">
  55. <ListBox.Template>
  56. <ControlTemplate>
  57. <ItemsPresenter/>
  58. </ControlTemplate>
  59. </ListBox.Template>
  60. <ListBox.ItemTemplate>
  61. <DataTemplate DataType="local:FunctionTemplate">
  62. <ContentControl MouseDoubleClick="FunctionTemplate_Click"
  63. Tag="{Binding}">
  64. <TextBlock Text="{Binding Template}"
  65. FontFamily="Consolas" FontSize="12"
  66. Padding="5">
  67. <TextBlock.ToolTip>
  68. <ToolTip Background="LightGray">
  69. <StackPanel>
  70. <TextBlock Text="{Binding Tooltip}"
  71. FontFamily="Consolas" FontSize="12"/>
  72. <TextBlock Text="{Binding Description}" FontSize="12"
  73. Style="{StaticResource tooltipDescriptionStyle}"/>
  74. </StackPanel>
  75. </ToolTip>
  76. </TextBlock.ToolTip>
  77. </TextBlock>
  78. </ContentControl>
  79. </DataTemplate>
  80. </ListBox.ItemTemplate>
  81. </ListBox>
  82. </Expander>
  83. </Border>
  84. </DataTemplate>
  85. </ItemsControl.ItemTemplate>
  86. </ItemsControl>
  87. </Expander>
  88. </Border>
  89. <Border BorderThickness="0,0,0,1" BorderBrush="LightGray"
  90. Margin="0,5,0,0"
  91. Padding="5">
  92. <Expander Header="Variables" IsExpanded="True">
  93. <ListBox ItemsSource="{Binding Path=Variables,ElementName=ExpressionWindow}"
  94. HorizontalContentAlignment="Stretch"
  95. BorderThickness="0">
  96. <ListBox.Template>
  97. <ControlTemplate>
  98. <ItemsPresenter/>
  99. </ControlTemplate>
  100. </ListBox.Template>
  101. <ListBox.ItemTemplate>
  102. <DataTemplate DataType="local:string">
  103. <ContentControl MouseDoubleClick="Variable_Click"
  104. Tag="{Binding}">
  105. <TextBlock Text="{Binding}"
  106. FontFamily="Consolas" FontSize="12"
  107. Padding="5"/>
  108. </ContentControl>
  109. </DataTemplate>
  110. </ListBox.ItemTemplate>
  111. </ListBox>
  112. </Expander>
  113. </Border>
  114. </StackPanel>
  115. </ScrollViewer>
  116. </Border>
  117. <Border Grid.Column="1" Grid.Row="1"
  118. BorderBrush="DarkGray" BorderThickness="1,0,0,0">
  119. <DockPanel LastChildFill="False">
  120. <Button Content="OK"
  121. DockPanel.Dock="Right"
  122. Click="OK_Click"
  123. Padding="5" Width="50" Height="30"/>
  124. </DockPanel>
  125. </Border>
  126. </Grid>
  127. </Window>