WPF遮蔽层的实现

在一些项目中,难免会有耗时的加载,如果加载时没有提示,给人一种假死的感觉,很不友好,那么现在福利来啦,WPF版的模态窗体,先上效果图

实际效果指针是转动的,话不多说,一大批干货来袭

XMAL的代码

  1 Window x:Class="ZhiHeng.IntelligentExpress.WpfUI.Views.CoverForm"
  2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5         Title="CoverForm"   x:Name="Window"
  6         Style="{StaticResource WindowsStyle}" Opacity="0.5">
  7     <Window.Resources>
  8         <Storyboard x:Key="Storyboard1">
  9             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)">
 10                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 11                 <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0" />
 12                 <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1" />
 13                 <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0" />
 14                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 15             </DoubleAnimationUsingKeyFrames>
 16             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse1">
 17                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 18                 <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0" />
 19                 <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1" />
 20                 <SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="0" />
 21                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 22             </DoubleAnimationUsingKeyFrames>
 23             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse2">
 24                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 25                 <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
 26                 <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="1" />
 27                 <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="0" />
 28                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 29             </DoubleAnimationUsingKeyFrames>
 30             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse3">
 31                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 32                 <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
 33                 <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="1" />
 34                 <SplineDoubleKeyFrame KeyTime="00:00:01.3000000" Value="0" />
 35                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 36             </DoubleAnimationUsingKeyFrames>
 37             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse4">
 38                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 39                 <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
 40                 <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="1" />
 41                 <SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="0" />
 42                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 43             </DoubleAnimationUsingKeyFrames>
 44             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse5">
 45                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 46                 <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0" />
 47                 <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" />
 48                 <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0" />
 49                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 50             </DoubleAnimationUsingKeyFrames>
 51             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse6">
 52                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 53                 <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0" />
 54                 <SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="1" />
 55                 <SplineDoubleKeyFrame KeyTime="00:00:01.6000000" Value="0" />
 56                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 57             </DoubleAnimationUsingKeyFrames>
 58             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse7">
 59                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 60                 <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="0" />
 61                 <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="1" />
 62                 <SplineDoubleKeyFrame KeyTime="00:00:01.7000000" Value="0" />
 63                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 64             </DoubleAnimationUsingKeyFrames>
 65             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse8">
 66                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 67                 <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="0" />
 68                 <SplineDoubleKeyFrame KeyTime="00:00:01.3000000" Value="1" />
 69                 <SplineDoubleKeyFrame KeyTime="00:00:01.8000000" Value="0" />
 70                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 71             </DoubleAnimationUsingKeyFrames>
 72             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse9">
 73                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 74                 <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0" />
 75                 <SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="1" />
 76                 <SplineDoubleKeyFrame KeyTime="00:00:01.9000000" Value="0" />
 77                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 78             </DoubleAnimationUsingKeyFrames>
 79             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse10">
 80                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 81                 <SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="0" />
 82                 <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1" />
 83                 <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0" />
 84                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 85             </DoubleAnimationUsingKeyFrames>
 86             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse11">
 87                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 88                 <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="0" />
 89                 <SplineDoubleKeyFrame KeyTime="00:00:01.6000000" Value="1" />
 90                 <SplineDoubleKeyFrame KeyTime="00:00:02.1000000" Value="0" />
 91                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 92             </DoubleAnimationUsingKeyFrames>
 93             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse12">
 94                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
 95                 <SplineDoubleKeyFrame KeyTime="00:00:01.3000000" Value="0" />
 96                 <SplineDoubleKeyFrame KeyTime="00:00:01.7000000" Value="1" />
 97                 <SplineDoubleKeyFrame KeyTime="00:00:02.2000000" Value="0" />
 98                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
 99             </DoubleAnimationUsingKeyFrames>
