You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
14 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl"
  4. xmlns:system="clr-namespace:System;assembly=mscorlib">
  5. <ResourceDictionary.MergedDictionaries>
  6. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/TextBox.xaml" />
  7. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/RepeatButton.xaml" />
  8. </ResourceDictionary.MergedDictionaries>
  9. <Style x:Key="RubyerNumericBox" TargetType="{x:Type bpa:NumericBox}">
  10. <Setter Property="Background" Value="{DynamicResource ControlBackground}" />
  11. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  12. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  13. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  14. <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
  15. <Setter Property="Cursor" Value="IBeam" />
  16. <Setter Property="HorizontalContentAlignment" Value="Left" />
  17. <Setter Property="VerticalContentAlignment" Value="Center" />
  18. <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
  19. <Setter Property="Validation.ErrorTemplate" Value="{StaticResource RubyerValidationErrorTemplate}" />
  20. <Setter Property="ShowButton" Value="True" />
  21. <Setter Property="MaxLength" Value="{x:Static system:Int32.MaxValue}" />
  22. <Setter Property="Interval" Value="1" />
  23. <Setter Property="NumericType" Value="Int" />
  24. <Setter Property="Padding" Value="0 5" />
  25. <Setter Property="MinValue" Value="{x:Static system:Double.MinValue}" />
  26. <Setter Property="MaxValue" Value="{x:Static system:Double.MaxValue}" />
  27. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  28. <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Primary}" />
  29. <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Primary}" />
  30. <Setter Property="bpa:InputBoxHelper.IsClearable" Value="False" />
  31. <Setter Property="bpa:InputBoxHelper.PreContent" Value="{x:Null}" />
  32. <Setter Property="bpa:InputBoxHelper.Watermark" Value="{x:Null}" />
  33. <Setter Property="Template">
  34. <Setter.Value>
  35. <ControlTemplate TargetType="{x:Type bpa:NumericBox}">
  36. <Grid x:Name="PART_Root">
  37. <TextBox x:Name="PART_TextBox"
  38. Style="{StaticResource RubyerTextBox}"
  39. Height="Auto"
  40. Padding="{TemplateBinding Padding}"
  41. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  42. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  43. bpa:ControlHelper.CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  44. bpa:ControlHelper.FocusBorderBrush="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  45. bpa:ControlHelper.MouseOverBrush="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  46. bpa:InputBoxHelper.InternalSpacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  47. bpa:InputBoxHelper.IsClearable="{Binding Path=(bpa:InputBoxHelper.IsClearable), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  48. bpa:InputBoxHelper.PreContent="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  49. bpa:InputBoxHelper.Watermark="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  50. Background="{TemplateBinding Background}"
  51. BorderBrush="{TemplateBinding BorderBrush}"
  52. BorderThickness="{TemplateBinding BorderThickness}"
  53. Foreground="{TemplateBinding Foreground}"
  54. InputMethod.IsInputMethodEnabled="False"
  55. IsReadOnly="{TemplateBinding IsReadOnly}"
  56. MaxLength="{TemplateBinding MaxLength}">
  57. <bpa:InputBoxHelper.PostContent>
  58. <StackPanel Orientation="Horizontal">
  59. <ContentControl x:Name="PART_Content"
  60. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  61. Content="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  62. <UniformGrid Height="28"
  63. Columns="1"
  64. Rows="2"
  65. Visibility="{TemplateBinding ShowButton, Converter={StaticResource BooleanToVisibleConverter}}">
  66. <RepeatButton x:Name="PART_IncreaseButton"
  67. Style="{StaticResource TextRepeatButton}"
  68. Padding="0"
  69. bpa:ControlHelper.CornerRadius="{DynamicResource TopControlCornerRadius}"
  70. Focusable="False"
  71. Foreground="{DynamicResource SeconarydText}">
  72. <bpa:Icon Type="ArrowUpSLine" />
  73. </RepeatButton>
  74. <RepeatButton x:Name="PART_DecreaseButton"
  75. Style="{StaticResource TextRepeatButton}"
  76. Padding="0"
  77. bpa:ControlHelper.CornerRadius="{DynamicResource BottomControlCornerRadius}"
  78. Focusable="False"
  79. Foreground="{DynamicResource SeconarydText}">
  80. <bpa:Icon Type="ArrowDownSLine" />
  81. </RepeatButton>
  82. </UniformGrid>
  83. </StackPanel>
  84. </bpa:InputBoxHelper.PostContent>
  85. </TextBox>
  86. </Grid>
  87. <ControlTemplate.Triggers>
  88. <Trigger Property="Validation.HasError" Value="True">
  89. <Setter TargetName="PART_TextBox" Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Error}" />
  90. <Setter TargetName="PART_TextBox" Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Error}" />
  91. <Setter TargetName="PART_TextBox" Property="BorderBrush" Value="{DynamicResource Error}" />
  92. </Trigger>
  93. <Trigger Property="bpa:InputBoxHelper.IsRound" Value="True">
  94. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  95. </Trigger>
  96. </ControlTemplate.Triggers>
  97. </ControlTemplate>
  98. </Setter.Value>
  99. </Setter>
  100. </Style>
  101. <Style x:Key="FrontBackNumericBox"
  102. BasedOn="{StaticResource RubyerNumericBox}"
  103. TargetType="{x:Type bpa:NumericBox}">
  104. <Setter Property="bpa:ControlHelper.CornerRadius" Value="0" />
  105. <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
  106. <!--<Setter Property="BorderThickness" Value="0 1" />-->
  107. <Setter Property="Template">
  108. <Setter.Value>
  109. <ControlTemplate TargetType="{x:Type bpa:NumericBox}">
  110. <Grid x:Name="PART_Root">
  111. <Grid.ColumnDefinitions>
  112. <ColumnDefinition Width="Auto" />
  113. <ColumnDefinition Width="*" />
  114. <ColumnDefinition Width="Auto" />
  115. </Grid.ColumnDefinitions>
  116. <TextBox x:Name="PART_TextBox"
  117. Style="{StaticResource RubyerTextBox}"
  118. Grid.Column="1"
  119. Height="Auto"
  120. Padding="{TemplateBinding Padding}"
  121. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  122. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  123. bpa:ControlHelper.CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  124. bpa:ControlHelper.FocusBorderBrush="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  125. bpa:ControlHelper.MouseOverBrush="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  126. bpa:InputBoxHelper.InternalSpacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  127. bpa:InputBoxHelper.IsClearable="{Binding Path=(bpa:InputBoxHelper.IsClearable), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  128. bpa:InputBoxHelper.PostContent="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  129. bpa:InputBoxHelper.PreContent="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  130. bpa:InputBoxHelper.Watermark="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  131. BorderBrush="{TemplateBinding BorderBrush}"
  132. BorderThickness="{TemplateBinding BorderThickness}"
  133. Focusable="{TemplateBinding Focusable}"
  134. Foreground="{TemplateBinding Foreground}"
  135. InputMethod.IsInputMethodEnabled="False"
  136. IsReadOnly="{TemplateBinding IsReadOnly}"
  137. MaxLength="{TemplateBinding MaxLength}" />
  138. <RepeatButton x:Name="PART_DecreaseButton"
  139. Height="Auto"
  140. Padding="5"
  141. VerticalAlignment="Stretch"
  142. bpa:ControlHelper.CornerRadius="{DynamicResource LeftControlCornerRadius}"
  143. Background="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  144. Focusable="False"
  145. Foreground="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  146. Visibility="{TemplateBinding ShowButton, Converter={StaticResource BooleanToVisibleConverter}}">
  147. <bpa:Icon Type="SubtractLine" />
  148. </RepeatButton>
  149. <RepeatButton x:Name="PART_IncreaseButton"
  150. Grid.Column="2"
  151. Height="Auto"
  152. Padding="5"
  153. VerticalAlignment="Stretch"
  154. bpa:ControlHelper.CornerRadius="{DynamicResource RightControlCornerRadius}"
  155. Background="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  156. Focusable="False"
  157. Foreground="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  158. Visibility="{TemplateBinding ShowButton, Converter={StaticResource BooleanToVisibleConverter}}">
  159. <bpa:Icon Type="AddLine" />
  160. </RepeatButton>
  161. </Grid>
  162. <ControlTemplate.Triggers>
  163. <Trigger Property="Validation.HasError" Value="True">
  164. <Setter TargetName="PART_TextBox" Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Error}" />
  165. <Setter TargetName="PART_TextBox" Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Error}" />
  166. <Setter TargetName="PART_TextBox" Property="BorderBrush" Value="{DynamicResource Error}" />
  167. </Trigger>
  168. </ControlTemplate.Triggers>
  169. </ControlTemplate>
  170. </Setter.Value>
  171. </Setter>
  172. </Style>
  173. <!-- Filled NumericBox -->
  174. <Style x:Key="FilledNumericBox"
  175. BasedOn="{StaticResource RubyerNumericBox}"
  176. TargetType="{x:Type bpa:NumericBox}">
  177. <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
  178. <Setter Property="Background" Value="{DynamicResource BorderLighter}" />
  179. <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource BorderLight}" />
  180. </Style>
  181. </ResourceDictionary>