WindowStyle.xaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:styleableWindow="clr-namespace:WpfStyleableWindow.StyleableWindow;assembly=MECF.Framework.Common">
  4. <!--主窗口背景色-->
  5. <!--<Style TargetType="Window" x:Key="mainBackground">
  6. <Setter Property="Background">
  7. <Setter.Value>
  8. <ImageBrush ImageSource="pack://application:,,,/MECF.Framework.Common;component/Resources/Main/主界面_切片.png" />
  9. </Setter.Value>
  10. </Setter>
  11. </Style>-->
  12. <ImageBrush x:Key="mainBackgroundImg" ImageSource="pack://application:,,,/MECF.Framework.Common;component/Resources/Main/主界面_切片SORTER.png" />
  13. <ImageBrush x:Key="loginBackgroundImg" ImageSource="pack://application:,,,/MECF.Framework.Common;component/Resources/Main/login.png" />
  14. <!--背景颜色-->
  15. <!--<SolidColorBrush Color="#1E7FC3" x:Key="mainBackgroundColor" />-->
  16. <SolidColorBrush x:Key="mainBackgroundColor" Color="#FF0671BC"/>
  17. <SolidColorBrush x:Key="mainInnerBackgroundColor" Color="#FFA4E1F8"/>
  18. <SolidColorBrush x:Key="mainCenterBackgroundColor" Color="#FFDDECF9"/>
  19. <SolidColorBrush Color="#669ACC" x:Key="viewBackgroundColor" />
  20. <!--<SolidColorBrush Color="#548C9B" x:Key="mainBackgroundColor" />
  21. <SolidColorBrush Color="#548C9B" x:Key="viewBackgroundColor" />-->
  22. <!--<SolidColorBrush Color="LightBlue" x:Key="titleBackgroundColor"/> // 427F7D afd5d5 -->
  23. <SolidColorBrush x:Key="Table_BG_Title" Color="#FF8BBDE0"/>
  24. <SolidColorBrush x:Key="Table_BG_Content" Color="#FFFFFFFF"/>
  25. <SolidColorBrush x:Key="HeaderPanel_BG_Title" Color="#FF94BCD7"/>
  26. <SolidColorBrush x:Key="HeaderPanel_BG" Color="#FFD1E1F3"/>
  27. <!--the brushes used in the template (use these to customize the window look along with the window style (see the bottom of this file)-->
  28. <SolidColorBrush x:Key="WindowColor" Color="Red"/>
  29. <SolidColorBrush x:Key="WindowBackColor" Color="LightBlue"/>
  30. <SolidColorBrush x:Key="WindowForeColor" Color="WhiteSmoke"/>
  31. <SolidColorBrush x:Key="WindowForeHighlightColor" Color="WhiteSmoke"/>
  32. <SolidColorBrush x:Key="WindowButtonColor" Color="DodgerBlue"/>
  33. <SolidColorBrush x:Key="WindowButtonOverColor" Color="LightBlue"/>
  34. <SolidColorBrush x:Key="WindowButtonPressedColor" Color="DarkBlue"/>
  35. <!--BottomView Style-->
  36. <SolidColorBrush x:Key="BtmnavButton_FG" Color="#FF004294"/>
  37. <SolidColorBrush x:Key="BottomFrame_BG" Color="#FF0C206C"/>
  38. <!---red window brushes-->
  39. <!--<SolidColorBrush x:Key="WindowColor" Color="DarkRed"/>
  40. <SolidColorBrush x:Key="WindowBackColor" Color="DarkRed"/>
  41. <SolidColorBrush x:Key="WindowForeColor" Color="White"/>
  42. <SolidColorBrush x:Key="WindowForeHighlightColor" Color="White"/>
  43. <SolidColorBrush x:Key="WindowButtonColor" Color="OrangeRed"/>
  44. <SolidColorBrush x:Key="WindowButtonOverColor" Color="Orange"/>
  45. <SolidColorBrush x:Key="WindowButtonPressedColor" Color="DarkOrange"/>-->
  46. <!--The window template and it's components -->
  47. <styleableWindow:WindowMinimizeCommand x:Key="MinimizeCommand"></styleableWindow:WindowMinimizeCommand>
  48. <styleableWindow:WindowMaximizeCommand x:Key="MaximizeCommand"></styleableWindow:WindowMaximizeCommand>
  49. <styleableWindow:WindowCloseCommand x:Key="CloseCommand"></styleableWindow:WindowCloseCommand>
  50. <Style TargetType="{x:Type Button}" x:Key="WindowButton">
  51. <Setter Property="Height" Value="25"/>
  52. <Setter Property="Width" Value="25"/>
  53. <Setter Property="Background" Value="{StaticResource WindowButtonColor}"/>
  54. <Setter Property="Foreground" Value="{StaticResource WindowForeColor}"/>
  55. <Setter Property="Template">
  56. <Setter.Value>
  57. <ControlTemplate TargetType="{x:Type Button}">
  58. <Border Background="{TemplateBinding Background}">
  59. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
  60. </Border>
  61. <ControlTemplate.Triggers>
  62. <Trigger Property="IsEnabled" Value="False">
  63. <Setter Property="Background" Value="{StaticResource WindowButtonColor}"/>
  64. <Setter Property="Foreground" Value="{StaticResource WindowColor}"/>
  65. </Trigger>
  66. <Trigger Property="IsMouseOver" Value="True">
  67. <Setter Property="Background" Value="{StaticResource WindowButtonOverColor}"/>
  68. <Setter Property="Foreground" Value="{StaticResource WindowForeHighlightColor}"/>
  69. </Trigger>
  70. <Trigger Property="IsPressed" Value="True">
  71. <Setter Property="Background" Value="{StaticResource WindowButtonPressedColor}"/>
  72. <Setter Property="Foreground" Value="{StaticResource WindowForeColor}"/>
  73. </Trigger>
  74. </ControlTemplate.Triggers>
  75. </ControlTemplate>
  76. </Setter.Value>
  77. </Setter>
  78. </Style>
  79. <Style TargetType="{x:Type Image}" x:Key="WindowIcon">
  80. <Setter Property="Height" Value="25"/>
  81. <Setter Property="Width" Value="25"/>
  82. </Style>
  83. <ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}">
  84. <Grid Background="{StaticResource WindowBackColor}">
  85. <Grid>
  86. <Grid.RowDefinitions>
  87. <RowDefinition Height="30"/>
  88. <RowDefinition Height="*"/>
  89. </Grid.RowDefinitions>
  90. <Grid Grid.Row="0" Margin="5,0,5,0">
  91. <Grid.ColumnDefinitions>
  92. <ColumnDefinition Width="auto"/>
  93. <ColumnDefinition Width="*"/>
  94. <ColumnDefinition Width="75"/>
  95. </Grid.ColumnDefinitions>
  96. <Label Grid.Column="0"
  97. styleableWindow:ControlDoubleClickBehavior.ExecuteCommand="{StaticResource CloseCommand}"
  98. styleableWindow:ControlDoubleClickBehavior.ExecuteCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Padding="0">
  99. <Image DockPanel.Dock="Left" Style="{StaticResource WindowIcon}" Source="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}},Path=Icon}"
  100. Width="16"
  101. styleableWindow:ShowSystemMenuBehavior.TargetWindow="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
  102. styleableWindow:ShowSystemMenuBehavior.LeftButtonShowAt="{Binding ElementName=WindowContent}"/>
  103. </Label>
  104. <Label Grid.Column="1" DockPanel.Dock="Left" Content="{TemplateBinding Property=Title}" Padding="3,0,0,0"
  105. HorizontalContentAlignment="Center"
  106. VerticalContentAlignment="Center"
  107. HorizontalAlignment="Stretch"
  108. VerticalAlignment="Stretch"
  109. Foreground="{StaticResource WindowForeColor}"
  110. FontSize="16"
  111. styleableWindow:WindowDragBehavior.LeftMouseButtonDrag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
  112. styleableWindow:ControlDoubleClickBehavior.ExecuteCommand="{StaticResource MaximizeCommand}"
  113. styleableWindow:ControlDoubleClickBehavior.ExecuteCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
  114. styleableWindow:ShowSystemMenuBehavior.TargetWindow="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
  115. styleableWindow:ShowSystemMenuBehavior.RightButtonShow="true">
  116. </Label>
  117. <StackPanel Grid.Column="2" Orientation="Horizontal">
  118. <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource MinimizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">_</Button>
  119. <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource MaximizeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">+</Button>
  120. <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Command="{StaticResource CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">X</Button>
  121. </StackPanel>
  122. </Grid>
  123. <Border Grid.Row="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  124. <Grid>
  125. <AdornerDecorator>
  126. <ContentPresenter x:Name="WindowContent"/>
  127. </AdornerDecorator>
  128. <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
  129. </Grid>
  130. </Border>
  131. </Grid>
  132. <Thumb x:Name="ThumbTop" Height="6" Margin="14,0" VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" styleableWindow:WindowResizeBehavior.TopResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  133. <Thumb x:Name="ThumbTopLeft" Height="6" Width="6" VerticalAlignment="Top" HorizontalAlignment="Left" Cursor="SizeNWSE" Opacity="0" styleableWindow:WindowResizeBehavior.TopLeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  134. <Thumb x:Name="ThumbBottom" Height="6" Margin="14,0" VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" styleableWindow:WindowResizeBehavior.BottomResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  135. <Thumb x:Name="ThumbTopRight" Height="6" Width="6" VerticalAlignment="Top" HorizontalAlignment="Right" Cursor="SizeNESW" Opacity="0" styleableWindow:WindowResizeBehavior.TopRightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  136. <Thumb x:Name="ThumbRight" HorizontalAlignment="Right" Margin="0,14" Width="6" Cursor="SizeWE" Opacity="0" styleableWindow:WindowResizeBehavior.RightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  137. <Thumb x:Name="ThumbBottomRight" Height="6" Width="6" VerticalAlignment="Bottom" HorizontalAlignment="Right" Cursor="SizeNWSE" Opacity="0" styleableWindow:WindowResizeBehavior.BottomRightResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  138. <Thumb x:Name="ThumbLeft" HorizontalAlignment="Left" Margin="0,14" Width="6" Cursor="SizeWE" Opacity="0" styleableWindow:WindowResizeBehavior.LeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  139. <Thumb x:Name="ThumbBottomLeft" Height="6" Width="6" VerticalAlignment="Bottom" HorizontalAlignment="Left" Cursor="SizeNESW" Opacity="0" styleableWindow:WindowResizeBehavior.BottomLeftResize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
  140. </Grid>
  141. <ControlTemplate.Triggers>
  142. <MultiTrigger>
  143. <MultiTrigger.Conditions>
  144. <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
  145. <Condition Property="WindowState" Value="Normal"/>
  146. </MultiTrigger.Conditions>
  147. <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
  148. </MultiTrigger>
  149. </ControlTemplate.Triggers>
  150. </ControlTemplate>
  151. <!-- the custom window style and the window template
  152. Here you can customize the look of the window without having to touch the control template
  153. or comment out the brushes and create a new style (see the red style below)-->
  154. <Style x:Key="CustomWindowStyle" TargetType="{x:Type Window}">
  155. <Setter Property="WindowStyle" Value="None"/>
  156. <Setter Property="AllowsTransparency" Value="True"/>
  157. <Setter Property="MinWidth" Value="200"/>
  158. <Setter Property="MinHeight" Value="46"/>
  159. <!--CaptionHeight + ResizeBorderThickness * 2-->
  160. <Setter Property="Background" Value="LightGray"/>
  161. <Setter Property="BorderBrush" Value="DodgerBlue"/>
  162. <Setter Property="BorderThickness" Value="2"/>
  163. <Setter Property="Foreground" Value="Black"/>
  164. <Setter Property="Template" Value="{StaticResource WindowTemplate}"/>
  165. </Style>
  166. <!--the red style window-->
  167. <Style x:Key="RedWindowStyle" TargetType="{x:Type Window}">
  168. <Setter Property="WindowStyle" Value="None"/>
  169. <Setter Property="AllowsTransparency" Value="True"/>
  170. <Setter Property="MinWidth" Value="100"/>
  171. <Setter Property="MinHeight" Value="46"/>
  172. <Setter Property="Background" Value="white"/>
  173. <Setter Property="BorderBrush" Value="DarkRed"/>
  174. <Setter Property="BorderThickness" Value="2"/>
  175. <Setter Property="Foreground" Value="DarkGray"/>
  176. <Setter Property="Template" Value="{StaticResource WindowTemplate}"/>
  177. </Style>
  178. </ResourceDictionary>