鱼C论坛

 找回密码
 立即注册
查看: 1028|回复: 0

逐帧动画效果

[复制链接]
发表于 2022-11-11 11:01:27 | 显示全部楼层 |阅读模式
30鱼币
本帖最后由 失败且常态 于 2022-11-17 09:10 编辑
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using System.Windows.Threading;

  17. namespace WpfApplication2
  18. {
  19.     /// <summary>
  20.     /// MainWindow.xaml 的交互逻辑
  21.     /// </summary>
  22.     ///
  23.     public partial class MainWindow : Window
  24.     {
  25.         Thread threadAnimation = null;
  26.         public MainWindow()
  27.         {

  28.             InitializeComponent();
  29.         }
  30.         
  31.         private void goAnimation()
  32.         {
  33.             int i = 1;
  34.             while (true)
  35.             {
  36.                 this.Dispatcher.Invoke(() =>
  37.                 {
  38.                     image.Source = new BitmapImage(new Uri("/WpfApplication2;component/images/0" + i + ".png", UriKind.Relative));
  39.                     Thread.Sleep(1000);
  40.                     i = i + 1;
  41.                     if (i > 4)
  42.                         i = 1;
  43.                 });
  44.             }
  45.         }
  46.         private void button_Click(object sender, RoutedEventArgs e)
  47.         {
  48.             threadAnimation.Start();
  49.         }
  50.     }
  51. }
复制代码

请问这是什么问题要怎么解决

55.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-27 12:05

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表