100             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse13">
101                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
102                 <SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="0" />
103                 <SplineDoubleKeyFrame KeyTime="00:00:01.8000000" Value="1" />
104                 <SplineDoubleKeyFrame KeyTime="00:00:02.3000000" Value="0" />
105                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
106             </DoubleAnimationUsingKeyFrames>
107             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse14">
108                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
109                 <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0" />
110                 <SplineDoubleKeyFrame KeyTime="00:00:01.9000000" Value="1" />
111                 <SplineDoubleKeyFrame KeyTime="00:00:02.4000000" Value="0" />
112                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
113             </DoubleAnimationUsingKeyFrames>
114             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse15">
115                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
116                 <SplineDoubleKeyFrame KeyTime="00:00:01.6000000" Value="0" />
117                 <SplineDoubleKeyFrame KeyTime="00:00:02" Value="1" />
118                 <SplineDoubleKeyFrame KeyTime="00:00:02.5000000" Value="0" />
119                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
120             </DoubleAnimationUsingKeyFrames>
121             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse16">
122                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
123                 <SplineDoubleKeyFrame KeyTime="00:00:01.7000000" Value="0" />
124                 <SplineDoubleKeyFrame KeyTime="00:00:02.1000000" Value="1" />
125                 <SplineDoubleKeyFrame KeyTime="00:00:02.6000000" Value="0" />
126                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
127             </DoubleAnimationUsingKeyFrames>
128             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse17">
129                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
130                 <SplineDoubleKeyFrame KeyTime="00:00:01.8000000" Value="0" />
131                 <SplineDoubleKeyFrame KeyTime="00:00:02.2000000" Value="1" />
132                 <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
133             </DoubleAnimationUsingKeyFrames>
134             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
135                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
136                 <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="180" />
137                 <SplineDoubleKeyFrame KeyTime="00:00:01" Value="360" />
138             </DoubleAnimationUsingKeyFrames>
139             <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="border1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
140                 <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
141                 <SplineDoubleKeyFrame KeyTime="00:00:02" Value="180" />
142                 <SplineDoubleKeyFrame KeyTime="00:00:04" Value="360" />
143             </DoubleAnimationUsingKeyFrames>
144         </Storyboard>
145     </Window.Resources>
146     <Window.Triggers>
147         <EventTrigger RoutedEvent="FrameworkElement.Loaded">
148             <BeginStoryboard Storyboard="{StaticResource Storyboard1}" />
149         </EventTrigger>
150     </Window.Triggers>
151     <Grid x:Name="LayoutRoot">
152         <Viewbox Width="8" Height="8">
153             <Grid HorizontalAlignment="Center" x:Name="loading" Margin="0" VerticalAlignment="Center" Width="3.333" Height="3.333" Visibility="Visible">
154                 <Ellipse RenderTransformOrigin="0.468,3.443" x:Name="ellipse" Fill="Black" Stroke="{x:Null}"  />
155                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}"  x:Name="ellipse0" >
156                     <Ellipse.RenderTransform>
157                         <TransformGroup>
158                             <ScaleTransform ScaleX="2" ScaleY="3" />
159                             <SkewTransform AngleX="0" AngleY="0" />
160                             <RotateTransform Angle="0" />
161                             <TranslateTransform X="0" Y="0" />
162                         </TransformGroup>
163                     </Ellipse.RenderTransform>
164                 </Ellipse>
165                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse1" >
166                     <Ellipse.RenderTransform>
167                         <TransformGroup>
168                             <ScaleTransform ScaleX="2" ScaleY="3" />
169                             <SkewTransform AngleX="0" AngleY="0" />
170                             <RotateTransform Angle="20" />
171                             <TranslateTransform X="0" Y="0" />
172                         </TransformGroup>
173                     </Ellipse.RenderTransform>
174                 </Ellipse>
175                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse2" >
176                     <Ellipse.RenderTransform>
177                         <TransformGroup>
178                             <ScaleTransform ScaleX="2" ScaleY="3" />
179                             <SkewTransform AngleX="0" AngleY="0" />
180                             <RotateTransform Angle="40" />
181                             <TranslateTransform X="0" Y="0" />
182                         </TransformGroup>
183                     </Ellipse.RenderTransform>
184                 </Ellipse>
185                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse3">
186                     <Ellipse.RenderTransform>
187                         <TransformGroup>
188                             <ScaleTransform ScaleX="2" ScaleY="3" />
189                             <SkewTransform AngleX="0" AngleY="0" />
190                             <RotateTransform Angle="60" />
191                             <TranslateTransform X="0" Y="0" />
192                         </TransformGroup>
193                     </Ellipse.RenderTransform>
194                 </Ellipse>
195                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse4">
196                     <Ellipse.RenderTransform>
197                         <TransformGroup>
198                             <ScaleTransform ScaleX="2" ScaleY="3" />
199                             <SkewTransform AngleX="0" AngleY="0" />
200                             <RotateTransform Angle="80" />
201                             <TranslateTransform X="0" Y="0" />
202                         </TransformGroup>
203                     </Ellipse.RenderTransform>
204                 </Ellipse>
205                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse5">
206                     <Ellipse.RenderTransform>
207                         <TransformGroup>
208                             <ScaleTransform ScaleX="2" ScaleY="3" />
209                             <SkewTransform AngleX="0" AngleY="0" />
210                             <RotateTransform Angle="100" />
211                             <TranslateTransform X="0" Y="0" />
212                         </TransformGroup>
213                     </Ellipse.RenderTransform>
214                 </Ellipse>
215                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse6" >
216                     <Ellipse.RenderTransform>
217                         <TransformGroup>
218                             <ScaleTransform ScaleX="2" ScaleY="3" />
219                             <SkewTransform AngleX="0" AngleY="0" />
220                             <RotateTransform Angle="120" />
221                             <TranslateTransform X="0" Y="0" />
222                         </TransformGroup>
223                     </Ellipse.RenderTransform>
224                 </Ellipse>
225                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse7" >
226                     <Ellipse.RenderTransform>
227                         <TransformGroup>
228                             <ScaleTransform ScaleX="2" ScaleY="3" />
229                             <SkewTransform AngleX="0" AngleY="0" />
230                             <RotateTransform Angle="140" />
231                             <TranslateTransform X="0" Y="0" />
232                         </TransformGroup>
233                     </Ellipse.RenderTransform>
234                 </Ellipse>
235                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse8" >
236                     <Ellipse.RenderTransform>
237                         <TransformGroup>
238                             <ScaleTransform ScaleX="2" ScaleY="3" />
239                             <SkewTransform AngleX="0" AngleY="0" />
240                             <RotateTransform Angle="160" />
241                             <TranslateTransform X="0" Y="0" />
242                         </TransformGroup>
243                     </Ellipse.RenderTransform>
244                 </Ellipse>
245                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse9" >
246                     <Ellipse.RenderTransform>
247                         <TransformGroup>
248                             <ScaleTransform ScaleX="2" ScaleY="3" />
249                             <SkewTransform AngleX="0" AngleY="0" />
250                             <RotateTransform Angle="180" />
251                             <TranslateTransform X="0" Y="0" />
252                         </TransformGroup>
253                     </Ellipse.RenderTransform>
254                 </Ellipse>
255                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse10" >
256                     <Ellipse.RenderTransform>
257                         <TransformGroup>
258                             <ScaleTransform ScaleX="2" ScaleY="3" />
259                             <SkewTransform AngleX="0" AngleY="0" />
260                             <RotateTransform Angle="200" />
261                             <TranslateTransform X="0" Y="0" />
262                         </TransformGroup>
263                     </Ellipse.RenderTransform>
264                 </Ellipse>
265                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse11" >
266                     <Ellipse.RenderTransform>
267                         <TransformGroup>
268                             <ScaleTransform ScaleX="2" ScaleY="3" />
269                             <SkewTransform AngleX="0" AngleY="0" />
270                             <RotateTransform Angle="220" />
271                             <TranslateTransform X="0" Y="0" />
272                         </TransformGroup>
273                     </Ellipse.RenderTransform>
274                 </Ellipse>
275                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse12" >
276                     <Ellipse.RenderTransform>
277                         <TransformGroup>
278                             <ScaleTransform ScaleX="2" ScaleY="3" />
279                             <SkewTransform AngleX="0" AngleY="0" />
280                             <RotateTransform Angle="240" />
281                             <TranslateTransform X="0" Y="0" />
282                         </TransformGroup>
283                     </Ellipse.RenderTransform>
284                 </Ellipse>
285                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse13" >
286                     <Ellipse.RenderTransform>
287                         <TransformGroup>
288                             <ScaleTransform ScaleX="2" ScaleY="3" />
289                             <SkewTransform AngleX="0" AngleY="0" />
290                             <RotateTransform Angle="260" />
291                             <TranslateTransform X="0" Y="0" />
292                         </TransformGroup>
293                     </Ellipse.RenderTransform>
294                 </Ellipse>
295                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse14" >
296                     <Ellipse.RenderTransform>
297                         <TransformGroup>
298                             <ScaleTransform ScaleX="2" ScaleY="3" />
299                             <SkewTransform AngleX="0" AngleY="0" />
300                             <RotateTransform Angle="280" />
301                             <TranslateTransform X="0" Y="0" />
302                         </TransformGroup>
303                     </Ellipse.RenderTransform>
304                 </Ellipse>
305                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse15" >
306                     <Ellipse.RenderTransform>
307                         <TransformGroup>
308                             <ScaleTransform ScaleX="2" ScaleY="3" />
309                             <SkewTransform AngleX="0" AngleY="0" />
310                             <RotateTransform Angle="300" />
311                             <TranslateTransform X="0" Y="0" />
312                         </TransformGroup>
313                     </Ellipse.RenderTransform>
314                 </Ellipse>
315                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse16" >
316                     <Ellipse.RenderTransform>
317                         <TransformGroup>
318                             <ScaleTransform ScaleX="2" ScaleY="3" />
319                             <SkewTransform AngleX="0" AngleY="0" />
320                             <RotateTransform Angle="320" />
321                             <TranslateTransform X="0" Y="0" />
322                         </TransformGroup>
323                     </Ellipse.RenderTransform>
324                 </Ellipse>
325                 <Ellipse RenderTransformOrigin="0.468,3.443" Fill="Black" Stroke="{x:Null}" x:Name="ellipse17" >
326                     <Ellipse.RenderTransform>
327                         <TransformGroup>
328                             <ScaleTransform ScaleX="2" ScaleY="3" />
329                             <SkewTransform AngleX="0" AngleY="0" />
330                             <RotateTransform Angle="340" />
331                             <TranslateTransform X="0" Y="0" />
332                         </TransformGroup>
333                     </Ellipse.RenderTransform>
334                 </Ellipse>
335                 <Ellipse RenderTransformOrigin="0.5,0.499" x:Name="ellipse_Copy" Fill="Black" Stroke="{x:Null}" Margin="-0.012,0,0.001,-9.67" VerticalAlignment="Bottom" Height="3.344">
336                     <Ellipse.RenderTransform>
337                         <TransformGroup>
338                             <ScaleTransform ScaleX="2" ScaleY="3" />
339                             <SkewTransform AngleX="0" AngleY="0" />
340                             <RotateTransform Angle="0" />
341                             <TranslateTransform X="0" Y="0" />
342                         </TransformGroup>
343                     </Ellipse.RenderTransform>
344                 </Ellipse>
345                 <Border RenderTransformOrigin="0.492,1.006" Margin="1.081,0,1.086,-8.056" x:Name="border" VerticalAlignment="Bottom" Height="8.622" Background="Black" CornerRadius="1,1,0,0">
346                     <Border.RenderTransform>
347                         <TransformGroup>
348                             <ScaleTransform ScaleX="2" ScaleY="3" />
349                             <SkewTransform AngleX="0" AngleY="0" />
350                             <RotateTransform Angle="0" />
351                             <TranslateTransform X="0" Y="0" />
352                         </TransformGroup>
353                     </Border.RenderTransform>
354                 </Border>
355                 <Border Height="4.994" Background="Black" CornerRadius="1,1,0,0" RenderTransformOrigin="0.496,1.001" Margin="0.705,0,0.714,-8.058" x:Name="border1" VerticalAlignment="Bottom">
356                     <Border.RenderTransform>
357                         <TransformGroup>
358                             <ScaleTransform ScaleX="2" ScaleY="3" />
359                             <SkewTransform AngleX="0" AngleY="0" />
360                             <RotateTransform Angle="0" />
361                             <TranslateTransform X="0" Y="0" />
362                         </TransformGroup>
363                     </Border.RenderTransform>
364                 </Border>
365             </Grid>
366         </Viewbox>
367         <Label Content="系统正在处理一些事情" FontSize="48" Foreground="Orange" HorizontalAlignment="Left" Margin="396,668,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.274,0.462"/>
368     </Grid>
369 </Window>

