From f8e5ac1a01993e6520a0d36d2a7c22586bb6ed87 Mon Sep 17 00:00:00 2001
From: Taiizor <41683699+Taiizor@users.noreply.github.com>
Date: Sat, 21 Oct 2023 01:38:03 +0300
Subject: [PATCH] Preparing Import Dialog
---
.../Views/Controls/DisplayPreferences.xaml | 18 ++----------
.../Views/Controls/DisplayPreferences.xaml.cs | 6 +++-
.../Views/Controls/OtherAbout.xaml | 17 ++++-------
.../Views/Controls/ThemeImport.xaml | 28 +++++++++++++++++--
.../Views/Controls/ThemeImport.xaml.cs | 24 +++++++++++++---
.../Views/Pages/LibraryPage.xaml.cs | 10 +++++--
.../Enum/CompatibilityType.cs | 4 +++
.../Sucrose.Shared.Zip/Helper/Archive.cs | 6 ++++
src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs | 19 +++++++++++++
src/Update/Sucrose.Update/App.xaml.cs | 2 +-
10 files changed, 96 insertions(+), 38 deletions(-)
diff --git a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml
index 7d0fdb50c..6f90fad91 100644
--- a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml
+++ b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml
@@ -17,27 +17,13 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs
index 6dd4dd8a3..8aa529526 100644
--- a/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs
+++ b/src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml.cs
@@ -214,7 +214,7 @@ private void DuplicateScreenTypeChecked(SEDST Type)
}
}
- private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
+ private async void ContentDialog_Loaded(object sender, RoutedEventArgs e)
{
Expander.Title.Text = SSRER.GetValue("Portal", "DisplayPreferences", "Expander");
Expander.Description.Text = SSRER.GetValue("Portal", "DisplayPreferences", "Expander", "Description");
@@ -329,6 +329,10 @@ private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
ExpanderContent.Children.Add(ExpanderDuplicateContent);
Expander.FooterCard = ExpanderContent;
+
+ await Task.Delay(10);
+
+ Panel.MinHeight = 0;
}
public void Dispose()
diff --git a/src/Portal/Sucrose.Portal/Views/Controls/OtherAbout.xaml b/src/Portal/Sucrose.Portal/Views/Controls/OtherAbout.xaml
index 0942fc265..23167df31 100644
--- a/src/Portal/Sucrose.Portal/Views/Controls/OtherAbout.xaml
+++ b/src/Portal/Sucrose.Portal/Views/Controls/OtherAbout.xaml
@@ -38,8 +38,7 @@
CornerRadius="15"
Appearance="Transparent"
BorderBrush="Transparent"
- NavigateUri="https://www.youtube.com/@iTaiizor"
- Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}">
+ NavigateUri="https://www.youtube.com/@iTaiizor">
+ NavigateUri="https://www.facebook.com/iTaiizor">
+ NavigateUri="https://www.instagram.com/Taiizor">
+ NavigateUri="https://www.twitter.com/iTaiizor">
+ NavigateUri="https://www.linkedin.com/in/Taiizor">
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml.cs
index 0cd11c93e..5d5fde12c 100644
--- a/src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml.cs
+++ b/src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml.cs
@@ -1,6 +1,8 @@
using System.Windows;
+using System.Windows.Media;
using Wpf.Ui.Controls;
using SPMI = Sucrose.Portal.Manage.Internal;
+using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSDECT = Sucrose.Shared.Dependency.Enum.CompatibilityType;
namespace Sucrose.Portal.Views.Controls
@@ -18,17 +20,31 @@ public ThemeImport() : base(SPMI.ContentDialogService.GetContentPresenter())
InitializeComponent();
}
- private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
+ private async void ContentDialog_Loaded(object sender, RoutedEventArgs e)
{
ThemeImportInfo.Text = Info;
if (Types.Any())
{
- //Legends (hata kodlarının anlamını burada kısaca ya da basitçe açıkla)
+ TypeCard.Visibility = Visibility.Visible;
- //Test: Test açıklaması
- //Test2: Test2 açıklaması
+ Types.ForEach(Type =>
+ {
+ ThemeImportType.Children.Add(new TextBlock
+ {
+ Text = $"{Type}: Bu şu anlama geliyor",
+ TextAlignment = TextAlignment.Left,
+ TextWrapping = TextWrapping.WrapWithOverflow,
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Foreground = SSRER.GetResource("SystemFillColorCriticalBrush")
+ });
+ });
}
+
+ await Task.Delay(10);
+
+ Panel.MinHeight = 0;
}
public void Dispose()
diff --git a/src/Portal/Sucrose.Portal/Views/Pages/LibraryPage.xaml.cs b/src/Portal/Sucrose.Portal/Views/Pages/LibraryPage.xaml.cs
index f4a9c5f95..64d8e2644 100644
--- a/src/Portal/Sucrose.Portal/Views/Pages/LibraryPage.xaml.cs
+++ b/src/Portal/Sucrose.Portal/Views/Pages/LibraryPage.xaml.cs
@@ -185,7 +185,7 @@ private async void GridLibrary_Drop(object sender, DragEventArgs e)
Name = SHG.GenerateString(SMMM.Chars, 25, SMR.Randomise);
} while (File.Exists(Path.Combine(SMMM.LibraryLocation, Name)));
- Result = SSZEZ.Extract(Record, Path.Combine(SMMM.LibraryLocation, Name));
+ Result = await Task.Run(() => SSZEZ.Extract(Record, Path.Combine(SMMM.LibraryLocation, Name)));
if (Result == SSDECT.Pass)
{
@@ -194,12 +194,16 @@ private async void GridLibrary_Drop(object sender, DragEventArgs e)
}
else
{
- Types.Add(Result);
- Messages.Add($"{Path.GetFileNameWithoutExtension(Record)} adlı tema kütüphaneye eklenemedi. Nedeni: {Result}");
+ Messages.Add($"{Path.GetFileNameWithoutExtension(Record)} adlı tema kütüphaneye eklenemedi. Nedeni bilinmiyor.");
}
}
else
{
+ if (!Types.Contains(Result))
+ {
+ Types.Add(Result);
+ }
+
Messages.Add($"{Path.GetFileNameWithoutExtension(Record)} adlı tema kütüphaneye eklenemedi. Nedeni: {Result}");
}
}
diff --git a/src/Shared/Sucrose.Shared.Dependency/Enum/CompatibilityType.cs b/src/Shared/Sucrose.Shared.Dependency/Enum/CompatibilityType.cs
index 219cff916..b1c7c926d 100644
--- a/src/Shared/Sucrose.Shared.Dependency/Enum/CompatibilityType.cs
+++ b/src/Shared/Sucrose.Shared.Dependency/Enum/CompatibilityType.cs
@@ -42,6 +42,10 @@ public enum CompatibilityType
///
Preview,
///
+ /// Seçilen ZIP dosyası şifreli!
+ ///
+ Encrypt,
+ ///
/// Seçilen dosya gerçekten ZIP dosyası değil!
///
ZipType,
diff --git a/src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs b/src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs
index 23cb8e578..2f8d35252 100644
--- a/src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs
+++ b/src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs
@@ -36,6 +36,12 @@ public static SSDECT Check(string Archive)
return SSDECT.ZipType;
}
+ //// Seçilen ZIP dosyası şifreli mi?
+ //if (SSZHZ.EncryptedArchive(Archive))
+ //{
+ // return SSDECT.Encrypt;
+ //}
+
// Arşivde SucroseInfo.json dosyası var mı?
if (!SSZHZ.CheckFile(Archive, SMR.SucroseInfo))
{
diff --git a/src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs b/src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs
index 09c4c6917..21f7d7bda 100644
--- a/src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs
+++ b/src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs
@@ -76,5 +76,24 @@ public static bool CheckArchive(string Archive)
return false;
}
}
+
+ public static bool EncryptedArchive(string Archive)
+ {
+ try
+ {
+ using FileStream Stream = new(Archive, FileMode.Open, FileAccess.Read, FileShare.Read);
+
+ byte[] ArchiveHeader = new byte[4];
+ Stream.Read(ArchiveHeader, 0, 4);
+
+ byte[] ZipHeader = new byte[] { 0x50, 0x4B, 0x03, 0x07 };
+
+ return ArchiveHeader.SequenceEqual(ZipHeader);
+ }
+ catch
+ {
+ return false;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Update/Sucrose.Update/App.xaml.cs b/src/Update/Sucrose.Update/App.xaml.cs
index f34302dc7..883e951f4 100644
--- a/src/Update/Sucrose.Update/App.xaml.cs
+++ b/src/Update/Sucrose.Update/App.xaml.cs
@@ -203,7 +203,7 @@ protected async void Configure()
if (Releases.Any())
{
- SSIIR Release = Release = Releases.FirstOrDefault();
+ SSIIR Release = Releases.FirstOrDefault();
if (SUMM.ChannelType == SSCECT.Release)
{