兼容win7版应用
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.

113 lines
3.0 KiB

using AIK.Common.Language;
using AIK.Models;
using AIK.Models.Menus;
using AIK.Models.UtilsModels.Step;
using AIK.Service.IService;
using AIK.ViewModels.CommonViewModel;
using AIK.ViewModels.Messages;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Media3D;
using System.Xml.Linq;
namespace AIK.ViewModels.RemoteCopy
{
public partial class RemoteCopyViewModel : ObservableObject
{
[ObservableProperty]
private ObservableCollection<StepItem> steps = new();
private int _currentStepIndex = 0;
public int CurrentStepIndex
{
get => _currentStepIndex;
set
{
if (SetProperty(ref _currentStepIndex, value))
{
UpdateStepActivation();
}
}
}
[ObservableProperty]
private string _tipsMessage;
#region 初始化
public RemoteCopyViewModel()
{
InitializeSteps();
}
private void InitializeSteps()
{
Steps.Clear();
Steps.Add(new StepItem(AiKLanguage.LanguageKey.GetValueOrDefault("Lock"), "\ue628"));
Steps.Add(new StepItem(AiKLanguage.LanguageKey.GetValueOrDefault("Unlock"), "\ue681"));
Steps.Add(new StepItem(AiKLanguage.LanguageKey.GetValueOrDefault("Trunk"), "\ue6ea"));
Steps.Add(new StepItem(AiKLanguage.LanguageKey.GetValueOrDefault("Panic"), "\ue699", true));
UpdateStepActivation();
}
private void UpdateStepActivation()
{
Application.Current.Dispatcher.Invoke(() =>
{
for (int i = 0; i < Steps.Count; i++)
{
Steps[i].IsActive = (i == CurrentStepIndex);
}
UpdateTipMessage();
});
}
private void UpdateTipMessage()
{
string m = Steps[CurrentStepIndex].StepName;
TipsMessage = $"{AiKLanguage.LanguageKey.GetValueOrDefault("PleasePress")}【{m}】{AiKLanguage.LanguageKey.GetValueOrDefault("Button")}";
}
#endregion
#region 页面方法
[RelayCommand]
private void NextStep()
{
if (CurrentStepIndex < Steps.Count - 1)
{
CurrentStepIndex++;
}
}
[RelayCommand]
private void PreviousStep()
{
if (CurrentStepIndex > 0)
{
CurrentStepIndex--;
}
}
[RelayCommand]
private void Reset()
{
CurrentStepIndex = 0;
}
#endregion
}
}