From 56cd29429ed796b17dacd87b5b1392d5814c6cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sun, 16 Nov 2025 01:56:10 +0100 Subject: [PATCH] Remove Bindings for maill ist page. --- .../MailItemDisplayInformationControl.xaml.cs | 63 +++++++++++-------- Wino.Mail.WinUI/Views/MailListPage.xaml | 20 +----- Wino.Mail.WinUI/Views/MailListPage.xaml.cs | 5 ++ 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Wino.Mail.WinUI/Controls/MailItemDisplayInformationControl.xaml.cs b/Wino.Mail.WinUI/Controls/MailItemDisplayInformationControl.xaml.cs index 865db642..ef5cda22 100644 --- a/Wino.Mail.WinUI/Controls/MailItemDisplayInformationControl.xaml.cs +++ b/Wino.Mail.WinUI/Controls/MailItemDisplayInformationControl.xaml.cs @@ -3,12 +3,15 @@ using System.Linq; using System.Numerics; using System.Windows.Input; using CommunityToolkit.WinUI; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Wino.Core.Domain.Enums; +using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.MailItem; using Wino.Extensions; using Wino.Mail.ViewModels.Data; +using Wino.Mail.WinUI; namespace Wino.Controls; @@ -30,6 +33,26 @@ public sealed partial class MailItemDisplayInformationControl : UserControl [GeneratedDependencyProperty(DefaultValue = true)] public partial bool IsSubjectVisible { get; set; } + [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] + public partial MailOperation LeftHoverAction { get; set; } + + [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] + public partial MailOperation CenterHoverAction { get; set; } + + [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] + public partial MailOperation RightHoverAction { get; set; } + + [GeneratedDependencyProperty(DefaultValue = true)] + public partial bool IsHoverActionsEnabled { get; set; } + + public event EventHandler? HoverActionExecuted; + + [GeneratedDependencyProperty(DefaultValue = false)] + public partial bool Prefer24HourTimeFormat { get; set; } + + [GeneratedDependencyProperty] + public partial IMailListItem? ActionItem { get; set; } + #region Display Properties [GeneratedDependencyProperty] @@ -62,29 +85,6 @@ public sealed partial class MailItemDisplayInformationControl : UserControl [GeneratedDependencyProperty] public partial string? Base64ContactPicture { get; set; } - #endregion - - [GeneratedDependencyProperty] - public partial WinoExpander? ConnectedExpander { get; set; } - - [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] - public partial MailOperation LeftHoverAction { get; set; } - - [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] - public partial MailOperation CenterHoverAction { get; set; } - - [GeneratedDependencyProperty(DefaultValue = MailOperation.None)] - public partial MailOperation RightHoverAction { get; set; } - - [GeneratedDependencyProperty] - public partial ICommand? HoverActionExecutedCommand { get; set; } - - [GeneratedDependencyProperty(DefaultValue = true)] - public partial bool IsHoverActionsEnabled { get; set; } - - [GeneratedDependencyProperty(DefaultValue = false)] - public partial bool Prefer24HourTimeFormat { get; set; } - [GeneratedDependencyProperty(DefaultValue = false)] public partial bool IsThreadExpanderVisible { get; set; } @@ -94,13 +94,24 @@ public sealed partial class MailItemDisplayInformationControl : UserControl [GeneratedDependencyProperty(DefaultValue = false)] public partial bool IsThumbnailUpdated { get; set; } - [GeneratedDependencyProperty] - public partial IMailListItem? ActionItem { get; set; } + #endregion public MailItemDisplayInformationControl() { InitializeComponent(); + // Initialize properties from IPreferencesService for AOT compatibility + var preferencesService = App.Current.Services.GetRequiredService(); + + DisplayMode = preferencesService.MailItemDisplayMode; + ShowPreviewText = preferencesService.IsShowPreviewEnabled; + IsAvatarVisible = preferencesService.IsShowSenderPicturesEnabled; + IsHoverActionsEnabled = preferencesService.IsHoverActionsEnabled; + Prefer24HourTimeFormat = preferencesService.Prefer24HourTimeFormat; + LeftHoverAction = preferencesService.LeftHoverAction; + CenterHoverAction = preferencesService.CenterHoverAction; + RightHoverAction = preferencesService.RightHoverAction; + var compositor = this.Visual().Compositor; var leftBackgroundVisual = compositor.CreateSpriteVisual(); @@ -152,7 +163,7 @@ public sealed partial class MailItemDisplayInformationControl : UserControl if (package == null) return; - HoverActionExecutedCommand?.Execute(package); + HoverActionExecuted?.Invoke(this, package); } private void FirstActionClicked(object sender, RoutedEventArgs e) diff --git a/Wino.Mail.WinUI/Views/MailListPage.xaml b/Wino.Mail.WinUI/Views/MailListPage.xaml index 742be5b0..8f5c6637 100644 --- a/Wino.Mail.WinUI/Views/MailListPage.xaml +++ b/Wino.Mail.WinUI/Views/MailListPage.xaml @@ -56,25 +56,17 @@ x:DefaultBindMode="OneWay" ActionItem="{x:Bind}" Base64ContactPicture="{x:Bind MailCopy.SenderContact.Base64ContactPicture, Mode=OneWay, TargetNullValue=''}" - CenterHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.CenterHoverAction, Mode=OneWay}" ContextRequested="MailItemContextRequested" CreationDate="{x:Bind CreationDate}" - DisplayMode="{Binding ElementName=root, Path=ViewModel.PreferencesService.MailItemDisplayMode, Mode=OneWay}" FromAddress="{x:Bind FromAddress}" FromName="{x:Bind FromName}" HasAttachments="{x:Bind HasAttachments, Mode=OneWay}" - HoverActionExecutedCommand="{Binding ElementName=root, Path=ViewModel.ExecuteHoverActionCommand}" - IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}" + HoverActionExecuted="MailItemDisplayInformationControl_HoverActionExecuted" IsDraft="{x:Bind IsDraft, Mode=OneWay}" IsFlagged="{x:Bind IsFlagged, Mode=OneWay}" - IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}" IsRead="{x:Bind IsRead, Mode=OneWay}" IsThumbnailUpdated="{x:Bind ThumbnailUpdatedEvent, Mode=OneWay}" - LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}" - Prefer24HourTimeFormat="{Binding ElementName=root, Path=ViewModel.PreferencesService.Prefer24HourTimeFormat, Mode=OneWay}" PreviewText="{x:Bind PreviewText, Mode=OneWay}" - RightHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.RightHoverAction, Mode=OneWay}" - ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}" Subject="{x:Bind Subject, Mode=OneWay}" /> @@ -88,27 +80,19 @@ x:DefaultBindMode="OneWay" ActionItem="{x:Bind}" Base64ContactPicture="{x:Bind Base64ContactPicture, Mode=OneWay, TargetNullValue=''}" - CenterHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.CenterHoverAction, Mode=OneWay}" ContextRequested="MailItemContextRequested" CreationDate="{x:Bind CreationDate}" - DisplayMode="{Binding ElementName=root, Path=ViewModel.PreferencesService.MailItemDisplayMode, Mode=OneWay}" FromAddress="{x:Bind FromAddress, Mode=OneWay}" FromName="{x:Bind FromName, Mode=OneWay}" HasAttachments="{x:Bind HasAttachments, Mode=OneWay}" - HoverActionExecutedCommand="{Binding ElementName=root, Path=ViewModel.ExecuteHoverActionCommand}" - IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}" + HoverActionExecuted="MailItemDisplayInformationControl_HoverActionExecuted" IsDraft="{x:Bind IsDraft, Mode=OneWay}" IsFlagged="{x:Bind IsFlagged, Mode=OneWay}" - IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}" IsRead="{x:Bind IsRead, Mode=OneWay}" IsThreadExpanded="{x:Bind IsThreadExpanded, Mode=OneWay}" IsThreadExpanderVisible="True" IsThumbnailUpdated="{x:Bind ThumbnailUpdatedEvent, Mode=OneWay}" - LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}" - Prefer24HourTimeFormat="{Binding ElementName=root, Path=ViewModel.PreferencesService.Prefer24HourTimeFormat, Mode=OneWay}" PreviewText="{x:Bind PreviewText, Mode=OneWay}" - RightHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.RightHoverAction, Mode=OneWay}" - ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}" Subject="{x:Bind Subject, Mode=OneWay}" /> diff --git a/Wino.Mail.WinUI/Views/MailListPage.xaml.cs b/Wino.Mail.WinUI/Views/MailListPage.xaml.cs index 86f50f53..932939e4 100644 --- a/Wino.Mail.WinUI/Views/MailListPage.xaml.cs +++ b/Wino.Mail.WinUI/Views/MailListPage.xaml.cs @@ -103,6 +103,11 @@ public sealed partial class MailListPage : MailListPageAbstract, private void SelectionModeToggleChecked(object sender, RoutedEventArgs e) => ChangeSelectionMode(ListViewSelectionMode.Multiple); + private void MailItemDisplayInformationControl_HoverActionExecuted(object sender, MailOperationPreperationRequest e) + { + ViewModel.ExecuteHoverActionCommand.Execute(e); + } + private void FolderPivotChanged(object sender, SelectionChangedEventArgs e) { foreach (var addedItem in e.AddedItems)