后台C#代码

 1  public partial class CoverForm : Window
 2     {
 3         public CoverForm(Action workAction)
 4         {
 5             InitializeComponent();
 6             this.workAction = workAction;
 7             System.Threading.Thread t = new System.Threading.Thread(ExecWorkAction);
 8             t.IsBackground = true;
 9             t.Start();
10         }
11         private Action workAction = null;
12         private void ExecWorkAction()
13         {
14             try
15             {
16                 var workTask = new Task(workAction);
17                 workTask.Start();
18                 Task.WaitAll(workTask);
19             }
20             finally
21             {
22                 this.Dispatcher.Invoke(new Action(() => { this.Close(); }));
23             }
24         }
25     }

调用的代码

1  new CoverForm(() => {耗时的代码 }); }).Show();          

有需要的尽管拿去吧,要问我是谁,请叫我是雷锋。

时间: 2024-11-15 09:57:49

WPF遮蔽层的实现的相关文章

Loading 遮蔽层 简单实现。

<!--背景div--><div id="bg" class="bg" style="display:none;text-align: center;"></div> <!--loading 图片 div --><div class="mydiv" id="popDiv"> <img src="${root }/common/ima

HTML页面弹出自定义对话框带遮蔽罩(使用JavaScript)

转载:http://blog.sina.com.cn/s/blog_610f47c50100ohe4.html 原理其实很简单:首先绘制弹出的自定义对话框,将其使用display:none隐藏,因为设置为none,其在页面中并不占用空间: 遮蔽罩使用一个div,然后将其宽高设置为整个显示窗口大小,配置其透明度,在将其z-index属性大于主页面的z-index的值,也就是遮蔽层在主页面上方,如此即可 事先隐藏一个div,在需要的时候调出显示既可. <!--以下代码从网上多处学习整合而成,由于来源

