WPF 实现QQ抖动

//wpf中实现类似于qq的抖动窗效果

//前段页面

<Window x:Class="WpfApplication4.MainWindow"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="MainWindow" Height="350" Width="525">

<Grid>

<Button Content="退出" Height="23" HorizontalAlignment="Left" Margin="248,177,0,0" Name="button1" VerticalAlignment="Top" Width="75" Background="#FF185886" Foreground="White" />

<Button Foreground="White" Content="进入" Height="23" HorizontalAlignment="Left" Margin="156,177,0,0" Name="button2" VerticalAlignment="Top" Width="75" BorderBrush="#FFEFD9D9" Click="button2_Click">

<Button.Background>

<RadialGradientBrush>

<GradientStop Color="Black" Offset="0" /><!--这里实现过渡-->

<GradientStop Color="#FF2D73BA" Offset="1" />

</RadialGradientBrush>

</Button.Background>

</Button>

<TextBlock Height="23" HorizontalAlignment="Left" Margin="101,110,0,0" Name="textBlock1" Text="用户ID:" VerticalAlignment="Top" />

<TextBlock Height="23" HorizontalAlignment="Left" Margin="90,139,0,0" Name="textBlock2" Text="用户密码:" VerticalAlignment="Top" />

<TextBox Height="23" HorizontalAlignment="Left" Margin="156,107,0,0" Name="textBox1" VerticalAlignment="Top" Width="167" />

<PasswordBox Height="23" HorizontalAlignment="Left" Margin="156,139,0,0" Name="passwordBox1" VerticalAlignment="Top" Width="167" />

</Grid>

</Window>

//后台

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

namespace WpfApplication4

{

///<summary>

/// MainWindow.xaml 的交互逻辑

///</summary>

public partial class MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

}

private void button2_Click(object sender, RoutedEventArgs e)

{

int i, j, k; //定义三个变量

for (i = 1; i <= 3; i++) //循环次数

{

for (j = 1; j <= 10; j++)

{

this.Top += 5;

this.Left += 5;

System.Threading.Thread.Sleep(5); //当前线程指定挂起的时间

}

for (k = 1; k <= 10; k++)

{

this.Top -= 5;

this.Left -= 5;

System.Threading.Thread.Sleep(5);

}

}

}

}

}

WPF 实现QQ抖动

上一篇:【vue】项目编译报错 Error: No PostCSS Config found in...


下一篇:python绘图工具matplotlib在linux下安装和使用