csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
using System;
|
|
using ReactiveUI;
|
|
using Avalonia.Animation;
|
|
|
|
namespace RenderDemo.ViewModels
|
|
{
|
|
public class AnimationsPageViewModel : ReactiveObject
|
|
{
|
|
private string _playStateText = "Pause all animations";
|
|
|
|
public AnimationsPageViewModel()
|
|
{
|
|
ToggleGlobalPlayState = ReactiveCommand.Create(()=>TogglePlayState());
|
|
}
|
|
|
|
void TogglePlayState()
|
|
{
|
|
switch (Timing.GetGlobalPlayState())
|
|
{
|
|
case PlayState.Run:
|
|
PlayStateText = "Resume all animations";
|
|
Timing.SetGlobalPlayState(PlayState.Pause);
|
|
break;
|
|
|
|
case PlayState.Pause:
|
|
PlayStateText = "Pause all animations";
|
|
Timing.SetGlobalPlayState(PlayState.Run);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public string PlayStateText
|
|
{
|
|
get { return _playStateText; }
|
|
set { this.RaiseAndSetIfChanged(ref _playStateText, value); }
|
|
}
|
|
|
|
public ReactiveCommand ToggleGlobalPlayState { get; }
|
|
}
|
|
}
|
|
|