RecipeEditorControl.xaml 19 KB

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