ModernWindowResource.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:controls="http://firstfloorsoftware.com/ModernUI"
  5. xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell">
  6. <ResourceDictionary.MergedDictionaries>
  7. <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Button.xaml" />
  8. </ResourceDictionary.MergedDictionaries>
  9. <!-- additional ModernWindow styles -->
  10. <!-- empty window style, no backbutton, menu, title links and logo -->
  11. <Style
  12. x:Key="MyEmptyWindow"
  13. BasedOn="{StaticResource {x:Type controls:ModernWindow}}"
  14. TargetType="{x:Type controls:ModernWindow}">
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type controls:ModernWindow}">
  18. <Border x:Name="WindowBorder" Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}">
  19. <Border.Background>
  20. <SolidColorBrush x:Name="WindowBorderBackground" Color="{DynamicResource WindowBackgroundColor}" />
  21. </Border.Background>
  22. <Border.Resources>
  23. <Storyboard x:Key="BackgroundAnimation">
  24. <ColorAnimation
  25. Storyboard.TargetName="WindowBorderBackground"
  26. Storyboard.TargetProperty="Color"
  27. To="{DynamicResource WindowBackgroundColor}"
  28. Duration="0:0:.6" />
  29. </Storyboard>
  30. </Border.Resources>
  31. <Grid>
  32. <Border BorderBrush="{DynamicResource WindowBorder}" BorderThickness="1">
  33. <AdornerDecorator>
  34. <Grid x:Name="LayoutRoot">
  35. <Grid.RowDefinitions>
  36. <RowDefinition Height="*" />
  37. <RowDefinition Height="15" />
  38. </Grid.RowDefinitions>
  39. <!-- window background content -->
  40. <ContentControl Grid.RowSpan="2" Content="{TemplateBinding BackgroundContent}" />
  41. <!-- window content -->
  42. <ContentControl Grid.RowSpan="2" Content="{TemplateBinding Content}" />
  43. <!-- title blob -->
  44. <Border
  45. Grid.RowSpan="2"
  46. MinWidth="500"
  47. MinHeight="53"
  48. HorizontalAlignment="Left"
  49. VerticalAlignment="Top"
  50. Background="Transparent"
  51. RenderTransform="1,0,0,1,-10,-10">
  52. <TextBlock
  53. Margin="0,8"
  54. VerticalAlignment="Center"
  55. Text="{TemplateBinding Title,
  56. Converter={StaticResource ToUpperConverter}}"
  57. FontSize="50"
  58. DataContext="{TemplateBinding IsTitleVisible}"
  59. Foreground="White"
  60. Style="{DynamicResource ModernWindowTitle}"
  61. Visibility="Visible">
  62. <TextBlock.Effect>
  63. <DropShadowEffect
  64. BlurRadius="2"
  65. Direction="330"
  66. Opacity="0.3"
  67. ShadowDepth="3"
  68. Color="LightGray" />
  69. </TextBlock.Effect>
  70. <TextBlock.OpacityMask>
  71. <LinearGradientBrush StartPoint="0.5,0.1" EndPoint="0.5,0.9">
  72. <LinearGradientBrush.GradientStops>
  73. <GradientStop Offset="0" Color="White" />
  74. <GradientStop Offset="1" Color="Transparent" />
  75. </LinearGradientBrush.GradientStops>
  76. </LinearGradientBrush>
  77. </TextBlock.OpacityMask>
  78. </TextBlock>
  79. </Border>
  80. <!-- window system buttons -->
  81. <Grid
  82. Width="1920"
  83. Height="20"
  84. HorizontalAlignment="Left"
  85. VerticalAlignment="Top"
  86. Background="Transparent"
  87. Opacity="1" />
  88. <StackPanel
  89. Margin="0,8,6,0"
  90. HorizontalAlignment="Right"
  91. VerticalAlignment="Top"
  92. shell:WindowChrome.IsHitTestVisibleInChrome="True"
  93. Orientation="Horizontal"
  94. Visibility="Visible">
  95. <Button
  96. Command="{Binding Source={x:Static shell:SystemCommands.MinimizeWindowCommand}}"
  97. Style="{StaticResource SystemButton}"
  98. ToolTip="minimize">
  99. <Button.Content>
  100. <Grid
  101. Width="13"
  102. Height="12"
  103. RenderTransform="1,0,0,1,0,1">
  104. <Path
  105. Width="8"
  106. Height="7"
  107. HorizontalAlignment="Center"
  108. VerticalAlignment="Center"
  109. Data="M0,6 L8,6 Z"
  110. Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
  111. StrokeThickness="2" />
  112. </Grid>
  113. </Button.Content>
  114. </Button>
  115. <Grid Margin="1,0,1,0">
  116. <Button
  117. x:Name="Restore"
  118. Command="{Binding Source={x:Static shell:SystemCommands.RestoreWindowCommand}}"
  119. Style="{StaticResource SystemButton}"
  120. ToolTip="restore"
  121. Visibility="Collapsed">
  122. <Button.Content>
  123. <Grid
  124. Width="13"
  125. Height="12"
  126. RenderTransform="1,0,0,1,.5,.5"
  127. UseLayoutRounding="True">
  128. <Path
  129. Width="8"
  130. Height="8"
  131. HorizontalAlignment="Center"
  132. VerticalAlignment="Center"
  133. Data="M2,0 L8,0 L8,6 M0,3 L6,3 M0,2 L6,2 L6,8 L0,8 Z"
  134. Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
  135. StrokeThickness="1" />
  136. </Grid>
  137. </Button.Content>
  138. </Button>
  139. <Button
  140. x:Name="Maximize"
  141. Command="{Binding Source={x:Static shell:SystemCommands.MaximizeWindowCommand}}"
  142. Style="{StaticResource SystemButton}"
  143. ToolTip="maximize"
  144. Visibility="Collapsed">
  145. <Button.Content>
  146. <Grid Width="13" Height="12">
  147. <Path
  148. Width="9"
  149. Height="8"
  150. HorizontalAlignment="Center"
  151. VerticalAlignment="Center"
  152. Data="M0,1 L9,1 L9,8 L0,8 Z"
  153. Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
  154. StrokeThickness="2" />
  155. </Grid>
  156. </Button.Content>
  157. </Button>
  158. </Grid>
  159. <Button
  160. Command="{Binding Source={x:Static shell:SystemCommands.CloseWindowCommand}}"
  161. Style="{StaticResource SystemButton}"
  162. ToolTip="close"
  163. Visibility="Visible">
  164. <Button.Content>
  165. <Grid
  166. Width="13"
  167. Height="12"
  168. RenderTransform="1,0,0,1,0,1">
  169. <Path
  170. Width="8"
  171. Height="7"
  172. HorizontalAlignment="Center"
  173. VerticalAlignment="Center"
  174. Data="M0,0 L8,7 M8,0 L0,7 Z"
  175. Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
  176. StrokeThickness="1.5" />
  177. </Grid>
  178. </Button.Content>
  179. </Button>
  180. </StackPanel>
  181. <!-- resize grip -->
  182. <Grid Grid.Row="1">
  183. <Path
  184. x:Name="ResizeGrip"
  185. Width="12"
  186. Height="12"
  187. Margin="1"
  188. HorizontalAlignment="Right"
  189. Data="F1 M1,10 L3,10 M5,10 L7,10 M9,10 L11,10 M2,9 L2,11 M6,9 L6,11 M10,9 L10,11 M5,6 L7,6 M9,6 L11,6 M6,5 L6,7 M10,5 L10,7 M9,2 L11,2 M10,1 L10,3"
  190. Stretch="None"
  191. Stroke="{DynamicResource WindowText}"
  192. StrokeThickness="1"
  193. Visibility="Collapsed" />
  194. </Grid>
  195. </Grid>
  196. </AdornerDecorator>
  197. </Border>
  198. <Border
  199. BorderBrush="{DynamicResource WindowBorderActive}"
  200. BorderThickness="1"
  201. Visibility="{Binding IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource BooleanToVisibilityConverter}}" />
  202. </Grid>
  203. </Border>
  204. <ControlTemplate.Triggers>
  205. <Trigger Property="WindowState" Value="Maximized">
  206. <Setter TargetName="Maximize" Property="Visibility" Value="Collapsed" />
  207. <Setter TargetName="Restore" Property="Visibility" Value="Visible" />
  208. <Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
  209. </Trigger>
  210. <Trigger Property="WindowState" Value="Normal">
  211. <Setter TargetName="Maximize" Property="Visibility" Value="Visible" />
  212. <Setter TargetName="Restore" Property="Visibility" Value="Collapsed" />
  213. </Trigger>
  214. <MultiTrigger>
  215. <MultiTrigger.Conditions>
  216. <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
  217. <Condition Property="WindowState" Value="Normal" />
  218. </MultiTrigger.Conditions>
  219. <Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
  220. </MultiTrigger>
  221. </ControlTemplate.Triggers>
  222. </ControlTemplate>
  223. </Setter.Value>
  224. </Setter>
  225. </Style>
  226. </ResourceDictionary>