asysnc mainimgbox
This commit is contained in:
parent
e872682d37
commit
5859db79b7
@ -61,6 +61,7 @@
|
||||
Stretch="UniformToFill" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<TextBlock x:Name="Fuck" Text="v"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<!-- <StackPanel> -->
|
||||
|
@ -1,15 +1,23 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using 山海奇闻录.ViewModels;
|
||||
|
||||
namespace 山海奇闻录.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public double WindowWidth;
|
||||
public double WindowHeight;
|
||||
private const int MainBoxNum = 3;
|
||||
private int CurImgIndex;
|
||||
|
||||
private Task backgroundTask;
|
||||
|
||||
private double WindowWidth;
|
||||
private double WindowHeight;
|
||||
|
||||
public MainView()
|
||||
{
|
||||
@ -55,6 +63,8 @@ public partial class MainView : UserControl
|
||||
InitLunBoTu();
|
||||
|
||||
InitPushWindow();
|
||||
|
||||
StartSwitchMainImageBox();
|
||||
}
|
||||
|
||||
private async void OpenPushWindowHandler(object? sender, RoutedEventArgs e)
|
||||
@ -117,7 +127,36 @@ public partial class MainView : UserControl
|
||||
{
|
||||
await ClosePushWindowExec();
|
||||
}
|
||||
|
||||
|
||||
private void StartSwitchMainImageBox()
|
||||
{
|
||||
backgroundTask = Task.Run(async () => await BackgroundTaskAsync());
|
||||
}
|
||||
|
||||
private async Task BackgroundTaskAsync()
|
||||
{
|
||||
int cnt = 0;
|
||||
while (true)
|
||||
{
|
||||
await Task.Delay(1000); // 每秒执行一次
|
||||
// for (int i = 0; i < CurImgIndex; i++)
|
||||
// {
|
||||
// // 更新 UI
|
||||
// Dispatcher.UIThread.InvokeAsync(() =>
|
||||
// {
|
||||
// this.Fuck.Text = cnt.ToString();
|
||||
// cnt += 1;
|
||||
// if (cnt >= 3)
|
||||
// {
|
||||
// cnt = 0;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//轮播图上一张
|
||||
void MainImageBoxPre()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user