diff --git a/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj b/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj index ca4bdf7d5..ea5056915 100644 --- a/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj +++ b/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj @@ -68,6 +68,8 @@ + + diff --git a/src/Live/Sucrose.Live.WebView/Sucrose.Live.WebView.csproj b/src/Live/Sucrose.Live.WebView/Sucrose.Live.WebView.csproj index 53e9c2a8d..b22b14345 100644 --- a/src/Live/Sucrose.Live.WebView/Sucrose.Live.WebView.csproj +++ b/src/Live/Sucrose.Live.WebView/Sucrose.Live.WebView.csproj @@ -68,6 +68,8 @@ + + diff --git a/src/Portal/Sucrose.Portal/Extension/ThemeCreate.cs b/src/Portal/Sucrose.Portal/Extension/ThemeCreate.cs new file mode 100644 index 000000000..12a8f4d80 --- /dev/null +++ b/src/Portal/Sucrose.Portal/Extension/ThemeCreate.cs @@ -0,0 +1,39 @@ +using SMR = Sucrose.Memory.Readonly; +using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; + +namespace Sucrose.Portal.Extension +{ + internal static class ThemeCreate + { + public static string GetAuthor() + { + return Environment.UserName; + } + + public static string GetContact() + { + string Result = string.Empty; + + if (SMR.Randomise.Next(2) == 0) + { + Result = $"{GetAuthor()}@example.com"; + } + else + { + Result = $"https://{GetAuthor()}.com"; + } + + return Result.ToLowerInvariant(); + } + + public static string GetTitle(string Name) + { + return Name; + } + + public static string GetDescription(string Name, SSDEWT Type) + { + return $"{Name} - {Type} Wallpaper"; + } + } +} \ No newline at end of file diff --git a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs index 76aac7546..63c4d02b6 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs @@ -3,6 +3,7 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Imaging; using Wpf.Ui.Controls; using OpenFileDialog = Microsoft.Win32.OpenFileDialog; using SEAT = Skylark.Enum.AssemblyType; @@ -10,6 +11,7 @@ using SHG = Skylark.Helper.Generator; using SMMM = Sucrose.Manager.Manage.Manager; using SMR = Sucrose.Memory.Readonly; +using SPETC = Sucrose.Portal.Extension.ThemeCreate; using SPETL = Sucrose.Portal.Extension.ThumbnailLoader; using SPMI = Sucrose.Portal.Manage.Internal; using SRER = Sucrose.Resources.Extension.Resources; @@ -79,6 +81,9 @@ private void GifCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; GifCard.Visibility = Visibility.Visible; CreateCard.Visibility = Visibility.Collapsed; + + GifAuthor.Text = SPETC.GetAuthor(); + GifContact.Text = SPETC.GetContact(); } private void UrlCreate_Click(object sender, RoutedEventArgs e) @@ -86,6 +91,9 @@ private void UrlCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; UrlCard.Visibility = Visibility.Visible; CreateCard.Visibility = Visibility.Collapsed; + + UrlAuthor.Text = SPETC.GetAuthor(); + UrlContact.Text = SPETC.GetContact(); } private void WebCreate_Click(object sender, RoutedEventArgs e) @@ -93,6 +101,9 @@ private void WebCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; WebCard.Visibility = Visibility.Visible; CreateCard.Visibility = Visibility.Collapsed; + + //WebAuthor.Text = SPETC.GetAuthor(); + //WebContact.Text = SPETC.GetContact(); } private void GifDelete_Click(object sender, RoutedEventArgs e) @@ -136,6 +147,8 @@ private async void GifArea_Drop(object sender, DragEventArgs e) if (Extension is ".gif") { + GifDescription.Text = SPETC.GetDescription(Path.GetFileNameWithoutExtension(Record), SSDEWT.Gif); + GifTitle.Text = SPETC.GetTitle(Path.GetFileNameWithoutExtension(Record)); GifImagine.Source = await Loader.LoadAsync(Record); GifDelete.Visibility = Visibility.Visible; GifIcon.Visibility = Visibility.Collapsed; @@ -165,6 +178,9 @@ private void VideoCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; VideoCard.Visibility = Visibility.Visible; CreateCard.Visibility = Visibility.Collapsed; + + VideoAuthor.Text = SPETC.GetAuthor(); + VideoContact.Text = SPETC.GetContact(); } private void VideoArea_DragLeave(object sender, DragEventArgs e) @@ -217,6 +233,8 @@ private async void VideoArea_Drop(object sender, DragEventArgs e) if (Extension is ".mp4" or ".avi" or ".mov" or ".mkv" or ".ogv" or ".flv" or ".wmv" or ".hevc" or ".webm" or ".mpeg" or ".mpeg1" or ".mpeg2" or ".mpeg4") { + VideoDescription.Text = SPETC.GetDescription(Path.GetFileNameWithoutExtension(Record), SSDEWT.Video); + VideoTitle.Text = SPETC.GetTitle(Path.GetFileNameWithoutExtension(Record)); VideoImagine.Source = await Loader.LoadAsync(Record); VideoDelete.Visibility = Visibility.Visible; VideoIcon.Visibility = Visibility.Collapsed; @@ -234,6 +252,9 @@ private void YouTubeCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; YouTubeCard.Visibility = Visibility.Visible; CreateCard.Visibility = Visibility.Collapsed; + + YouTubeAuthor.Text = SPETC.GetAuthor(); + YouTubeContact.Text = SPETC.GetContact(); } private void ContentDialog_Loaded(object sender, RoutedEventArgs e) @@ -284,6 +305,9 @@ private void ApplicationCreate_Click(object sender, RoutedEventArgs e) IsPrimaryButtonEnabled = true; CreateCard.Visibility = Visibility.Collapsed; ApplicationCard.Visibility = Visibility.Visible; + + //ApplicationAuthor.Text = SPETC.GetAuthor(); + //ApplicationContact.Text = SPETC.GetContact(); } private void ContentDialog_PreviewKeyDown(object sender, KeyEventArgs e) @@ -429,7 +453,20 @@ protected override async void OnButtonClick(ContentDialogButton Button) } else { - await Task.Run(async () => await ExtractResources(Thumbnail, Theme)); + try + { + using FileStream Stream = new(Path.Combine(Theme, Thumbnail), FileMode.Create); + + BitmapEncoder Encoder = new JpegBitmapEncoder(); + + Encoder.Frames.Add(BitmapFrame.Create((BitmapSource)GifImagine.Source)); + + Encoder.Save(Stream); + } + catch + { + await Task.Run(async () => await ExtractResources(Thumbnail, Theme)); + } } if (File.Exists($"{GifPreview.Content}")) @@ -683,7 +720,20 @@ protected override async void OnButtonClick(ContentDialogButton Button) } else { - await Task.Run(async () => await ExtractResources(Thumbnail, Theme)); + try + { + using FileStream Stream = new(Path.Combine(Theme, Thumbnail), FileMode.Create); + + BitmapEncoder Encoder = new JpegBitmapEncoder(); + + Encoder.Frames.Add(BitmapFrame.Create((BitmapSource)VideoImagine.Source)); + + Encoder.Save(Stream); + } + catch + { + await Task.Run(async () => await ExtractResources(Thumbnail, Theme)); + } } if (File.Exists($"{VideoPreview.Content}")) diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs index 10a8e6bd0..8adda852f 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs @@ -47,7 +47,7 @@ public static string GetGifContent(Uri Source) public static string GetGifContent(string Source) { - string Content = @"
Edge DetectInvert ColoursLoop ModeGrayscale
Pixelate Amount
"; + string Content = @"
Edge DetectInvert ColoursLoop ModeGrayscale
Pixelate Amount
"; return Content.Replace("{Source}", Source); }