WPFMessageBox.xaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <Window x:Name="MessageBoxWindow"
  2. x:Class="Aitex.Core.UI.Dialog.WPFMessageBox"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:local="clr-namespace:Aitex.Core.UI.Dialog"
  8. mc:Ignorable="d"
  9. MaxWidth="500"
  10. AllowsTransparency="True"
  11. Background="Transparent"
  12. Closing="MessageBoxWindow_Closing"
  13. Loaded="Window_Loaded"
  14. MouseDown="Window_MouseDown"
  15. RenderTransformOrigin="0.5, 0.5"
  16. ResizeMode="NoResize"
  17. Topmost="True"
  18. ShowInTaskbar="False"
  19. SizeToContent="WidthAndHeight"
  20. Title="MyMessageBox"
  21. WindowStartupLocation="CenterScreen"
  22. WindowStyle="None">
  23. <Window.RenderTransform>
  24. <ScaleTransform x:Name="Scale"/>
  25. </Window.RenderTransform>
  26. <Window.Resources>
  27. <!-- Brushes -->
  28. <LinearGradientBrush x:Key="BackgroundBrush" StartPoint="0,0" EndPoint="0,1">
  29. <GradientStop Offset="0" Color="#E4E9F0"/>
  30. <GradientStop Offset="1" Color="#D5DDED"/>
  31. </LinearGradientBrush>
  32. <!-- Styles -->
  33. <Style TargetType="Label">
  34. <Setter Property="VerticalContentAlignment" Value="Center"/>
  35. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  36. <Setter Property="FontFamily" Value="Segoe UI"/>
  37. <Setter Property="FontSize" Value="12pt"/>
  38. <Setter Property="Foreground" Value="#FF003399"/>
  39. </Style>
  40. <Style TargetType="Image">
  41. <Setter Property="Height" Value="32"/>
  42. <Setter Property="Width" Value="32"/>
  43. <Setter Property="Margin" Value="3"/>
  44. </Style>
  45. <Style TargetType="Button">
  46. <Setter Property="Height" Value="23"/>
  47. <Setter Property="Width" Value="75"/>
  48. <Setter Property="Margin" Value="3"/>
  49. </Style>
  50. <!-- Animation -->
  51. <Storyboard x:Key="LoadAnimation">
  52. <DoubleAnimation
  53. AccelerationRatio="0.4"
  54. Duration="00:00:00.15"
  55. From="0.6"
  56. Storyboard.TargetName="Scale"
  57. Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
  58. To="1.1"/>
  59. <DoubleAnimation
  60. AccelerationRatio="0.4"
  61. Duration="00:00:00.15"
  62. From="0.6"
  63. Storyboard.TargetName="Scale"
  64. Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
  65. To="1.1"/>
  66. <DoubleAnimation
  67. AccelerationRatio="0.4"
  68. Duration="00:00:00.15"
  69. From="0"
  70. Storyboard.TargetName="MessageBoxWindow"
  71. Storyboard.TargetProperty="(Window.Opacity)"
  72. To="1"/>
  73. <DoubleAnimation
  74. BeginTime="00:00:00.15"
  75. Duration="00:00:00.1"
  76. From="1.1"
  77. Storyboard.TargetName="Scale"
  78. Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
  79. To="1"/>
  80. <DoubleAnimation
  81. BeginTime="00:00:00.15"
  82. Duration="00:00:00.1"
  83. From="1.1"
  84. Storyboard.TargetName="Scale"
  85. Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
  86. To="1"/>
  87. </Storyboard>
  88. <Storyboard x:Key="UnloadAnimation">
  89. <DoubleAnimation
  90. AccelerationRatio="0.4"
  91. Duration="00:00:00.2"
  92. From="1"
  93. Storyboard.TargetName="Scale"
  94. Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
  95. To="0.6"/>
  96. <DoubleAnimation
  97. AccelerationRatio="0.4"
  98. Duration="00:00:00.2"
  99. From="1"
  100. Storyboard.TargetName="Scale"
  101. Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
  102. To="0.6"/>
  103. <DoubleAnimation
  104. AccelerationRatio="0.4"
  105. Duration="00:00:00.2"
  106. From="1"
  107. Storyboard.TargetName="MessageBoxWindow"
  108. Storyboard.TargetProperty="(Window.Opacity)"
  109. To="0"/>
  110. </Storyboard>
  111. </Window.Resources>
  112. <!-- Border with Margin = 50 to allow the animation to grow beyond the window's original size.
  113. If this was omitted the window would just get cropped when it reached it's original size and try to grow-->
  114. <Border
  115. Margin="50"
  116. Background="{StaticResource BackgroundBrush}"
  117. BorderBrush="CornflowerBlue"
  118. BorderThickness="2"
  119. Padding="7">
  120. <DockPanel LastChildFill="True">
  121. <Expander
  122. x:Name="DetailsExpander"
  123. Margin="0,7,0,0"
  124. DockPanel.Dock="Bottom"
  125. Header="细节">
  126. <DockPanel Margin="3" LastChildFill="True">
  127. <TextBox
  128. x:Name="DetailsText"
  129. MaxHeight="275"
  130. IsReadOnly="True"
  131. IsReadOnlyCaretVisible="True"
  132. TextWrapping="Wrap"
  133. VerticalScrollBarVisibility="Auto"/>
  134. </DockPanel>
  135. </Expander>
  136. <!-- placeholder for the buttons-->
  137. <StackPanel
  138. x:Name="ButtonsPanel"
  139. HorizontalAlignment="Center"
  140. DockPanel.Dock="Bottom"
  141. Orientation="Horizontal"/>
  142. <Image x:Name="ImagePlaceholder" DockPanel.Dock="Left"/>
  143. <!-- The label contains a text block to enable text wrapping-->
  144. <Label x:Name="MessageLabel" DockPanel.Dock="Right">
  145. <TextBlock x:Name="MessageText" TextWrapping="Wrap"/>
  146. </Label>
  147. </DockPanel>
  148. </Border>
  149. </Window>