-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
427737f
commit 16b2c51
Showing
13 changed files
with
268 additions
and
287 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
Natsurainko.FluentLauncher/ViewModels/Common/SkinManageViewModel.cs
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
Natsurainko.FluentLauncher/ViewModels/Common/UploadSkinDialogViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.Win32; | ||
using Natsurainko.FluentLauncher.Services.Storage; | ||
using Natsurainko.FluentLauncher.Utils; | ||
using Nrk.FluentCore.Authentication; | ||
using Nrk.FluentCore.Utils; | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
#nullable disable | ||
namespace Natsurainko.FluentLauncher.ViewModels.Common; | ||
|
||
public partial class UploadSkinDialogViewModel : ObservableObject | ||
{ | ||
private readonly Account _account; | ||
private ContentDialog _dialog; | ||
|
||
[ObservableProperty] | ||
[NotifyCanExecuteChangedFor(nameof(UploadCommand))] | ||
private string filePath; | ||
|
||
[ObservableProperty] | ||
private bool isSlimModel; | ||
|
||
public UploadSkinDialogViewModel(Account account) | ||
{ | ||
_account = account; | ||
} | ||
|
||
[RelayCommand] | ||
public void LoadEvent(object args) | ||
{ | ||
var grid = args.As<Grid, object>().sender; | ||
_dialog = grid.FindName("Dialog") as ContentDialog; | ||
} | ||
|
||
[RelayCommand(CanExecute = nameof(CanUpload))] | ||
public async Task Upload() | ||
{ | ||
try | ||
{ | ||
if (_account is MicrosoftAccount microsoftAccount) | ||
await SkinHelper.UploadSkinAsync(microsoftAccount, IsSlimModel, FilePath); | ||
else if (_account is YggdrasilAccount yggdrasilAccount) | ||
await SkinHelper.UploadSkinAsync(yggdrasilAccount, IsSlimModel, FilePath); | ||
|
||
await App.GetService<CacheSkinService>().CacheSkinOfAccount(_account); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
} | ||
|
||
App.DispatcherQueue.TryEnqueue(_dialog.Hide); | ||
} | ||
|
||
[RelayCommand] | ||
public void BrowserFile() | ||
{ | ||
var openFileDialog = new OpenFileDialog(); | ||
openFileDialog.Multiselect = false; | ||
openFileDialog.Filter = "Png Image File|*.png"; | ||
|
||
if (openFileDialog.ShowDialog().GetValueOrDefault(false)) | ||
FilePath = openFileDialog.FileName; | ||
} | ||
|
||
[RelayCommand] | ||
public void Cancel() => _dialog.Hide(); | ||
|
||
private bool CanUpload => File.Exists(FilePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.