WPF核心对象模型-类图和解析

DispatcherObject是根基类,通过继承该类,可以得到访问创建该对象的UI线程的Dispatcher对象的能力.通过Dispatcher对象,可以将代码段合并入该UI线程执行. DependencyObject是核心基类,用于实现依赖属性机制.依赖属性是一个比CLR属性更强大的属性模型,该模型支持更改通知,默认值继承等特性,并能减少属性存储空间.DependencyObject通过GetValue和SetValue等方法支持依赖属性机制.继承该类的几个下一层基类Visual,Visua

运用WPF和ADO.Net实现限制登录错误次数的简单登录界面

最近看了一下传智播客的免费公开课视频,有一个登录界面的小练习.其中涉及到登录时间的限定功能,并未实现.所以我就自己动手写了一个,大家可以看看. 首先编写SqlHelper类,通过SqlHelper类实现SQL单语句操作数据库.代码如下: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Data.SqlClient; 6 usin

div滤镜结合ajax,实现登录

一:登陆页面 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>test</TITLE

基于多线程的C#版QQ农场

基于多线程的C#版QQ农场(图形图像,文件和流,多线程,Web服务) 课程链接:http://www.dwz.cn/wkkAv 咨询QQ2110053820 课程讲师:蝈蝈 课程分类:.Net 适合人群:初级 课时数量:35课时 更新程度:完毕 用到技术:文本编辑器的实现.图形图像编程.多线程编程.文件和流 涉及项目:QQ农场 课程简介: 模拟QQ农场是以农场为背景的模拟经营类游戏,前身为"五分钟"团队开 发的开心农场,后面则嵌入在Q间和QQ校友(腾讯朋友)平台中的应用程序 游戏.游戏

