RecipeEditorControl.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <UserControl x:Class="Aitex.UI.RecipeEditor.RecipeEditorControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. mc:Ignorable="d"
  7. xmlns:s="clr-namespace:System;assembly=mscorlib"
  8. xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
  9. xmlns:app="clr-namespace:Aitex.UI.RecipeEditor"
  10. xmlns:xctl="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
  11. xmlns:toolkit="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
  12. xmlns:xctk="http://schemas.xceed.com/wpf/xaml/datagrid"
  13. d:DesignHeight="452" d:DesignWidth="1201" FontFamily="Arial,SimSun" >
  14. <Grid x:Name="grid1">
  15. <Grid.RowDefinitions>
  16. <RowDefinition Height="32" />
  17. <RowDefinition Height="426*" />
  18. </Grid.RowDefinitions>
  19. <Grid.Resources>
  20. <DataTemplate x:Key="defaultGroupTemplate">
  21. <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
  22. <ContentPresenter VerticalAlignment="Center" Content="{Binding Value}" ContentTemplate="{Binding Path=DataContext.ValueTemplate, RelativeSource={RelativeSource TemplatedParent}}" ContentTemplateSelector="{Binding Path=DataContext.ValueTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" />
  23. </StackPanel>
  24. </DataTemplate>
  25. <DataTemplate x:Key="{DataTemplateKey {x:Type xctk:Group}}" DataType="{x:Type xctk:Group}">
  26. <ContentControl Name="groupContentPresenter" Focusable="False" ContentTemplate="{StaticResource defaultGroupTemplate}" Content="{Binding}" />
  27. </DataTemplate>
  28. <Style TargetType="{x:Type xctk:GroupHeaderControl}" BasedOn="{x:Null}">
  29. <Setter Property="Template">
  30. <Setter.Value>
  31. <ControlTemplate TargetType="{x:Type xctk:GroupHeaderControl}">
  32. <Border BorderThickness="2">
  33. <StackPanel Orientation="Horizontal">
  34. <ContentPresenter/>
  35. </StackPanel>
  36. </Border>
  37. </ControlTemplate>
  38. </Setter.Value>
  39. </Setter>
  40. </Style>
  41. <app:CellForeColorConverter x:Key="CellForeColorConverter" />
  42. <app:ErrColorConverter x:Key="ErrColorConverter" />
  43. <app:ErrContentConverter x:Key="ErrContentConverter" />
  44. <app:ErrTooltipConverter x:Key="ErrTooltipConverter" />
  45. <app:RecipeHeadStringConverter x:Key="RecipeHeadStringConverter" />
  46. <app:CellBorderConverter x:Key="cellBorderConverter" />
  47. <app:JumpCellBorderConverter x:Key="jumpCellBorderConverter"/>
  48. <DataTemplate x:Key="columnRedTitleTemplate">
  49. <TextBlock Text="{Binding}" Foreground="Black"/>
  50. </DataTemplate>
  51. <DataTemplate x:Key="columnBlackTitleTemplate">
  52. <TextBlock Text="{Binding}" Foreground="Black"/>
  53. </DataTemplate>
  54. <DataTemplate x:Key="CustomTemplate">
  55. <Border BorderThickness="{Binding IsRunning,Converter={StaticResource cellBorderConverter}}" BorderBrush="Blue">
  56. <TextBlock Text="{Binding Display}" Foreground="Black" Background="{Binding Background}" ToolTip="{Binding ToolTip}" FontWeight="{Binding FontWeight}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
  57. </Border>
  58. </DataTemplate>
  59. <DataTemplate x:Key="RowHeadTemplate">
  60. <TextBlock Text="{Binding Path=FriendlyName}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="Black"/>
  61. </DataTemplate>
  62. <xctk:DataGridCollectionViewSource x:Key="recipeData" Source="{Binding RecipeRows}">
  63. <xctk:DataGridCollectionViewSource.GroupDescriptions>
  64. <PropertyGroupDescription PropertyName="CatalogName" />
  65. </xctk:DataGridCollectionViewSource.GroupDescriptions>
  66. </xctk:DataGridCollectionViewSource>
  67. </Grid.Resources>
  68. <Grid Grid.Row="0">
  69. <StackPanel Orientation="Horizontal">
  70. <toolkit:SplitButton Width="70" Focusable="False" BorderThickness="0" Command="{Binding OpenLocalRecipeCommand}" Visibility="{Binding SingleAppElementVisibility}">
  71. <toolkit:SplitButton.Content>
  72. <WrapPanel>
  73. <Image Height="16" Source="/RecipeEditorControl;component/Images/open.png" />
  74. <TextBlock Text=" Open" FontFamily="Arial,SimSun" />
  75. </WrapPanel>
  76. </toolkit:SplitButton.Content>
  77. <toolkit:SplitButton.DropDownContent>
  78. <ListBox ItemsSource="{Binding OpenRecipeList}">
  79. <ListBox.ItemTemplate>
  80. <DataTemplate>
  81. <Button Content="{Binding Item1}" Tag="{Binding Item2}" Background="Transparent" BorderBrush="Transparent" Height="20" Focusable="False" FontSize="12" Width="150" HorizontalContentAlignment="Left" Click="OpenButtonPanelLoaded" />
  82. </DataTemplate>
  83. </ListBox.ItemTemplate>
  84. </ListBox>
  85. </toolkit:SplitButton.DropDownContent>
  86. </toolkit:SplitButton>
  87. <toolkit:DropDownButton Width="70" Focusable="False" BorderThickness="0" x:Name="newButton" Visibility="{Binding SingleAppElementVisibility}">
  88. <toolkit:DropDownButton.Content>
  89. <WrapPanel>
  90. <Image Height="14" Source="/RecipeEditorControl;component/Images/edit_add.png" />
  91. <TextBlock Text=" New" FontFamily="Arial,SimSun" />
  92. </WrapPanel>
  93. </toolkit:DropDownButton.Content>
  94. <toolkit:DropDownButton.DropDownContent>
  95. <ListBox ItemsSource="{Binding CreateRecipeList}">
  96. <ListBox.ItemTemplate>
  97. <DataTemplate>
  98. <Button Content="{Binding Item1}" Tag="{Binding Item2}" Background="Transparent" BorderBrush="Transparent" Height="20" Focusable="False" FontSize="12" Width="150" HorizontalContentAlignment="Left" Click="NewButtonPanelLoaded" />
  99. </DataTemplate>
  100. </ListBox.ItemTemplate>
  101. </ListBox>
  102. </toolkit:DropDownButton.DropDownContent>
  103. </toolkit:DropDownButton>
  104. <Button Width="60" Focusable="False" BorderThickness="0" Command="{Binding SaveRecipeCommand}" Visibility="{Binding SingleAppElementVisibility}">
  105. <Button.Content>
  106. <WrapPanel>
  107. <Image Height="16" Source="/RecipeEditorControl;component/Images/save.png" />
  108. <TextBlock Text=" Save" FontFamily="Arial,SimSun" />
  109. </WrapPanel>
  110. </Button.Content>
  111. </Button>
  112. <toolkit:SplitButton Width="80" Focusable="False" BorderThickness="0" IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext.IsUndoEnabled}"
  113. Command="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext.UndoCommand}">
  114. <toolkit:SplitButton.Content>
  115. <WrapPanel>
  116. <Image Height="16" Source="/RecipeEditorControl;component/Images/arrow_undo.png" />
  117. <TextBlock Text="{DynamicResource GlobalLableButtonUndo}" FontFamily="Arial,SimSun" />
  118. </WrapPanel>
  119. </toolkit:SplitButton.Content>
  120. <toolkit:SplitButton.DropDownContent>
  121. <ListBox ItemsSource="{Binding UndoList}">
  122. <ListBox.ItemTemplate>
  123. <DataTemplate>
  124. <Button Content="{Binding Item1}" ToolTip="{Binding Item2}" Tag="{Binding Item3}"
  125. Background="Transparent" BorderBrush="Transparent" Command="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=DataContext.UndoCommand}"
  126. Height="20" Focusable="False" FontSize="10" CommandParameter="{Binding Item4}" />
  127. </DataTemplate>
  128. </ListBox.ItemTemplate>
  129. </ListBox>
  130. </toolkit:SplitButton.DropDownContent>
  131. </toolkit:SplitButton>
  132. <toolkit:SplitButton Width="80" Focusable="False" BorderThickness="0" IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext.IsRedoEnabled}"
  133. Command="{Binding RedoCommand}">
  134. <toolkit:SplitButton.Content>
  135. <WrapPanel>
  136. <Image Height="16" Source="/RecipeEditorControl;component/Images/arrow_redo.png" />
  137. <TextBlock Text="{DynamicResource GlobalLableButtonRedo}" FontFamily="Arial,SimSun" />
  138. </WrapPanel>
  139. </toolkit:SplitButton.Content>
  140. <toolkit:SplitButton.DropDownContent>
  141. <ListBox ItemsSource="{Binding RedoList}">
  142. <ListBox.ItemTemplate>
  143. <DataTemplate>
  144. <Button Content="{Binding Item1}" ToolTip="{Binding Item2}" Tag="{Binding Item3}"
  145. Background="Transparent" BorderBrush="Transparent" Command="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=DataContext.RedoCommand}"
  146. Height="20" Focusable="False" FontSize="10" CommandParameter="{Binding Item4}" />
  147. </DataTemplate>
  148. </ListBox.ItemTemplate>
  149. </ListBox>
  150. </toolkit:SplitButton.DropDownContent>
  151. </toolkit:SplitButton>
  152. <Button Width="80" Focusable="False" BorderThickness="0" Command="{Binding ExpandGroupCommand}">
  153. <Button.Content>
  154. <WrapPanel>
  155. <Image Height="13" Source="/RecipeEditorControl;component/Images/expand.png" />
  156. <TextBlock Text="{DynamicResource GlobalLableButtonExpand}" FontFamily="Arial,SimSun" />
  157. </WrapPanel>
  158. </Button.Content>
  159. </Button>
  160. <Button Width="80" Focusable="False" BorderThickness="0" Command="{Binding CollapseGroupCommand}">
  161. <Button.Content>
  162. <WrapPanel>
  163. <Image Height="13" Source="/RecipeEditorControl;component/Images/toggle.png" />
  164. <TextBlock Text="{DynamicResource GlobalLableButtonToggle}" FontFamily="Arial,SimSun" />
  165. </WrapPanel>
  166. </Button.Content>
  167. </Button>
  168. <Button Width="100" Focusable="False" BorderThickness="0" Command="{Binding ToggleHideSameCommand}">
  169. <Button.Content>
  170. <WrapPanel>
  171. <Image Height="16" Source="/RecipeEditorControl;component/Images/hideSame.png" />
  172. <TextBlock Text="{DynamicResource GlobalLableButtonHideSame}" FontFamily="Arial,SimSun" />
  173. </WrapPanel>
  174. </Button.Content>
  175. </Button>
  176. <Button Width="80" Focusable="False" BorderThickness="0" Command="{Binding RecipeExport2ExcelCommand}" Visibility="{Binding SingleAppElementVisibility}">
  177. <Button.Content>
  178. <WrapPanel>
  179. <Image Height="16" Source="/RecipeEditorControl;component/Images/excel.png" />
  180. <TextBlock Text="{DynamicResource GlobalLableButtonExport}" FontFamily="Arial,SimSun" />
  181. </WrapPanel>
  182. </Button.Content>
  183. </Button>
  184. <Button Width="100" Focusable="False" BorderThickness="0" Command="{Binding EditRecipeInfoCommand}"
  185. ToolTip="{Binding RecipeHead,Converter={StaticResource RecipeHeadStringConverter}}">
  186. <Button.Content>
  187. <WrapPanel>
  188. <Image Height="14" Source="/RecipeEditorControl;component/Images/property.png" />
  189. <TextBlock Text="{DynamicResource GlobalLableButtonSetting}" FontFamily="Arial,SimSun" />
  190. </WrapPanel>
  191. </Button.Content>
  192. </Button>
  193. <Button Width="80" Focusable="False" BorderThickness="0" Command="{Binding ShowDetailedErrInfoCommand}"
  194. Background="{Binding Path=Errors, Converter={StaticResource ErrColorConverter}}"
  195. ToolTip="{Binding Path=Errors, Converter={StaticResource ErrTooltipConverter}}">
  196. <Button.Content>
  197. <WrapPanel>
  198. <Image Height="14" Source="/RecipeEditorControl;component/Images/warning.png" />
  199. <TextBlock Text="{Binding Errors, Converter={StaticResource ErrContentConverter}}" TextAlignment="Right" FontFamily="Arial,SimSun"/>
  200. </WrapPanel>
  201. </Button.Content>
  202. </Button>
  203. <Button Width="80" Focusable="False" BorderThickness="0" Command="{Binding RecipeHelpDocCommand}" Visibility="{Binding SingleAppElementVisibility}">
  204. <Button.Content>
  205. <WrapPanel>
  206. <Image Height="16" Source="/RecipeEditorControl;component/Images/help.png" />
  207. <TextBlock Text=" Help" FontFamily="Arial,SimSun" />
  208. </WrapPanel>
  209. </Button.Content>
  210. </Button>
  211. <Grid Visibility="{Binding IsBarcodeVisibility}">
  212. <TextBox Foreground="White" FontSize="30" InputMethod.PreferredImeState="Off"
  213. InputMethod.IsInputMethodEnabled="False" Text="{Binding RecipeHead.Barcode}" PreviewTextInput="UIElement_OnPreviewTextInput" TabIndex="0" BorderThickness="1" Margin="0" Width="230" HorizontalAlignment="Center" TextAlignment="Center" VerticalContentAlignment="Center" >
  214. <TextBox.Background>
  215. <ImageBrush Stretch="Fill" x:Name="BarcodeBrushName" Opacity="0.1" AlignmentX="Center" AlignmentY="Center">
  216. <ImageBrush.ImageSource>
  217. <BitmapImage UriSource="/RecipeEditorControl;component/Images/barcode.png"/>
  218. </ImageBrush.ImageSource>
  219. </ImageBrush>
  220. </TextBox.Background>
  221. <TextBox.Triggers>
  222. <!-- Animates the color of the brush used to paint
  223. the second button from red to blue . -->
  224. <EventTrigger RoutedEvent="TextBox.GotFocus">
  225. <BeginStoryboard>
  226. <Storyboard>
  227. <DoubleAnimation
  228. Storyboard.TargetName="BarcodeBrushName"
  229. Storyboard.TargetProperty="Opacity"
  230. AutoReverse="True"
  231. RepeatBehavior="Forever"
  232. From="0" To="0.3" Duration="0:0:0.5" />
  233. </Storyboard>
  234. </BeginStoryboard>
  235. </EventTrigger>
  236. <EventTrigger RoutedEvent="TextBox.LostFocus">
  237. <BeginStoryboard>
  238. <Storyboard>
  239. <DoubleAnimation
  240. Storyboard.TargetName="BarcodeBrushName"
  241. Storyboard.TargetProperty="Opacity"
  242. AutoReverse="False"
  243. From="0.3" To="0.1" Duration="0:0:0.1" />
  244. </Storyboard>
  245. </BeginStoryboard>
  246. </EventTrigger>
  247. </TextBox.Triggers>
  248. </TextBox>
  249. </Grid>
  250. </StackPanel>
  251. <TextBlock Text="{Binding RecipeInfo}" Margin="0,5,17,5" HorizontalAlignment="Right" VerticalAlignment="Center" TextAlignment="Right" Width="142" Visibility="{Binding RecipeInfoTextVisibility}" />
  252. </Grid>
  253. <xctk:DataGridControl Grid.Row="1" x:Name="dataGrid1" ItemsSource="{Binding Source={StaticResource recipeData}}" FontSize="13"
  254. AutoCreateColumns="False" Background="#FFC5D0D8"
  255. ItemsPrimaryAxis="Horizontal" PagingBehavior="LeftToRight"
  256. UpdateSourceTrigger="CellContentChanged" Grid.RowSpan="2" BorderThickness="0.5" SelectionUnit="Cell">
  257. <i:Interaction.Triggers>
  258. <i:EventTrigger EventName="MouseRightButtonDown">
  259. <i:InvokeCommandAction Command="{Binding RightClickCommand}" />
  260. </i:EventTrigger>
  261. </i:Interaction.Triggers>
  262. <xctk:DataGridControl.View>
  263. <xctk:TableflowView FixedColumnCount="1" ContainerHeight="25" x:Name="tblView"
  264. VerticalGridLineThickness="0.5" HorizontalGridLineBrush="Gray"
  265. HorizontalGridLineThickness="0.5" VerticalGridLineBrush="Black"
  266. RowFadeInAnimationDuration="0"
  267. ScrollingAnimationDuration="0" ColumnStretchMinWidth="10"
  268. DetailIndicatorWidth="20" ShowRowSelectorPane="False"
  269. ShowScrollTip="False" UseDefaultHeadersFooters="False">
  270. <xctk:TableflowView.FixedHeaders>
  271. <DataTemplate>
  272. <xctk:ColumnManagerRow AllowColumnReorder="False" AllowColumnResize="True" AllowDrop="False" AllowSort="False" />
  273. </DataTemplate>
  274. </xctk:TableflowView.FixedHeaders>
  275. <xctk:TableView.Theme>
  276. <!--<xctk:LunaNormalColorTheme/>-->
  277. <xctk:ZuneNormalColorTheme />
  278. </xctk:TableView.Theme>
  279. </xctk:TableflowView>
  280. </xctk:DataGridControl.View>
  281. <xctk:DataGridControl.DefaultCellEditors>
  282. <xctk:CellEditor x:Key="{x:Type app:SmartCellData}">
  283. <xctk:CellEditor.EditTemplate>
  284. <DataTemplate>
  285. <app:SmartCellEditor Content="{xctk:CellEditorBinding}">
  286. <i:Interaction.Triggers>
  287. <i:EventTrigger EventName="Loaded">
  288. <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=xctk:DataGridControl},Path=DataContext.SmartCellEditorLoadedCommand}"
  289. CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=app:SmartCellEditor},Path=DataContext}" />
  290. </i:EventTrigger>
  291. <i:EventTrigger EventName="Unloaded">
  292. <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=xctk:DataGridControl},Path=DataContext.SmartCellEditorUnloadedCommand}"
  293. CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=app:SmartCellEditor},Path=DataContext}" />
  294. </i:EventTrigger>
  295. </i:Interaction.Triggers>
  296. </app:SmartCellEditor>
  297. </DataTemplate>
  298. </xctk:CellEditor.EditTemplate>
  299. </xctk:CellEditor>
  300. </xctk:DataGridControl.DefaultCellEditors>
  301. </xctk:DataGridControl>
  302. </Grid>
  303. </UserControl>