ExpressionEditorWindow.xaml 7.6 KB

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