wpf 窗体翻页效果

点击设置翻页,取消翻回来

1.xaml

  1 "_3D翻页动画.MainWindow"
  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         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6         xmlns:local="clr-namespace:_3D翻页动画"
  7         mc:Ignorable="d"
  8         Topmost="True"
  9         WindowStartupLocation="CenterScreen"
 10         WindowStyle="None"
 11         RenderTransformOrigin="0.5,0.5"
 12         AllowsTransparency="True"  
 13    Background="Transparent"
 14         MouseLeftButtonDown="Window_MouseLeftButtonDown"
 15         Title="MainWindow" Height="330" Width="428">
 16     
 17     
 18         "WindowTransform" >
 19     
 20     
 21         
 48 
 49         "ClosedStoryboard" Storyboard.TargetName="LoginGrid">
 50             "1" To="0" Duration="0:0:2" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
 51             "1" To="0" Duration="0:0:1.5" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
 52             "#00000000" Duration="0" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
 53         
 54         "ClosedBrush" StartPoint="0.5,0" EndPoint="0.5,1">
 55             "#FF000000" Offset="0"/>
 56             "#FF000000" Offset="1"/>
 57             "#FF000000" Offset="1"/>
 58         
 59         
 60         "TransformToMiddle">
 61             "WindowTransform" Storyboard.TargetProperty="ScaleX"  From="1" To="-1" By="1" Duration="0:0:1" />
 62         
 63         
 64         "TransformToMiddle1">
 65             "WindowTransform" Storyboard.TargetProperty="ScaleX"  From="-1" To="1" By="1" Duration="0:0:1" />
 66         
 67 
 68 
 69     
 70     "Black"  CornerRadius="10" >
 71         "LoginGrid" Background="Transparent" >
 72 
 73             
 74             "0.5,1" EndPoint="0.5,0">
 75                 "#00000000" Offset="0"/>
 76                 "#00000000" Offset="1"/>
 77                 "#00000000" Offset="1"/>
 78             
 79         
 80         
 81             "Loaded">
 82                 
 83                     
 84                         
 85                             "1" To="0" Duration="0:0:1.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
 86                             "1" To="0" Duration="0:0:1" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
 87                             "#FF000000" Duration="0" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
 88                         
 89                     
 90                 
 91             
 92         
 93             "Black" BorderThickness="1"  CornerRadius="10" Background="White">
 94 
 95                 "grid1">
 96                     
 97                         "62*"/>
 98                         "103*"/>
 99                     
100                     "Black"  Background="#306aff" CornerRadius="10,10,0,0">
101                         "Transparent">
102                             "Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="5">
103                                 "设置"  FontSize="15"  Foreground="White" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown">
104                                 "关闭" Margin="10,0,0,0" Foreground="White" FontSize="15" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1">
105                             
106                         
107                     
108                     "Black" BorderThickness="1" Background="White" Margin="183,93,183,175" Grid.RowSpan="2"  CornerRadius="30">
109                         "60" Height="60"  Source="Images/黑马.png" >
110                     
111                     "1" Width="280" HorizontalAlignment="Center" VerticalAlignment="Center">
112                         "textBoxName" Height="38"  >
113                             
114                                 
149                             
150                         
151                         "textBoxPassword" Height="38"  >
152                             
153                                 
190                             
191                         
192                         
229                 
230             
231         
232     
233 

2.cs

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using System.Windows;
 7 using System.Windows.Controls;
 8 using System.Windows.Data;
 9 using System.Windows.Documents;
10 using System.Windows.Input;
11 using System.Windows.Media;
12 using System.Windows.Media.Animation;
13 using System.Windows.Media.Imaging;
14 using System.Windows.Media.Media3D;
15 using System.Windows.Navigation;
16 using System.Windows.Shapes;/// 
17 /// 
18 /// 
19 namespace _3D翻页动画
20 {
21     /// 
22     /// MainWindow.xaml 的交互逻辑
23     /// 
24     public partial class MainWindow : Window
25     {
26         System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
27         public MainWindow()
28         {
29             InitializeComponent();
30             myTimer.Tick += new EventHandler(timer1_Tick);
31             myTimer.Enabled = false;
32             myTimer.Interval = 500;
33 
34             //  page1.ColoedButtonClick += new EventHandler(ColoedButtonClick);
35         }
36         /// 
37         /// 计时器
38         /// 
39         /// 
40         /// 
41         private void timer1_Tick(object sender, EventArgs e)
42         {
43             myTimer.Stop();
44             if (grid1.Visibility == Visibility.Visible)
45             {
46                 grid1.Visibility = Visibility.Collapsed;
47                 border2.Visibility = Visibility.Visible;
48             }
49             else
50             {
51                 grid1.Visibility = Visibility.Visible;
52                 border2.Visibility = Visibility.Collapsed;
53             }
54         }    
55         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
56         {
57             //窗体移动
58             if (e.ButtonState == MouseButtonState.Pressed)
59             {
60                 this.DragMove();
61             }
62         }
63         /// 
64         /// 设置按钮
65         /// 
66         /// 
67         /// 
68         private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
69         {
70             Storyboard sbto = this.Resources["TransformToMiddle"] as Storyboard;
71             sbto.Begin(this);
72             myTimer.Start();
73         }
74         /// 
75         /// 关闭窗口
76         /// 
77         /// 
78         /// 
79         private void TextBlock_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
80         {
81             this.IsEnabled = false;
82             LoginGrid.OpacityMask = this.Resources["ClosedBrush"] as LinearGradientBrush;
83             Storyboard std = this.Resources["ClosedStoryboard"] as Storyboard;
84             std.Completed += delegate { this.Close(); };
85             std.Begin();
86         }
87         /// 
88         /// 取消
89         /// 
90         /// 
91         /// 
92         private void Button_Click_1(object sender, RoutedEventArgs e)
93         {
94             Storyboard sbto = this.Resources["TransformToMiddle1"] as Storyboard;
95             sbto.Begin(this);
96             myTimer.Start();
97         }
98     }
99 }
View Code

 

转载于:https://www.cnblogs.com/pu-tao-zi/p/9681457.html

你可能感兴趣的:(wpf 窗体翻页效果)