1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 21:26:09 +03:00
ProxySU/ProxySuper.Core/ViewModels/TrojanGoEditorViewModel.cs

64 lines
1.7 KiB
C#
Raw Normal View History

2021-05-16 11:29:37 +03:00
using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
namespace ProxySuper.Core.ViewModels
{
public class TrojanGoEditorViewModel : MvxViewModel<Record, Record>
{
public TrojanGoEditorViewModel(IMvxNavigationService navigationService)
{
NavigationService = navigationService;
}
public IMvxNavigationService NavigationService { get; }
public IMvxCommand SaveCommand => new MvxCommand(Save);
2021-08-19 12:54:23 +03:00
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
2021-05-16 11:29:37 +03:00
public string Id { get; set; }
public Host Host { get; set; }
public TrojanGoSettings Settings { get; set; }
public override void Prepare(Record parameter)
{
var record = Utils.DeepClone(parameter);
Id = record.Id;
Host = record.Host;
Settings = record.TrojanGoSettings;
}
private void Save()
{
NavigationService.Close(this, new Record
{
Id = this.Id,
Host = this.Host,
TrojanGoSettings = Settings,
});
}
2021-08-19 12:54:23 +03:00
private void SaveAndInstall()
{
var record = new Record
{
Id = this.Id,
Host = this.Host,
TrojanGoSettings = Settings,
};
NavigationService.Close(this, record);
NavigationService.Navigate<TrojanGoInstallViewModel, Record>(record);
}
2021-05-16 11:29:37 +03:00
}
}