Skip to content

Commit

Permalink
Preparing Import Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Oct 20, 2023
1 parent 4da2d6c commit f8e5ac1
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 38 deletions.
18 changes: 2 additions & 16 deletions src/Portal/Sucrose.Portal/Views/Controls/DisplayPreferences.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,13 @@
<Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:DisplayPreferences}" />
</ui:ContentDialog.Resources>

<StackPanel x:Name="Panel" HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Vertical" MinWidth="400">
<StackPanel x:Name="Panel" HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Vertical" MinHeight="9999" MinWidth="400">
<Border Background="{DynamicResource ControlFillColorDefaultBrush}" CornerRadius="5" Margin="0 10 0 10" MinHeight="150">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<WrapPanel x:Name="Contents" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" />
</ScrollViewer>
</Border>

<vcontrols:ExpanderCard x:Name="Expander" LeftIconSymbol="DualScreenSpan24" IsExpand="True" Expandable="True">
<vcontrols:ExpanderCard.FooterCard>
<StackPanel>
<RadioButton />
<RadioButton />
<RadioButton />

<ui:NavigationViewItemSeparator Margin="0 10 0 10" />

<ui:TextBlock Margin="0 0 0 10" />

<RadioButton />
</StackPanel>
</vcontrols:ExpanderCard.FooterCard>
</vcontrols:ExpanderCard>
<vcontrols:ExpanderCard x:Name="Expander" LeftIconSymbol="DualScreenSpan24" IsExpand="True" Expandable="True" />
</StackPanel>
</ui:ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 6 additions & 11 deletions src/Portal/Sucrose.Portal/Views/Controls/OtherAbout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<ui:Image
Height="32"
CornerRadius="16"
Expand All @@ -50,8 +49,7 @@
CornerRadius="15"
Appearance="Transparent"
BorderBrush="Transparent"
NavigateUri="https://www.facebook.com/iTaiizor"
Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}">
NavigateUri="https://www.facebook.com/iTaiizor">
<ui:Image
Height="32"
CornerRadius="16"
Expand All @@ -62,8 +60,7 @@
CornerRadius="15"
Appearance="Transparent"
BorderBrush="Transparent"
NavigateUri="https://www.instagram.com/Taiizor"
Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}">
NavigateUri="https://www.instagram.com/Taiizor">
<ui:Image
Height="32"
CornerRadius="16"
Expand All @@ -74,8 +71,7 @@
CornerRadius="15"
Appearance="Transparent"
BorderBrush="Transparent"
NavigateUri="https://www.twitter.com/iTaiizor"
Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}">
NavigateUri="https://www.twitter.com/iTaiizor">
<ui:Image
Height="32"
CornerRadius="16"
Expand All @@ -86,8 +82,7 @@
CornerRadius="15"
Appearance="Transparent"
BorderBrush="Transparent"
NavigateUri="https://www.linkedin.com/in/Taiizor"
Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}">
NavigateUri="https://www.linkedin.com/in/Taiizor">
<ui:Image
Height="32"
CornerRadius="16"
Expand Down Expand Up @@ -128,7 +123,7 @@
TextWrapping="WrapWithOverflow"
Text="{DynamicResource Portal.OtherAbout.Contributors}" />

<WrapPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0 10 0 0" Cursor="">
<WrapPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0 10 0 0">
<ui:HyperlinkButton
Cursor="Hand"
CornerRadius="15"
Expand Down
28 changes: 26 additions & 2 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,31 @@
<Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:ThemeImport}" />
</ui:ContentDialog.Resources>

<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Vertical" MinHeight="250" MinWidth="400">
<TextBlock x:Name="ThemeImportInfo" Text="{DynamicResource Portal.ThemeImport.Info}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<StackPanel x:Name="Panel" HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Vertical" MinHeight="9999" MinWidth="500">
<ui:Card Background="{DynamicResource CardStrokeColorDefaultBrush}">
<Grid>
<TextBlock x:Name="ThemeImportInfo" Text="{DynamicResource Portal.ThemeImport.Info}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
</Grid>
</ui:Card>

<ui:Card x:Name="TypeCard" Background="{DynamicResource CardStrokeColorDefaultBrush}" Margin="0 3 0 0" Visibility="Collapsed">
<Grid VerticalAlignment="Center" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<ui:TextBlock
Grid.Row="0"
TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="WrapWithOverflow"
Foreground="{DynamicResource AccentTextFillColorPrimaryBrush}"
Text="Neden Açıklamaları" />

<WrapPanel x:Name="ThemeImportType" Grid.Row="1" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0 10 0 0" />
</Grid>
</ui:Card>
</StackPanel>
</ui:ContentDialog>
24 changes: 20 additions & 4 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeImport.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<Brush>("SystemFillColorCriticalBrush")
});
});
}

await Task.Delay(10);

Panel.MinHeight = 0;
}

public void Dispose()
Expand Down
10 changes: 7 additions & 3 deletions src/Portal/Sucrose.Portal/Views/Pages/LibraryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public enum CompatibilityType
/// </summary>
Preview,
/// <summary>
/// Seçilen ZIP dosyası şifreli!
/// </summary>
Encrypt,
/// <summary>
/// Seçilen dosya gerçekten ZIP dosyası değil!
/// </summary>
ZipType,
Expand Down
6 changes: 6 additions & 0 deletions src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
19 changes: 19 additions & 0 deletions src/Shared/Sucrose.Shared.Zip/Helper/Zip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Update/Sucrose.Update/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit f8e5ac1

Please sign in to comment.