鱼C论坛

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

逐帧动画效果

[复制链接]
发表于 2022-11-11 11:01:27 | 显示全部楼层 |阅读模式
30鱼币
本帖最后由 失败且常态 于 2022-11-17 09:10 编辑
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
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;
using System.Windows.Threading;

namespace WpfApplication2
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    ///
    public partial class MainWindow : Window
    {
        Thread threadAnimation = null;
        public MainWindow()
        {

            InitializeComponent();
        }
        
        private void goAnimation()
        {
            int i = 1;
            while (true)
            {
                this.Dispatcher.Invoke(() =>
                {
                    image.Source = new BitmapImage(new Uri("/WpfApplication2;component/images/0" + i + ".png", UriKind.Relative));
                    Thread.Sleep(1000);
                    i = i + 1;
                    if (i > 4)
                        i = 1;
                });
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            threadAnimation.Start();
        }
    }
}
请问这是什么问题要怎么解决

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-20 16:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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