C# 创建像 office 2010 一样的动画闪屏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14645252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating an animated splash screen like office 2010
提问by Saleh Omar
How can I create an animated splash screen like the one in Office 2010 using C#?
如何使用 C# 创建类似于 Office 2010 中的动画启动画面?
采纳答案by The-First-Tiger
Is this question about winforms or wpf?
这是关于winforms还是wpf的问题?
If it's about wpf:
如果是关于 wpf:
An animated splash screen is not more than a wpf window showing while your "Main Window" is loading. You can design this splash window with Expression Blend as explained by wischi.
动画启动画面只不过是在加载“主窗口”时显示的 wpf 窗口。您可以使用 wischi 解释的 Expression Blend 设计此启动窗口。
You can also have a look at this code project.
你也可以看看这个代码项目。
For creating some kind of a loading animation: A Simple WPF Loading Animation
用于创建某种加载动画:A Simple WPF Loading Animation
Just create a window with an animation defined in xaml and show it while your application is loading -> animated splash screen.
只需创建一个带有在 xaml 中定义的动画的窗口,并在您的应用程序加载时显示它 -> 动画闪屏。
In Winforms:
在 Winforms 中:
You may have to override the paint method of a form to create an animation. But it's still showing another window which contains an animation while another window is loading.
您可能必须覆盖表单的绘制方法才能创建动画。但它仍然显示另一个窗口,其中包含一个动画,而另一个窗口正在加载。
回答by Random IT Guy
A detailed guide for a splashscreen is here: eExample splashscreen
启动画面的详细指南在这里: eExample splashscreen
Although the basics is:
虽然基础是:
1) Create a splashscreen, show it, close/dispose it
1)创建一个闪屏,显示它,关闭/处理它
private void SplashForm()
{
SplashForm newSplashForm = new SplashForm();
newSplashForm.ShowDialog();
newSplashForm.Dispose();
}
2) Run the splashscreen on a seperate thread/backgroundworker
2)在单独的线程/后台工作者上运行启动画面
Thread t1 = new Thread(new ThreadStart(SplashForm));
t1.Start();
Thread.Sleep(5000); // 5 seconds
t1.Abort();
Thread.Sleep(1000);
回答by wischi
I recommend using WPFfor modern application design and your splashscreen problem.
Expression Blend is a nice tool for creating animations and xaml designs. But you can also design animations by writing plain xaml as well
我建议将WPF用于现代应用程序设计和您的闪屏问题。
Expression Blend 是用于创建动画和 xaml 设计的好工具。但是您也可以通过编写简单的 xaml 来设计动画
Expression Blend Tutorials
Animation Using Expression Blend: How to create an animation
Animation Using Expression Blend: How to start animations on events
Expression Blend 教程
使用 Expression Blend 的动画:如何创建动画 使用 Expression Blend的动画
:如何在事件上启动动画
MSDN Info
Animation Overview
MSDN 信息
动画概述
Using Winforms it will be much mor compicated. The entire GUI is rendered by the CPU (no GPU support) but u can create a custom usercontrol and overwrite the Paint
event and use GDI for drawing, but this will be much more complicated then using wpf.
使用 Winforms 会更加复杂。整个 GUI 由 CPU 渲染(不支持 GPU),但您可以创建自定义用户控件并覆盖Paint
事件并使用 GDI 进行绘图,但这会比使用 wpf 复杂得多。
回答by Eslam Hamouda
if you want to make a dynamic animated splash screen like Office 2010 , i recommend you to use WPFand never think about WinFormsto make dynamic animation with code !
如果你想制作像Office 2010一样的动态动画闪屏,我建议你使用WPF,不要想着WinForms用代码制作动态动画!
but if you are determined of using WinForms you have to be tricky , and use one of this tricks :
但是,如果您决定使用 WinForms,您就必须很棘手,并使用以下技巧之一:
? put a Flash ActiveX Object , and make your animation with Flash then link them together
? 放置一个 Flash ActiveX 对象,并使用 Flash 制作动画,然后将它们链接在一起
? if you are good with WPFand Silverlightyou can make your animation with Silverlight and view it in a WebBrowser Control , You may also use Flash or HTML5
? 如果您擅长WPF和Silverlight,则可以使用 Silverlight 制作动画并在 WebBrowser Control 中查看,您也可以使用 Flash 或HTML5
回答by Marco Guignard
In Winforms, the simplest way is using a PictureBox with an animated Gif on a splashscreen.
在 Winforms 中,最简单的方法是在闪屏上使用带有动画 Gif 的 PictureBox。
This way allows you to spend more time on your animation than your code.
通过这种方式,您可以在动画上花费比代码更多的时间。