Skip to content

Commit

Permalink
🐛 fixed Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Jun 29, 2024
1 parent 2fd651f commit a6aec5a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static WindowTransparencyLevel ToWindowTransparencyLevel(
WindowBackgroundMaterial.Blur => WindowTransparencyLevel.Blur,
WindowBackgroundMaterial.AcrylicBlur => WindowTransparencyLevel.AcrylicBlur,
WindowBackgroundMaterial.Mica => WindowTransparencyLevel.Mica,
WindowBackgroundMaterial.Transparent => WindowTransparencyLevel.Transparent,
_ => WindowTransparencyLevel.None,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
<ComboBox SelectedItem="{Binding Source={x:Static ms:UISettings.WindowBackgroundMaterial}, Path=Value, Mode=TwoWay}">
<ComboBox.Items>
<spp:WindowBackgroundMaterial>None</spp:WindowBackgroundMaterial>
<spp:WindowBackgroundMaterial>Transparent</spp:WindowBackgroundMaterial>
<spp:WindowBackgroundMaterial>Blur</spp:WindowBackgroundMaterial>
<spp:WindowBackgroundMaterial>AcrylicBlur</spp:WindowBackgroundMaterial>
<spp:WindowBackgroundMaterial>Mica</spp:WindowBackgroundMaterial>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,27 @@ public static bool ReadXml(AuthenticatorDTO authenticatorDto, XmlReader reader,
return filePath;
}

public static async Task<IEnumerable<IFileResult>?> MultipleSelectFolderPath(string? fileExtension = null)
{
var options = new PickOptions();
if (!string.IsNullOrEmpty(fileExtension))
{
AvaloniaFilePickerFileTypeFilter fileTypes = new AvaloniaFilePickerFileTypeFilter.Item[] {
new($"{fileExtension} Files") {
Patterns = new[] { $"*{fileExtension}", },
//MimeTypes
//AppleUniformTypeIdentifiers =
},
};
options.FileTypes = fileTypes;
}
var filePaths = await FilePicker2.PickMultipleAsync(options);

if (!filePaths.Any_Nullable())
Toast.Show(ToastIcon.Warning, Strings.FilePathNotExist);
return filePaths;
}

public static async Task<bool> VerifyMaxValue()
{
var auths = await AuthenticatorHelper.GetAllSourceAuthenticatorAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BD.WTTS.UI.Views.Pages;
using WinAuth;
using static SteamKit2.DepotManifest;
using SJsonSerializer = System.Text.Json.JsonSerializer;

namespace BD.WTTS.UI.ViewModels;
Expand Down Expand Up @@ -68,34 +69,40 @@ static async Task ImportFromSdaFile()
{
try
{
var filePath = await AuthenticatorHelper.SelectFolderPath(FileEx.maFile);
var filePaths = await AuthenticatorHelper.MultipleSelectFolderPath(FileEx.maFile);

if (string.IsNullOrEmpty(filePath)) return;
if (!filePaths.Any_Nullable())
return;

var text = await File.ReadAllTextAsync(filePath);
foreach (var file in filePaths)
{
if (!File.Exists(file.FullPath)) return;
var text = await File.ReadAllTextAsync(file.FullPath);

var sdaFileModel = SJsonSerializer.Deserialize(text, ImportFileModelJsonContext.Default.SdaFileModel);
sdaFileModel.ThrowIsNull();
var steamDataModel = new SdaFileConvertToSteamDataModel(sdaFileModel);
var sdaFileModel = SJsonSerializer.Deserialize(text, ImportFileModelJsonContext.Default.SdaFileModel);
sdaFileModel.ThrowIsNull();
var steamDataModel = new SdaFileConvertToSteamDataModel(sdaFileModel);

SteamAuthenticator steamAuthenticator = new()
{
DeviceId = sdaFileModel.DeviceId,
Serial = sdaFileModel.SerialNumber,
SecretKey = Convert.FromBase64String(sdaFileModel.SharedSecret),
SteamData = SJsonSerializer.Serialize(steamDataModel, ImportFileModelJsonContext.Default.SdaFileConvertToSteamDataModel),
};

var authDto =
new AuthenticatorDTO()
SteamAuthenticator steamAuthenticator = new()
{
Name = $"(Steam){steamAuthenticator.AccountName}",
Value = steamAuthenticator,
Created = DateTimeOffset.Now,
DeviceId = sdaFileModel.DeviceId,
Serial = sdaFileModel.SerialNumber,
SecretKey = Convert.FromBase64String(sdaFileModel.SharedSecret),
SteamData = SJsonSerializer.Serialize(steamDataModel, ImportFileModelJsonContext.Default.SdaFileConvertToSteamDataModel),
};
if (await AuthenticatorHelper.SaveAuthenticator(authDto))
{
Toast.Show(ToastIcon.Success, Strings.ModelContent_ImportSuccessful_.Format(authDto.Name));

var authDto =
new AuthenticatorDTO()
{
Name = $"(Steam){steamAuthenticator.AccountName}",
Value = steamAuthenticator,
Created = DateTimeOffset.Now,
};

if (await AuthenticatorHelper.SaveAuthenticator(authDto))
{
Toast.Show(ToastIcon.Success, Strings.ModelContent_ImportSuccessful_.Format(authDto.Name));
}
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,10 @@ private void RunOrStopAutoCardDropCheck(bool b)
Task.Delay(TimeSpan.FromMinutes(SteamIdleSettings.RefreshBadgesTime.Value), DropCardCancellationTokenSource.Token).Wait();
if (!IsLogin)
{
StopIdleRun();
MainThread2.BeginInvokeOnMainThread(() =>
{
StopIdleRun();
});
break;
}
AutoCardDropCheck().Wait();
Expand Down
2 changes: 2 additions & 0 deletions src/BD.WTTS.Client/Enums/UI/WindowBackgroundMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public enum WindowBackgroundMaterial : byte
{
None = 0,

Transparent = 1,

Blur = 2,

AcrylicBlur = 3,
Expand Down

0 comments on commit a6aec5a

Please sign in to comment.