码迷,mamicode.com
首页 > Windows程序 > 详细

WPF遮蔽层的实现

时间:2015-06-30 17:41:39      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

 在一些项目中,难免会有耗时的加载,如果加载时没有提示,给人一种假死的感觉,很不友好,那么现在福利来啦,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>
View Code

后台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     }
View Code

调用的代码

技术分享
1  new CoverForm(() => {耗时的代码 }); }).Show();          
View Code

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

WPF遮蔽层的实现

标签:

原文地址:http://www.cnblogs.com/ztb123/p/4610932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!