From de1e33ed189e30b2447ee0a01d57d3777ab22827 Mon Sep 17 00:00:00 2001 From: JasonGrass Date: Sun, 15 Dec 2024 12:17:56 +0800 Subject: [PATCH 1/4] Add configurability for the width of StackSummary in SettingsLayout, as well as configuration for controlling whether StackSummary is displayed based on the width of the SettingsLayout. --- SukiUI/Controls/SettingsLayout.axaml | 4 +-- SukiUI/Controls/SettingsLayout.axaml.cs | 48 +++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/SukiUI/Controls/SettingsLayout.axaml b/SukiUI/Controls/SettingsLayout.axaml index 5e283dbec..1f00af28f 100644 --- a/SukiUI/Controls/SettingsLayout.axaml +++ b/SukiUI/Controls/SettingsLayout.axaml @@ -122,9 +122,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/InternalWindow.axaml.cs b/SukiUI/Controls/Experimental/DesktopEnvironment/InternalWindow.axaml.cs new file mode 100644 index 000000000..8f8ff72a2 --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/InternalWindow.axaml.cs @@ -0,0 +1,193 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; + +namespace SukiUI.Controls.Experimental.DesktopEnvironment +{ + public partial class InternalWindow : UserControl + { + private Point _startPoint; + private Thickness _startMargin; + private bool _isDragging; + private Panel _windowBorder; + private Size _initialSize; + private WindowManager _ParentWM; + private bool _isResizing; + + private bool isVisible = true; + public InternalWindow(WindowManager WM, Control content, string title) + { + InitializeComponent(); + + _ParentWM = WM; + this.Get("TBTitle").Text = title; + _windowBorder = this.FindControl("WindowBorder"); + this.FindControl("WindowContent").Content = content; + + // Gérer les événements pour permettre le déplacement + var titleBar = this.FindControl("PART_TitleBarBackground"); + titleBar.PointerPressed += OnTitleBarPointerPressed; + titleBar.PointerMoved += OnTitleBarPointerMoved; + titleBar.PointerReleased += OnTitleBarPointerReleased; + } + + private void OnTitleBarPointerPressed(object sender, PointerPressedEventArgs e) + { + + _startPoint = e.GetPosition( _ParentWM); + _startMargin = _windowBorder.Margin; + _isDragging = true; + + } + + private void OnTitleBarPointerMoved(object sender, PointerEventArgs e) + { + if (_isDragging) + { + var currentPosition = e.GetPosition( _ParentWM); + + // Calculer le décalage par rapport à la position initiale + var offsetX = currentPosition.X - _startPoint.X; + var offsetY = currentPosition.Y - _startPoint.Y; + + // Appliquer la transformation de déplacement à la fenêtre + _windowBorder.Margin = new Thickness(_startMargin.Left + offsetX, _startMargin.Top + offsetY, 0, 0); + + } + } + + private void OnTitleBarPointerReleased(object sender, PointerReleasedEventArgs e) + { + // Arrête le suivi de la souris + _isDragging = false; + + var parent = _ParentWM; + var currentPosition = e.GetPosition( _ParentWM); + if (parent != null) + { + + // Vérifier la largeur et la hauteur du parent + var parentWidth = parent.Bounds.Width; + var parentHeight = parent.Bounds.Height; + + // Si la position X est à moins de 50 pixels du bord gauche + if (currentPosition.X < 60) + { + // Redimensionner et repositionner la fenêtre pour occuper toute la moitié gauche du parent + _windowBorder.Margin = new Thickness(0, 0, parentWidth / 2, 0); + _windowBorder.Animate(WidthProperty, _windowBorder.Width,parentWidth / 2); + _windowBorder.Animate(HeightProperty, _windowBorder.Height,parentHeight); + + } + // Si la position X est à moins de 50 pixels du bord droit + else if (currentPosition.X + _windowBorder.Width > parentWidth - 60) + { + // Redimensionner et repositionner la fenêtre pour occuper toute la moitié droite du parent + _windowBorder.Margin = new Thickness(parentWidth / 2, 0, 0, 0); + + _windowBorder.Animate(WidthProperty, _windowBorder.Width,parentWidth / 2); + _windowBorder.Animate(HeightProperty, _windowBorder.Height,parentHeight); + } + // Si la position Y est à moins de 50 pixels du bord supérieur + else if (currentPosition.Y < 60) + { + // Redimensionner et repositionner la fenêtre pour occuper tout l'écran + _windowBorder.Margin = new Thickness(0); + + _windowBorder.Animate(WidthProperty, _windowBorder.Width,parentWidth ); + _windowBorder.Animate(HeightProperty, _windowBorder.Height,parentHeight); + } + } + } + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + public event EventHandler Closed; + + private void CloseButton_OnClick(object sender, RoutedEventArgs e) + { + Closed?.Invoke(this, EventArgs.Empty); + } + + private void resizeborder(object? sender, PointerPressedEventArgs e) + { + _startPoint = e.GetPosition(_windowBorder); + _isResizing= true; + _initialSize = new Size(_windowBorder.Width, _windowBorder.Height); + } + + private void rezisebordermove(object? sender, PointerEventArgs e) + { + if (_isResizing) + { + // Obtenir la position actuelle de la souris + var currentPosition = e.GetPosition(_windowBorder); + var deltaX = currentPosition.X - _startPoint.X; + var deltaY = currentPosition.Y - _startPoint.Y; + + // Calculer la nouvelle taille + var newWidth = Math.Max(_initialSize.Width + deltaX, 100); // Limite minimale de taille + var newHeight = Math.Max(_initialSize.Height , 100); + + // Appliquer la nouvelle taille + _windowBorder.Width = newWidth; + _windowBorder.Height = newHeight; + } + } + + private void rezisebordermoveNS(object? sender, PointerEventArgs e) + { + + if (_isResizing) + { + // Obtenir la position actuelle de la souris + var currentPosition = e.GetPosition(_windowBorder); + var deltaX = currentPosition.X - _startPoint.X; + var deltaY = currentPosition.Y - _startPoint.Y; + + // Calculer la nouvelle taille + var newWidth = Math.Max(_initialSize.Width , 100); // Limite minimale de taille + var newHeight = Math.Max(_initialSize.Height + deltaY, 100); + + // Appliquer la nouvelle taille + _windowBorder.Width = newWidth; + _windowBorder.Height = newHeight; + } + } + + private void resizereleased(object? sender, PointerReleasedEventArgs e) + { + _isResizing = false; + } + + public void ChangeVisibility() + { + if (isVisible) + _windowBorder.Animate(OpacityProperty,1,0); + else + _windowBorder.Animate(OpacityProperty,0,1); + + _windowBorder.IsHitTestVisible = !isVisible; + + isVisible = !isVisible; + } + + private void PART_MaximizeButton_OnClick(object sender, RoutedEventArgs e) + { + // Redimensionner et repositionner la fenêtre pour occuper tout l'écran + _windowBorder.Margin = new Thickness(0); + + _windowBorder.Animate(WidthProperty, _windowBorder.Width,_ParentWM.Bounds.Width ); + _windowBorder.Animate(HeightProperty, _windowBorder.Height,_ParentWM.Bounds.Height); + } + + private void PART_MinimizeButton_OnClick(object sender, RoutedEventArgs e) + { + ChangeVisibility(); + } + } +} \ No newline at end of file diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/SDESoftware.cs b/SukiUI/Controls/Experimental/DesktopEnvironment/SDESoftware.cs new file mode 100644 index 000000000..1b4212353 --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/SDESoftware.cs @@ -0,0 +1,41 @@ +using Avalonia.Controls; +using Avalonia.Media; +using SukiUI.Helpers; + +namespace SukiUI.Controls.Experimental.DesktopEnvironment +{ + public class SDESoftware : SukiObservableObject + { + public IImage? Icon { get; set; } + + public string Name { get; set; } + + public Type Content { get; set; } + + + + private InternalWindow instance = null; + + public InternalWindow Instance + { + get => instance; + set + { + SetAndRaise(ref instance, value); + } + } + + public void Click(WindowManager wm) + { + if (Instance == null) + { + Instance = new InternalWindow(wm, (Control)Activator.CreateInstance(Content), Name); + Instance.Closed += (sender, args) => Instance = null; + wm.OpenWindow(Instance); + return; + } + + Instance.ChangeVisibility(); + } + } +} \ No newline at end of file diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml b/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml new file mode 100644 index 000000000..12fb3b011 --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml @@ -0,0 +1,99 @@ + + + + + diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml.cs b/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml.cs new file mode 100644 index 000000000..316e83eb1 --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/SukiDesktopEnvironment.axaml.cs @@ -0,0 +1,69 @@ +using System.Collections.ObjectModel; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using Avalonia.Media; + +namespace SukiUI.Controls.Experimental.DesktopEnvironment +{ + public partial class SukiDesktopEnvironment : UserControl + { + private WindowManager _WM; + + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { + base.OnApplyTemplate(e); + _WM = e.NameScope.Find("WM"); + } + public SukiDesktopEnvironment() + { + InitializeComponent(); + } + + public static readonly StyledProperty DesktopBackgroundImageSourceProperty = + AvaloniaProperty.Register(nameof(DesktopBackgroundImageSource)); + + public IImage? DesktopBackgroundImageSource + { + get => GetValue(DesktopBackgroundImageSourceProperty); + set => SetValue(DesktopBackgroundImageSourceProperty, value); + } + + public static readonly StyledProperty HomeImageSourceProperty = + AvaloniaProperty.Register(nameof(HomeImageSource)); + + public IImage? HomeImageSource + { + get => GetValue(HomeImageSourceProperty); + set => SetValue(HomeImageSourceProperty, value); + } + + private void open(object? sender, RoutedEventArgs e) + { + SDESoftware soft = (SDESoftware)(((Button)sender).Tag); + soft.Click(_WM); + } + + public static readonly StyledProperty> SoftwaresProperty = + AvaloniaProperty.Register>(nameof(Softwares), + defaultValue: new ObservableCollection()); + + public ObservableCollection Softwares + { + get { return GetValue(SoftwaresProperty); } + set { SetValue(SoftwaresProperty, value); } + } + + private void InputElement_OnPointerPressed(object sender, PointerPressedEventArgs e) + { + var ctl = sender as Control; + if (ctl != null) + { + FlyoutBase.ShowAttachedFlyout(ctl); + } + } + } +} \ No newline at end of file diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml b/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml new file mode 100644 index 000000000..29d52c410 --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml @@ -0,0 +1,8 @@ + + + diff --git a/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml.cs b/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml.cs new file mode 100644 index 000000000..0bbf98f8d --- /dev/null +++ b/SukiUI/Controls/Experimental/DesktopEnvironment/WindowManager.axaml.cs @@ -0,0 +1,30 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace SukiUI.Controls.Experimental.DesktopEnvironment +{ + public partial class WindowManager : UserControl + { + private Canvas _canvas; + + public WindowManager() + { + _canvas = new Canvas(); + this.Content = _canvas; + } + + public void OpenWindow(InternalWindow window) + { + + + window.Closed += (s, e) => _canvas.Children.Remove(window); + + _canvas.Children.Add(window); + + // Positionner la fenêtre + Canvas.SetLeft(window, 0); + Canvas.SetTop(window, 0); + } + } +} \ No newline at end of file diff --git a/SukiUI/SukiUI.csproj b/SukiUI/SukiUI.csproj index 9c49c1f67..0db9eee66 100644 --- a/SukiUI/SukiUI.csproj +++ b/SukiUI/SukiUI.csproj @@ -83,6 +83,10 @@ SukiDialog.axaml + + ChatUI.axaml + Code + From 0efb25b1ac71a6d54e8ca9884c8f4cd9a6d04c2a Mon Sep 17 00:00:00 2001 From: Clement Sepulchre Date: Tue, 17 Dec 2024 11:49:07 +0100 Subject: [PATCH 3/4] flat button invert pointerover opacity --- SukiUI/Theme/Button.axaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SukiUI/Theme/Button.axaml b/SukiUI/Theme/Button.axaml index eac164fd0..73df90fb3 100644 --- a/SukiUI/Theme/Button.axaml +++ b/SukiUI/Theme/Button.axaml @@ -290,7 +290,7 @@ From c72f8713df2e4a1d8a91863845cc74d44ce005d6 Mon Sep 17 00:00:00 2001 From: pcortellezzi Date: Tue, 17 Dec 2024 10:18:01 -0300 Subject: [PATCH 4/4] Update HostWindow.axaml fixes kikipoulet/SukiUI#362 --- SukiUI.Dock/HostWindow.axaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/SukiUI.Dock/HostWindow.axaml b/SukiUI.Dock/HostWindow.axaml index e57383297..c8243cd2d 100644 --- a/SukiUI.Dock/HostWindow.axaml +++ b/SukiUI.Dock/HostWindow.axaml @@ -10,7 +10,6 @@ - @@ -18,8 +17,6 @@ - -