HTML+CSS项目开发总结

好几天没更新博客了,刚实战完一个HTML+CSS的简单项目.经过几天的摸索,发现收益良多.之前只是单纯得写demo,看知识点,没有亲自实战项目.但实战过后才会了解,如何才能更好地提升自己的技术.针对这次项目开发,我总结了以下内容: 一.技术总结 1.公共样式的设定 在开始项目之前,我们可以先大体了解一下项目中每个页面的内容,比如字体样式,段落结构,文字大小等.我们可以针对这些内容来设定一个固定的样式文件.在开发中    就可以直接引入此文件,而无需再重复敲CSS代码. /*基本样式*/ * {

百度地图api-在中国范围内的多行政区选择与反选(增加屏蔽层)

这两天在实验百度地图的api,老实说做的还蛮好使的,不过我这需要的行政区选择和反选功能还是不怎么好实现,实践了一下总算找到了一个比较好一点的解决办法.行政区选择其实没啥好说的,就是直接拿出行政区名字来调用BMap.Boundary().get(districtName,callback)就可以了反选尤其是不确定多少个行政区时候的反选才是个麻烦.我自己选择的方式是找出咱国家四个角端点的经纬度,然后以此画一个闭合折线,再连接选中的区域,再连接四角端点,依次类推优点是省事&节省资源(我懒_(:з」∠)

弹框CSS、JS

非本人原创,此为本人导师代码,在此整理分析. 1.遮蔽层,弹框弹出时,页面变灰. CSS部分 .overlay{display:none;position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;background-color:hsla(0, 0%, 0%, .7);} 2.定时提示小弹框,页面垂直居中显示 CSS部分 /*toast提示*/ .toast{position:fixed;top:50%;left:50%;z-