mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-03-11 22:15:34 +00:00
Removals and cleanup
This commit is contained in:
parent
829a5561ab
commit
620eba5fcb
7 changed files with 43 additions and 374 deletions
|
|
@ -11142,31 +11142,6 @@
|
|||
"zh_TW": "右搖桿"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "UserProfilesChangeProfileImage",
|
||||
"Translations": {
|
||||
"ar_SA": "تغيير الصورة",
|
||||
"de_DE": "Bild ändern",
|
||||
"el_GR": "Αλλαγή εικόνας",
|
||||
"en_US": "Change Image",
|
||||
"es_ES": "Cambiar imagen",
|
||||
"fr_FR": "Changer l’image",
|
||||
"he_IL": "שנה תמונה",
|
||||
"it_IT": "Cambia immagine",
|
||||
"ja_JP": "画像を変更",
|
||||
"ko_KR": "이미지 변경",
|
||||
"no_NO": "Endre bilde",
|
||||
"pl_PL": "Zmień obraz",
|
||||
"pt_BR": "Mudar imagem",
|
||||
"ru_RU": "Изменить аватар",
|
||||
"sv_SE": "Byt bild",
|
||||
"th_TH": "เปลี่ยนรูปภาพ",
|
||||
"tr_TR": "Resmi değiştir",
|
||||
"uk_UA": "Змінити аватар",
|
||||
"zh_CN": "更换图片",
|
||||
"zh_TW": "變更圖片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "UserProfilesDelete",
|
||||
"Translations": {
|
||||
|
|
@ -11267,31 +11242,6 @@
|
|||
"zh_TW": "選擇設定檔圖像"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "ProfileImageSelectionNote",
|
||||
"Translations": {
|
||||
"ar_SA": "يمكنك استيراد صورة مخصصة أو اختيار صورة رمزية من النظام.",
|
||||
"de_DE": "Du kannst ein eigenes Profilbild importieren oder einen Avatar aus der Firmware wählen.",
|
||||
"el_GR": "Μπορείτε να εισάγετε εικόνα προφίλ ή να επιλέξετε avatar από το Firmware.",
|
||||
"en_US": "You may import a custom profile image or select an avatar from system firmware.",
|
||||
"es_ES": "Puedes importar una imagen personalizada o seleccionar un avatar del firmware.",
|
||||
"fr_FR": "Vous pouvez importer une image ou choisir un avatar depuis le firmware.",
|
||||
"he_IL": "אתם יכולים לייבא תמונה מותאמת או לבחור אווטאר מהמערכת.",
|
||||
"it_IT": "Puoi importare un'immagine personalizzata o selezionare un avatar dal firmware.",
|
||||
"ja_JP": "カスタム画像をインポートまたはファームウェア内のアバターを選択できます。",
|
||||
"ko_KR": "사용자 지정 이미지를 가져오거나 시스템 펌웨어에서 아바타 선택.",
|
||||
"no_NO": "Du kan importere et bilde eller velge en avatar fra system firmware.",
|
||||
"pl_PL": "Możesz zaimportować obraz lub wybrać awatar z firmware'u.",
|
||||
"pt_BR": "Você pode importar uma imagem personalizada ou selecionar um avatar do Firmware.",
|
||||
"ru_RU": "Вы можете импортировать изображение или выбрать аватар из прошивки.",
|
||||
"sv_SE": "Du kan importera en bild eller välja en avatar från firmware.",
|
||||
"th_TH": "คุณสามารถนำเข้ารูปหรือเลือกรูปจากระบบ",
|
||||
"tr_TR": "Özel profil resmi içeri aktarabilir veya sistem avatarı seçebilirsiniz.",
|
||||
"uk_UA": "Ви можете імпортувати зображення або вибрати аватар з мікропрограми.",
|
||||
"zh_CN": "您可以导入自定义头像或从系统固件中选择预设头像。",
|
||||
"zh_TW": "您可以匯入自訂圖片或從系統韌體選擇大頭貼。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "ProfileImageSelectionImportImage",
|
||||
"Translations": {
|
||||
|
|
@ -19070,26 +19020,26 @@
|
|||
{
|
||||
"ID": "LoadSupportedImageFormatDialogTitle",
|
||||
"Translations": {
|
||||
"ar_SA": "اختر تنسيق صورة مدعوم",
|
||||
"de_DE": "Wählen Sie ein unterstütztes Bildformat",
|
||||
"el_GR": "Επιλέξτε μια υποστηριζόμενη μορφή εικόνας",
|
||||
"en_US": "Choose a supported image format",
|
||||
"es_ES": "Elige un formato de imagen compatible",
|
||||
"fr_FR": "Choisissez un format d'image pris en charge",
|
||||
"he_IL": "בחר פורמט תמונה נתמך",
|
||||
"it_IT": "Scegli un formato immagine supportato",
|
||||
"ja_JP": "サポートされている画像フォーマットを選択",
|
||||
"ko_KR": "지원되는 이미지 형식을 선택하세요",
|
||||
"no_NO": "Velg et støttet bildeformat",
|
||||
"pl_PL": "Wybierz obsługiwany format obrazu",
|
||||
"pt_BR": "Escolha um formato de imagem compatível",
|
||||
"ru_RU": "Выберите поддерживаемый формат изображения",
|
||||
"sv_SE": "Välj ett stödjat bildformat",
|
||||
"th_TH": "เลือกฟอร์แมตรูปภาพที่รองรับ",
|
||||
"tr_TR": "Desteklenen bir resim formatı seçin",
|
||||
"uk_UA": "Виберіть підтримуваний формат зображення",
|
||||
"zh_CN": "选择一个支持的图片格式",
|
||||
"zh_TW": "選擇一個支持的圖片格式"
|
||||
"ar_SA": "اختر إما JPG أو JPEG أو PNG أو BMP",
|
||||
"de_DE": "Wählen Sie entweder ein JPG, JPEG, PNG oder BMP",
|
||||
"el_GR": "Επιλέξτε είτε JPG, JPEG, PNG ή BMP",
|
||||
"en_US": "Choose either a JPG, JPEG, PNG, or BMP",
|
||||
"es_ES": "Elige ya sea JPG, JPEG, PNG o BMP",
|
||||
"fr_FR": "Choisissez soit un JPG, JPEG, PNG ou BMP",
|
||||
"he_IL": "בחר את JPG, JPEG, PNG או BMP",
|
||||
"it_IT": "Scegli tra JPG, JPEG, PNG o BMP",
|
||||
"ja_JP": "JPG、JPEG、PNG、またはBMPのいずれかを選択してください",
|
||||
"ko_KR": "JPG, JPEG, PNG 또는 BMP 중에서 선택하세요",
|
||||
"no_NO": "Velg enten et JPG, JPEG, PNG eller BMP",
|
||||
"pl_PL": "Wybierz JPG, JPEG, PNG lub BMP",
|
||||
"pt_BR": "Escolha JPG, JPEG, PNG ou BMP",
|
||||
"ru_RU": "Выберите либо JPG, JPEG, PNG, или BMP",
|
||||
"sv_SE": "Välj antingen ett JPG, JPEG, PNG eller BMP",
|
||||
"th_TH": "เลือก JPG, JPEG, PNG หรือ BMP",
|
||||
"tr_TR": "JPG, JPEG, PNG veya BMP seçin",
|
||||
"uk_UA": "Виберіть або JPG, JPEG, PNG, або BMP",
|
||||
"zh_CN": "选择 JPG、JPEG、PNG 或 BMP",
|
||||
"zh_TW": "選擇 JPG、JPEG、PNG 或 BMP"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -20842,31 +20792,6 @@
|
|||
"zh_TW": "暫停"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "UserProfilesSetProfileImage",
|
||||
"Translations": {
|
||||
"ar_SA": "تعيين صورة",
|
||||
"de_DE": "Bild festlegen",
|
||||
"el_GR": "Ορισμός Εικόνας",
|
||||
"en_US": "Set Image",
|
||||
"es_ES": "Elegir Imagen",
|
||||
"fr_FR": "Définir l’Image",
|
||||
"he_IL": "הגדר תמונה",
|
||||
"it_IT": "Imposta immagine",
|
||||
"ja_JP": "画像を設定",
|
||||
"ko_KR": "이미지 설정",
|
||||
"no_NO": "Angi bilde",
|
||||
"pl_PL": "Ustaw obraz",
|
||||
"pt_BR": "Definir Imagem",
|
||||
"ru_RU": "Установить аватар",
|
||||
"sv_SE": "Välj bild",
|
||||
"th_TH": "ตั้งค่ารูปภาพ",
|
||||
"tr_TR": "Resim Ayarla",
|
||||
"uk_UA": "Встановити аватар",
|
||||
"zh_CN": "设置图片",
|
||||
"zh_TW": "設定圖片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "UserProfileEmptyNameError",
|
||||
"Translations": {
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
public partial class UserProfileImageSelectorViewModel : BaseModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
public partial bool FirmwareFound { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -45,13 +45,14 @@
|
|||
VerticalAlignment="Stretch"
|
||||
Orientation="Vertical">
|
||||
<Border
|
||||
Name="ImageBox"
|
||||
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||
BorderThickness="1">
|
||||
<Panel>
|
||||
<ui:SymbolIcon
|
||||
FontSize="70"
|
||||
Width="115"
|
||||
Height="115"
|
||||
Width="120"
|
||||
Height="120"
|
||||
Margin="0"
|
||||
Foreground="{DynamicResource AppListHoverBackgroundColor}"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
|
@ -59,28 +60,29 @@
|
|||
Symbol="Camera" />
|
||||
<Image
|
||||
Name="ProfileImage"
|
||||
Width="115"
|
||||
Height="115"
|
||||
Width="120"
|
||||
Height="120"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Top"
|
||||
Source="{Binding Image, Converter={x:Static helpers:BitmapArrayValueConverter.Instance}}" />
|
||||
<Border
|
||||
Margin="2"
|
||||
Height="24"
|
||||
Width="24"
|
||||
CornerRadius="12"
|
||||
Height="27"
|
||||
Width="27"
|
||||
CornerRadius="17"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource ThemeContentBackgroundColor}">
|
||||
<Button
|
||||
MaxHeight="24"
|
||||
Name="ProfileImageButton"
|
||||
MaxWidth="24"
|
||||
MinHeight="24"
|
||||
MinWidth="24"
|
||||
CornerRadius="12"
|
||||
MaxHeight="27"
|
||||
MaxWidth="27"
|
||||
MinHeight="27"
|
||||
MinWidth="27"
|
||||
CornerRadius="17"
|
||||
Padding="0">
|
||||
<ui:SymbolIcon Symbol="Edit" />
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="Bottom">
|
||||
<MenuItem
|
||||
|
|
@ -93,7 +95,6 @@
|
|||
Click="SelectFirmwareImage_OnClick" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
<ui:SymbolIcon Symbol="Edit" />
|
||||
</Button>
|
||||
</Border>
|
||||
</Panel>
|
||||
|
|
@ -127,16 +128,6 @@
|
|||
Click="DeleteButton_Click">
|
||||
<TextBlock Text="{ext:Locale UserProfilesDelete}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="ChangePictureButton"
|
||||
Click="ChangePictureButton_Click">
|
||||
<TextBlock Text="{ext:Locale UserProfilesChangeProfileImage}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="AddPictureButton"
|
||||
Click="ChangePictureButton_Click">
|
||||
<TextBlock Text="{ext:Locale UserProfilesSetProfileImage}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="SaveButton"
|
||||
Click="SaveButton_Click">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.VisualTree;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using FluentAvalonia.UI.Navigation;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
|
|
@ -8,13 +11,11 @@ using Ryujinx.Ava.UI.Controls;
|
|||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using SkiaSharp;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Avalonia.VisualTree;
|
||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.User
|
||||
{
|
||||
|
|
@ -61,8 +62,6 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - " +
|
||||
$"{(_isNewUser ? LocaleManager.Instance[LocaleKeys.UserEditorTitleNewUser] : UserEditorTitle)}";
|
||||
|
||||
AddPictureButton.IsVisible = _isNewUser;
|
||||
ChangePictureButton.IsVisible = !_isNewUser;
|
||||
IdLabel.IsVisible = _profile != null;
|
||||
IdText.IsVisible = _profile != null;
|
||||
if (!_isNewUser && IsDeletable)
|
||||
|
|
@ -122,6 +121,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DataValidationErrors.ClearErrors(NameBox);
|
||||
DataValidationErrors.ClearErrors(ImageBox);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ViewModel.Name))
|
||||
{
|
||||
|
|
@ -132,7 +132,8 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
|
||||
if (ViewModel.Image == null)
|
||||
{
|
||||
_parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, ViewModel));
|
||||
DataValidationErrors.SetError(ImageBox, new DataValidationException(LocaleManager.Instance[LocaleKeys.UserProfileEmptyNameError]));
|
||||
ImageBox.BorderBrush = Brushes.Red;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -157,19 +158,6 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
_parent?.GoBack();
|
||||
}
|
||||
|
||||
public void SelectProfileImage()
|
||||
{
|
||||
_parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, ViewModel));
|
||||
}
|
||||
|
||||
private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_profile != null || _isNewUser)
|
||||
{
|
||||
SelectProfileImage();
|
||||
}
|
||||
}
|
||||
|
||||
private async void SelectFirmwareImage_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModel.FirmwareFound)
|
||||
|
|
@ -180,7 +168,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
|
||||
private async void Import_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
var result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.LoadSupportedImageFormatDialogTitle],
|
||||
AllowMultiple = false,
|
||||
|
|
@ -192,30 +180,6 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
AppleUniformTypeIdentifiers = ["public.jpeg", "public.png", "com.microsoft.bmp"],
|
||||
MimeTypes = ["image/jpeg", "image/png", "image/bmp"],
|
||||
},
|
||||
new("JPG")
|
||||
{
|
||||
Patterns = ["*.jpg"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg"],
|
||||
MimeTypes = ["image/jpeg"],
|
||||
},
|
||||
new("JPEG")
|
||||
{
|
||||
Patterns = ["*.jpeg"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg"],
|
||||
MimeTypes = ["image/jpeg"],
|
||||
},
|
||||
new("PNG")
|
||||
{
|
||||
Patterns = ["*.png"],
|
||||
AppleUniformTypeIdentifiers = ["public.png"],
|
||||
MimeTypes = ["image/png"],
|
||||
},
|
||||
new("BMP")
|
||||
{
|
||||
Patterns = ["*.bmp"],
|
||||
AppleUniformTypeIdentifiers = ["com.microsoft.bmp"],
|
||||
MimeTypes = ["image/bmp"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
{
|
||||
private NavigationDialogHost _parent;
|
||||
private TempProfile _profile;
|
||||
private ContentManager _contentManager;
|
||||
|
||||
|
||||
public UserFirmwareAvatarSelectorView(ContentManager contentManager)
|
||||
{
|
||||
ContentManager = contentManager;
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:ext="clr-namespace:Ryujinx.Ava.Common.Markup"
|
||||
xmlns:viewModles="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||
Focusable="True"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Ryujinx.Ava.UI.Views.User.UserProfileImageSelectorView"
|
||||
x:DataType="viewModles:UserProfileImageSelectorViewModel"
|
||||
Width="500"
|
||||
d:DesignWidth="500">
|
||||
<Design.DataContext>
|
||||
<viewModles:UserProfileImageSelectorViewModel />
|
||||
</Design.DataContext>
|
||||
<Grid Margin="10"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center" RowDefinitions="Auto,70,Auto">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"
|
||||
TextAlignment="Start"
|
||||
Text="{ext:Locale ProfileImageSelectionNote}" />
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
Spacing="10"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Width="50"
|
||||
MinWidth="50"
|
||||
Click="GoBack">
|
||||
<ui:SymbolIcon Symbol="Back" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
Spacing="10"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Name="Import"
|
||||
Click="Import_OnClick">
|
||||
<TextBlock Text="{ext:Locale ProfileImageSelectionImportImage}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="SelectFirmwareImage"
|
||||
IsEnabled="{Binding FirmwareFound}"
|
||||
Click="SelectFirmwareImage_OnClick">
|
||||
<TextBlock Text="{ext:Locale ProfileImageSelectionSelectAvatar}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.VisualTree;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using FluentAvalonia.UI.Navigation;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Controls;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using SkiaSharp;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.User
|
||||
{
|
||||
public partial class UserProfileImageSelectorView : RyujinxControl<UserProfileImageSelectorViewModel>
|
||||
{
|
||||
private ContentManager _contentManager;
|
||||
private NavigationDialogHost _parent;
|
||||
private TempProfile _profile;
|
||||
|
||||
public UserProfileImageSelectorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||
{
|
||||
NavigatedTo(e);
|
||||
}, RoutingStrategies.Direct);
|
||||
}
|
||||
|
||||
private void NavigatedTo(NavigationEventArgs arg)
|
||||
{
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
switch (arg.NavigationMode)
|
||||
{
|
||||
case NavigationMode.New:
|
||||
(_parent, _profile) = ((NavigationDialogHost, TempProfile))arg.Parameter;
|
||||
_contentManager = _parent.ContentManager;
|
||||
|
||||
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {LocaleManager.Instance[LocaleKeys.ProfileImageSelectionHeader]}";
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
DataContext = ViewModel = new UserProfileImageSelectorViewModel();
|
||||
ViewModel.FirmwareFound = _contentManager.GetCurrentFirmwareVersion() != null;
|
||||
}
|
||||
|
||||
break;
|
||||
case NavigationMode.Back:
|
||||
if (_profile.Image != null)
|
||||
{
|
||||
_parent.GoBack();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Import_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IReadOnlyList<IStorageFile> result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.LoadSupportedImageFormatDialogTitle],
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
|
||||
{
|
||||
Patterns = ["*.jpg", "*.jpeg", "*.png", "*.bmp"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg", "public.png", "com.microsoft.bmp"],
|
||||
MimeTypes = ["image/jpeg", "image/png", "image/bmp"],
|
||||
},
|
||||
new("JPG")
|
||||
{
|
||||
Patterns = ["*.jpg"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg"],
|
||||
MimeTypes = ["image/jpeg"],
|
||||
},
|
||||
new("JPEG")
|
||||
{
|
||||
Patterns = ["*.jpeg"],
|
||||
AppleUniformTypeIdentifiers = ["public.jpeg"],
|
||||
MimeTypes = ["image/jpeg"],
|
||||
},
|
||||
new("PNG")
|
||||
{
|
||||
Patterns = ["*.png"],
|
||||
AppleUniformTypeIdentifiers = ["public.png"],
|
||||
MimeTypes = ["image/png"],
|
||||
},
|
||||
new("BMP")
|
||||
{
|
||||
Patterns = ["*.bmp"],
|
||||
AppleUniformTypeIdentifiers = ["com.microsoft.bmp"],
|
||||
MimeTypes = ["image/bmp"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
_profile.Image = ProcessProfileImage(File.ReadAllBytes(result[0].Path.LocalPath));
|
||||
_parent.GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
private void GoBack(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_parent.GoBack();
|
||||
}
|
||||
|
||||
private void SelectFirmwareImage_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModel.FirmwareFound)
|
||||
{
|
||||
_parent.Navigate(typeof(UserFirmwareAvatarSelectorView), (_parent, _profile));
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] ProcessProfileImage(byte[] buffer)
|
||||
{
|
||||
using SKBitmap bitmap = SKBitmap.Decode(buffer);
|
||||
|
||||
SKBitmap resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), SKFilterQuality.High);
|
||||
|
||||
using MemoryStream streamJpg = new();
|
||||
|
||||
if (resizedBitmap != null)
|
||||
{
|
||||
using SKImage image = SKImage.FromBitmap(resizedBitmap);
|
||||
using SKData dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100);
|
||||
|
||||
dataJpeg.SaveTo(streamJpg);
|
||||
}
|
||||
|
||||
return streamJpg.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue