ExpressionEditorWindow.xaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. <Grid Margin="5">
  12. <Grid.ColumnDefinitions>
  13. <ColumnDefinition Width="*"/>
  14. <ColumnDefinition Width="250"/>
  15. </Grid.ColumnDefinitions>
  16. <Grid.RowDefinitions>
  17. <RowDefinition Height="*"/>
  18. <RowDefinition Height="Auto"/>
  19. </Grid.RowDefinitions>
  20. <TextBox x:Name="Editor"
  21. Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
  22. Background="LightYellow"
  23. BorderThickness="1,1,0,1"
  24. Padding="5"
  25. FontFamily="Consolas" FontSize="12"
  26. TextWrapping="Wrap"
  27. PreviewLostKeyboardFocus="Editor_PreviewLostKeyboardFocus"
  28. PreviewTextInput="Editor_PreviewTextInput"
  29. KeyDown="Editor_KeyDown"/>
  30. <Border Grid.Column="1" Grid.Row="0"
  31. BorderBrush="DarkGray" BorderThickness="1,0,0,0">
  32. <ScrollViewer VerticalScrollBarVisibility="Auto">
  33. <StackPanel>
  34. <Border BorderThickness="0,0,0,1" BorderBrush="LightGray"
  35. Padding="5">
  36. <Expander Header="Functions">
  37. <ItemsControl ItemsSource="{x:Static local:ExpressionEditorWindow.FunctionTemplates}">
  38. <ItemsControl.ItemTemplate>
  39. <DataTemplate>
  40. <Border BorderThickness="1,0,0,1" BorderBrush="LightGray"
  41. Padding="5">
  42. <Expander Header="{Binding Item1}">
  43. <ListBox ItemsSource="{Binding Item2}"
  44. HorizontalContentAlignment="Stretch"
  45. BorderThickness="0">
  46. <ListBox.Template>
  47. <ControlTemplate>
  48. <ItemsPresenter/>
  49. </ControlTemplate>
  50. </ListBox.Template>
  51. <ListBox.ItemTemplate>
  52. <DataTemplate DataType="local:FunctionTemplate">
  53. <TextBlock Text="{Binding Template}"
  54. FontFamily="Consolas" FontSize="12"
  55. Padding="5"
  56. Tag="{Binding}"
  57. MouseLeftButtonUp="FunctionTemplate_Click"/>
  58. </DataTemplate>
  59. </ListBox.ItemTemplate>
  60. </ListBox>
  61. </Expander>
  62. </Border>
  63. </DataTemplate>
  64. </ItemsControl.ItemTemplate>
  65. </ItemsControl>
  66. </Expander>
  67. </Border>
  68. <Border BorderThickness="0,0,0,1" BorderBrush="LightGray"
  69. Margin="0,5,0,0"
  70. Padding="5">
  71. <Expander Header="Variables" IsExpanded="True">
  72. <ListBox ItemsSource="{Binding Path=Variables,ElementName=ExpressionWindow}"
  73. HorizontalContentAlignment="Stretch"
  74. BorderThickness="0">
  75. <ListBox.Template>
  76. <ControlTemplate>
  77. <ItemsPresenter/>
  78. </ControlTemplate>
  79. </ListBox.Template>
  80. <ListBox.ItemTemplate>
  81. <DataTemplate DataType="local:string">
  82. <Label Content="{Binding}"
  83. FontFamily="Consolas" FontSize="12"
  84. Tag="{Binding}"
  85. MouseLeftButtonUp="Variable_Click"/>
  86. </DataTemplate>
  87. </ListBox.ItemTemplate>
  88. </ListBox>
  89. </Expander>
  90. </Border>
  91. </StackPanel>
  92. </ScrollViewer>
  93. </Border>
  94. <Border Grid.Column="1" Grid.Row="1"
  95. BorderBrush="DarkGray" BorderThickness="1,0,0,0">
  96. <DockPanel LastChildFill="False">
  97. <Button Content="OK"
  98. DockPanel.Dock="Right"
  99. Click="OK_Click"
  100. Padding="5" Width="50" Height="30"/>
  101. </DockPanel>
  102. </Border>
  103. </Grid>
  104. </Window>