RecipeEditorControl.xaml 21 KB

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