diff --git a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml index 8f4d92c76..8448f7bea 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml +++ b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml @@ -273,6 +273,68 @@ Appearance="Secondary" BorderBrush="Transparent" Icon="{ui:SymbolIcon ArrowLeft24}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs index 3049fcbaa..67cd148ce 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/ThemeCreate.xaml.cs @@ -40,6 +40,11 @@ private void Back_Click(object sender, RoutedEventArgs e) VideoCard.Visibility = Visibility.Collapsed; YouTubeCard.Visibility = Visibility.Collapsed; ApplicationCard.Visibility = Visibility.Collapsed; + + GifDelete_Click(null, null); + VideoDelete_Click(null, null); + + Dispose(); } private void GifArea_Drop(object sender, DragEventArgs e) @@ -70,6 +75,34 @@ private void GifArea_Drop(object sender, DragEventArgs e) } } + private void VideoArea_Drop(object sender, DragEventArgs e) + { + VideoRectangle.Stroke = SSRER.GetResource("TextFillColorDisabledBrush"); + + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + string[] Files = (string[])e.Data.GetData(DataFormats.FileDrop); + + if (Files.Any()) + { + foreach (string Record in Files) + { + string Extension = Path.GetExtension(Record).ToLowerInvariant(); + + 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") + { + VideoDelete.Visibility = Visibility.Visible; + VideoIcon.Visibility = Visibility.Collapsed; + VideoText.Visibility = Visibility.Collapsed; + VideoRectangle.Stroke = Brushes.SeaGreen; + VideoImagine.Source = new(Record); + break; + } + } + } + } + } + private void GifArea_DragOver(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop) || e.AllowedEffects.HasFlag(DragDropEffects.Copy) == false) @@ -125,6 +158,28 @@ private void GifDelete_Click(object sender, RoutedEventArgs e) GifRectangle.Stroke = SSRER.GetResource("TextFillColorDisabledBrush"); } + private void VideoArea_DragOver(object sender, DragEventArgs e) + { + if (!e.Data.GetDataPresent(DataFormats.FileDrop) || e.AllowedEffects.HasFlag(DragDropEffects.Copy) == false) + { + e.Effects = DragDropEffects.None; + } + else + { + e.Effects = DragDropEffects.Copy; + VideoRectangle.Stroke = Brushes.DodgerBlue; + } + } + + private void VideoDelete_Click(object sender, RoutedEventArgs e) + { + VideoImagine.Source = null; + VideoIcon.Visibility = Visibility.Visible; + VideoText.Visibility = Visibility.Visible; + VideoDelete.Visibility = Visibility.Collapsed; + VideoRectangle.Stroke = SSRER.GetResource("TextFillColorDisabledBrush"); + } + private void VideoCreate_Click(object sender, RoutedEventArgs e) { IsPrimaryButtonEnabled = true; @@ -132,6 +187,18 @@ private void VideoCreate_Click(object sender, RoutedEventArgs e) CreateCard.Visibility = Visibility.Collapsed; } + private void VideoArea_DragLeave(object sender, DragEventArgs e) + { + if (string.IsNullOrEmpty($"{VideoImagine.Source}")) + { + VideoRectangle.Stroke = SSRER.GetResource("TextFillColorDisabledBrush"); + } + else + { + VideoRectangle.Stroke = Brushes.SeaGreen; + } + } + private void ThemePreview_Click(object sender, RoutedEventArgs e) { Button Button = sender as Button; @@ -426,6 +493,100 @@ protected override async void OnButtonClick(ContentDialogButton Button) SSTHI.WriteJson(Path.Combine(Theme, SMR.SucroseInfo), Info); } } + else if (VideoCard.Visibility == Visibility.Visible) + { + Uri Video = VideoImagine.Source; + + if (Video == null || string.IsNullOrEmpty(Video.LocalPath)) + { + VideoRectangle.Stroke = Brushes.Crimson; + return; + } + else if (string.IsNullOrEmpty(VideoTitle.Text)) + { + VideoTitle.Focus(); + return; + } + else if (string.IsNullOrEmpty(VideoDescription.Text)) + { + VideoDescription.Focus(); + return; + } + else if (string.IsNullOrEmpty(VideoAuthor.Text)) + { + VideoAuthor.Focus(); + return; + } + else if (!SSTHV.IsUrl(VideoContact.Text) && !SSTHV.IsMail(VideoContact.Text)) + { + VideoContact.Focus(); + return; + } + else + { + string Name; + string Theme; + string Preview = "Preview.gif"; + string Thumbnail = "Thumbnail.jpg"; + + do + { + SPMI.LibraryService.Theme = SHG.GenerateString(SMMM.Chars, 25, SMR.Randomise); + Theme = Path.Combine(SMMM.LibraryLocation, SPMI.LibraryService.Theme); + } while (File.Exists(Theme)); + + Directory.CreateDirectory(Theme); + + if (File.Exists(Video.LocalPath)) + { + Name = "s_" + Path.GetFileName(Video.LocalPath); + await Task.Run(() => File.Copy(Video.LocalPath, Path.Combine(Theme, Name), true)); + } + else + { + VideoRectangle.Stroke = Brushes.Crimson; + return; + } + + if (File.Exists($"{VideoThumbnail.Content}")) + { + string Source = $"{VideoThumbnail.Content}"; + Thumbnail = "t_" + Path.GetFileName(Source); + await Task.Run(() => File.Copy(Source, Path.Combine(Theme, Thumbnail), true)); + } + else + { + await Task.Run(async () => await ExtractResources(Thumbnail, Theme)); + } + + if (File.Exists($"{VideoPreview.Content}")) + { + string Source = $"{VideoPreview.Content}"; + Preview = "p_" + Path.GetFileName(Source); + await Task.Run(() => File.Copy(Source, Path.Combine(Theme, Preview), true)); + } + else + { + await Task.Run(async () => await ExtractResources(Preview, Theme)); + } + + SSTHI Info = new() + { + Source = Name, + Preview = Preview, + Type = SSDEWT.Video, + Thumbnail = Thumbnail, + Title = VideoTitle.Text, + AppVersion = SSCHV.Get(), + Version = new(1, 0, 0, 0), + Author = VideoAuthor.Text, + Contact = VideoContact.Text, + Description = VideoDescription.Text + }; + + SSTHI.WriteJson(Path.Combine(Theme, SMR.SucroseInfo), Info); + } + } else if (YouTubeCard.Visibility == Visibility.Visible) { if (!SSTHV.IsYouTubeAll(YouTubeUrl.Text)) diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.DE.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.DE.xaml index 8c8fa204d..3b02cdad2 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.DE.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.DE.xaml @@ -46,7 +46,8 @@ Rückgängig Ziehen und Ablegen Sie Ihre Gif-Datei hier - + Ziehen und Ablegen Sie Ihre Videodatei hier + Deckbild Auswählen Bilddateien (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.EN.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.EN.xaml index e2f5f705f..50633a353 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.EN.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.EN.xaml @@ -46,6 +46,7 @@ Undo Drag and drop your gif file here + Drag and drop your video file here Select Cover Image Image Files (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.ES.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.ES.xaml index 262946967..63615beb9 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.ES.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.ES.xaml @@ -46,6 +46,7 @@ Deshacer Arrastra y suelta tu archivo gif aquí + Arrastre y suelte su archivo de video aquí Selecciona Imagen de Portada Archivos de Imagen (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.FR.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.FR.xaml index be3d7e0f9..a97f0a317 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.FR.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.FR.xaml @@ -45,7 +45,8 @@ Annuler - Glissez-déposez votre fichier gif ici + Faites glisser et déposez votre fichier gif ici + Faites glisser et déposez votre fichier vidéo ici Sélectionner une Image de Couverture Fichiers Image (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.PL.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.PL.xaml index f4a5c2740..a73eb5dff 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.PL.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.PL.xaml @@ -44,8 +44,9 @@ Proszę podać poprawne argumenty aplikacji Cofnij - + Przeciągnij i upuść swój plik gif tutaj + Przeciągnij i upuść swój plik wideo tutaj Wybierz Obraz Okładki Pliki Obrazów (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp diff --git a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.TR.xaml b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.TR.xaml index d5741f6c3..7ba2390ee 100644 --- a/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.TR.xaml +++ b/src/Shared/Sucrose.Shared.Resources/Locales/Portal/Controls/ThemeCreate/Portal.ThemeCreate.TR.xaml @@ -46,6 +46,7 @@ Geri Al Gif dosyanızı buraya sürükleyin ve bırakın + Video dosyanızı buraya sürükleyin ve bırakın Kapak Resmi Seç Resim Dosyaları (*.png;*.jpg;*.jpeg;*.tiff;*.webp)|*.png;*.jpg;*.jpeg;*.tiff;*.webp