1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-12-01 09:36:06 +03:00
ProxySU/ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2021-08-23 07:00:39 +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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
public class MTProtoGoEditorViewModel : MvxViewModel<Record, Record>
2021-08-23 07:00:39 +03:00
{
public MTProtoGoEditorViewModel(IMvxNavigationService navigationService)
2021-08-23 07:00:39 +03:00
{
NavigationService = navigationService;
}
public IMvxNavigationService NavigationService { get; }
public IMvxCommand SaveCommand => new MvxCommand(Save);
public IMvxCommand SaveAndInstallCommand => new MvxCommand(SaveAndInstall);
public string Id { get; set; }
public Host Host { get; set; }
public MTProtoGoSettings Settings { get; set; }
2021-08-23 07:00:39 +03:00
public override void Prepare(Record parameter)
{
var record = Utils.DeepClone(parameter);
Id = record.Id;
Host = record.Host;
Settings = record.MTProtoGoSettings;
2021-08-23 07:00:39 +03:00
}
private void Save()
{
NavigationService.Close(this, new Record
{
Id = this.Id,
Host = this.Host,
MTProtoGoSettings = Settings,
2021-08-23 07:00:39 +03:00
});
}
private void SaveAndInstall()
{
var record = new Record
{
Id = this.Id,
Host = this.Host,
MTProtoGoSettings = Settings,
2021-08-23 07:00:39 +03:00
};
NavigationService.Close(this, record);
NavigationService.Navigate<MTProtoGoInstallViewModel, Record>(record);
2021-08-23 07:00:39 +03:00
}
}
}