我正在研究一个项目,我只是想让屏幕闪烁。动画闪烁效果C#
我从来没有编码C#或以前使用过Visual Studio,所以我没有弄清楚我在做什么。
我刚刚敲了一个我试图做的快速javascript版本,你可以在这里看到它。
http://jsfiddle.net/OwenMelbz/73Le7/
我已经附加了VS项目文件http://www.mediafire.com/?6cji3czfsc6f5h3
以下是我在我的xaml.cs文件的那一刻了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
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 WpfApplication3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private static System.Timers.Timer testTimer;
public MainWindow()
{
InitializeComponent();
testTimer = new System.Timers.Timer(5000); // 5 seconds
testTimer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
testTimer.Interval = 5000;
testTimer.Enabled = true;
}
public void OnTimerElapsed(object source, ElapsedEventArgs e)
{
this.Dispatcher.Invoke((Action)(() =>
{
b1.Height = 420;
b2.Height = 420;
}));
this.Dispatcher.Invoke((Action)(() =>
{
b1.Height = 0;
b2.Height = 0;
System.Threading.Thread.Sleep(100);
}));
}
}
}
而且继承人什么我有在MainWindow.xaml
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="1440"
Name="Winda" AllowsTransparency="True" WindowStyle="None"
Opacity="1" Topmost="True" WindowStartupLocation="CenterScreen"
WindowState="Maximized" IsHitTestVisible="False" ShowInTaskbar="False" Background="Transparent">
<Grid>
<Rectangle Fill="Black" HorizontalAlignment="Left" Height="0" Stroke="Black" VerticalAlignment="Top" Width="1440" Stretch="Fill" Name="b1"/>
<Rectangle Fill="Black" HorizontalAlignment="Left" Height="0" Stroke="Black" VerticalAlignment="Bottom" Width="1440" Margin="0" Stretch="Fill" Name="b2"/>
</Grid>
</Window>
从JavaScript的演示,我希望你能看到我想要做的事。所以任何帮助将不胜感激!
谢谢。
你可以看看C#中的图形类来看看这里:http://msdn.microsoft.com/en-us/library/system。 drawing.graphics.aspx – Max 2013-03-20 21:08:03