Item vm prop changes.

This commit is contained in:
Burak Kaan Köse
2025-10-28 14:43:22 +01:00
parent c461a4daed
commit d02205fba3
11 changed files with 346 additions and 2005 deletions
@@ -0,0 +1,10 @@
namespace Wino.Core.Domain.Enums;
/// <summary>
/// Grouping options for emails
/// </summary>
public enum EmailGroupingType
{
ByFromName,
ByDate
}
File diff suppressed because it is too large Load Diff
@@ -345,7 +345,7 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
UpdateUniqueIdHashes(existingItem, false); UpdateUniqueIdHashes(existingItem, false);
UpdateUniqueIdHashes(new MailItemViewModel(updatedItem), true); UpdateUniqueIdHashes(new MailItemViewModel(updatedItem), true);
await ExecuteUIThread(() => { existingItem.MailCopy = updatedItem; }); await ExecuteUIThread(() => { existingItem.NotifyPropertyChanges(); });
} }
/// <summary> /// <summary>
@@ -548,7 +548,7 @@ public class WinoMailCollection : ObservableRecipient, IRecipient<SelectedItemsC
if (itemContainer.ItemViewModel != null) if (itemContainer.ItemViewModel != null)
{ {
itemContainer.ItemViewModel.MailCopy = updatedMailCopy; itemContainer.ItemViewModel.NotifyPropertyChanges();
} }
UpdateUniqueIdHashes(new MailItemViewModel(updatedMailCopy), true); UpdateUniqueIdHashes(new MailItemViewModel(updatedMailCopy), true);
+1 -2
View File
@@ -559,8 +559,7 @@ public partial class ComposePageViewModel : MailBaseViewModel
{ {
await ExecuteUIThread(() => await ExecuteUIThread(() =>
{ {
CurrentMailDraftItem.MailCopy = updatedMail; CurrentMailDraftItem.NotifyPropertyChanges();
DiscardCommand.NotifyCanExecuteChanged(); DiscardCommand.NotifyCanExecuteChanged();
SendCommand.NotifyCanExecuteChanged(); SendCommand.NotifyCanExecuteChanged();
}); });
+90 -5
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Wino.Core.Domain.Entities.Mail; using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Enums;
namespace Wino.Mail.ViewModels.Data; namespace Wino.Mail.ViewModels.Data;
@@ -10,19 +11,23 @@ namespace Wino.Mail.ViewModels.Data;
/// </summary> /// </summary>
public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient, IMailListItem public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient, IMailListItem
{ {
public DateTime CreationDate => MailCopy.CreationDate; public MailCopy MailCopy { get; } = mailCopy;
[ObservableProperty]
public partial MailCopy MailCopy { get; set; } = mailCopy;
[ObservableProperty] [ObservableProperty]
public partial bool ThumbnailUpdatedEvent { get; set; } = false; public partial bool IsDisplayedInThread { get; set; }
[ObservableProperty] [ObservableProperty]
[NotifyPropertyChangedRecipients] [NotifyPropertyChangedRecipients]
public partial bool IsSelected { get; set; } public partial bool IsSelected { get; set; }
public DateTime CreationDate
{
get => MailCopy.CreationDate;
set => SetProperty(MailCopy.CreationDate, value, MailCopy, (u, n) => u.CreationDate = n);
}
[ObservableProperty] [ObservableProperty]
public partial bool IsDisplayedInThread { get; set; } public partial bool ThumbnailUpdatedEvent { get; set; } = false;
public bool IsFlagged public bool IsFlagged
{ {
@@ -90,6 +95,86 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableRecipient,
set => SetProperty(MailCopy.HasAttachments, value, MailCopy, (u, n) => u.HasAttachments = n); set => SetProperty(MailCopy.HasAttachments, value, MailCopy, (u, n) => u.HasAttachments = n);
} }
public MailImportance Importance
{
get => MailCopy.Importance;
set => SetProperty(MailCopy.Importance, value, MailCopy, (u, n) => u.Importance = n);
}
public string ThreadId
{
get => MailCopy.ThreadId;
set => SetProperty(MailCopy.ThreadId, value, MailCopy, (u, n) => u.ThreadId = n);
}
public string MessageId
{
get => MailCopy.MessageId;
set => SetProperty(MailCopy.MessageId, value, MailCopy, (u, n) => u.MessageId = n);
}
public string References
{
get => MailCopy.References;
set => SetProperty(MailCopy.References, value, MailCopy, (u, n) => u.References = n);
}
public string InReplyTo
{
get => MailCopy.InReplyTo;
set => SetProperty(MailCopy.InReplyTo, value, MailCopy, (u, n) => u.InReplyTo = n);
}
public Guid FileId
{
get => MailCopy.FileId;
set => SetProperty(MailCopy.FileId, value, MailCopy, (u, n) => u.FileId = n);
}
public Guid FolderId
{
get => MailCopy.FolderId;
set => SetProperty(MailCopy.FolderId, value, MailCopy, (u, n) => u.FolderId = n);
}
public Guid UniqueId
{
get => MailCopy.UniqueId;
set => SetProperty(MailCopy.UniqueId, value, MailCopy, (u, n) => u.UniqueId = n);
}
public string Base64ContactPicture
{
get => MailCopy.SenderContact?.Base64ContactPicture ?? string.Empty;
set => SetProperty(MailCopy.SenderContact.Base64ContactPicture, value, MailCopy, (u, n) => u.SenderContact.Base64ContactPicture = n);
}
public void NotifyPropertyChanges()
{
// Raise on property changes for all observable properties.
OnPropertyChanged(nameof(CreationDate));
OnPropertyChanged(nameof(IsFlagged));
OnPropertyChanged(nameof(FromName));
OnPropertyChanged(nameof(IsFocused));
OnPropertyChanged(nameof(IsRead));
OnPropertyChanged(nameof(IsDraft));
OnPropertyChanged(nameof(DraftId));
OnPropertyChanged(nameof(Id));
OnPropertyChanged(nameof(Subject));
OnPropertyChanged(nameof(PreviewText));
OnPropertyChanged(nameof(FromAddress));
OnPropertyChanged(nameof(HasAttachments));
OnPropertyChanged(nameof(Importance));
OnPropertyChanged(nameof(ThreadId));
OnPropertyChanged(nameof(MessageId));
OnPropertyChanged(nameof(References));
OnPropertyChanged(nameof(InReplyTo));
OnPropertyChanged(nameof(FileId));
OnPropertyChanged(nameof(FolderId));
OnPropertyChanged(nameof(UniqueId));
OnPropertyChanged(nameof(Base64ContactPicture));
}
public IEnumerable<Guid> GetContainingIds() => [MailCopy.UniqueId]; public IEnumerable<Guid> GetContainingIds() => [MailCopy.UniqueId];
public IEnumerable<MailItemViewModel> GetSelectedMailItems() public IEnumerable<MailItemViewModel> GetSelectedMailItems()
@@ -3,18 +3,17 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Wino.Core.Domain.Enums;
namespace Wino.Mail.ViewModels.Data; namespace Wino.Mail.ViewModels.Data;
/// <summary> /// <summary>
/// Thread mail item (multiple IMailItem) view model representation. /// Thread mail item (multiple IMailItem) view model representation.
/// </summary> /// </summary>
public partial class ThreadMailItemViewModel : ObservableRecipient, IDisposable, IMailListItem public partial class ThreadMailItemViewModel : ObservableRecipient, IMailListItem
{ {
private readonly string _threadId; private readonly string _threadId;
private bool _disposed;
[ObservableProperty] [ObservableProperty]
[NotifyPropertyChangedRecipients] [NotifyPropertyChangedRecipients]
[NotifyPropertyChangedFor(nameof(IsSelectedOrExpanded))] [NotifyPropertyChangedFor(nameof(IsSelectedOrExpanded))]
@@ -35,23 +34,106 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IDisposable,
/// <summary> /// <summary>
/// Gets the latest email's subject for display /// Gets the latest email's subject for display
/// </summary> /// </summary>
public string Subject => ThreadEmails public string Subject => latestMailViewModel?.MailCopy?.Subject;
.OrderByDescending(e => e.MailCopy?.CreationDate)
.FirstOrDefault()?.MailCopy?.Subject;
/// <summary> /// <summary>
/// Gets the latest email's sender name for display /// Gets the latest email's sender name for display
/// </summary> /// </summary>
public string FromName => ThreadEmails public string FromName => latestMailViewModel?.MailCopy?.SenderContact.Name;
.OrderByDescending(e => e.MailCopy?.CreationDate)
.FirstOrDefault()?.MailCopy?.SenderContact.Name;
/// <summary> /// <summary>
/// Gets the latest email's creation date for sorting /// Gets the latest email's creation date for sorting
/// </summary> /// </summary>
public DateTime CreationDate => ThreadEmails public DateTime CreationDate => latestMailViewModel?.MailCopy?.CreationDate ?? DateTime.MinValue;
.OrderByDescending(e => e.MailCopy?.CreationDate)
.FirstOrDefault()?.MailCopy?.CreationDate ?? DateTime.MinValue; /// <summary>
/// Gets the latest email's sender address for display
/// </summary>
public string FromAddress => latestMailViewModel?.FromAddress ?? string.Empty;
/// <summary>
/// Gets the preview text from the latest email
/// </summary>
public string PreviewText => latestMailViewModel?.PreviewText ?? string.Empty;
/// <summary>
/// Gets whether any email in this thread has attachments
/// </summary>
public bool HasAttachments => ThreadEmails.Any(e => e.HasAttachments);
/// <summary>
/// Gets whether any email in this thread is flagged
/// </summary>
public bool IsFlagged => ThreadEmails.Any(e => e.IsFlagged);
/// <summary>
/// Gets whether the latest email is focused
/// </summary>
public bool IsFocused => latestMailViewModel?.IsFocused ?? false;
/// <summary>
/// Gets whether all emails in this thread are read
/// </summary>
public bool IsRead => ThreadEmails.All(e => e.IsRead);
/// <summary>
/// Gets whether any email in this thread is a draft
/// </summary>
public bool IsDraft => ThreadEmails.Any(e => e.IsDraft);
/// <summary>
/// Gets the draft ID from the latest email if it's a draft
/// </summary>
public string DraftId => latestMailViewModel?.DraftId ?? string.Empty;
/// <summary>
/// Gets the ID from the latest email
/// </summary>
public string Id => latestMailViewModel?.Id ?? string.Empty;
/// <summary>
/// Gets the importance of the latest email
/// </summary>
public MailImportance Importance => latestMailViewModel?.Importance ?? MailImportance.Normal;
/// <summary>
/// Gets the thread ID from the latest email
/// </summary>
public string ThreadId => latestMailViewModel?.ThreadId ?? _threadId;
/// <summary>
/// Gets the message ID from the latest email
/// </summary>
public string MessageId => latestMailViewModel?.MessageId ?? string.Empty;
/// <summary>
/// Gets the references from the latest email
/// </summary>
public string References => latestMailViewModel?.References ?? string.Empty;
/// <summary>
/// Gets the in-reply-to from the latest email
/// </summary>
public string InReplyTo => latestMailViewModel?.InReplyTo ?? string.Empty;
/// <summary>
/// Gets the file ID from the latest email
/// </summary>
public Guid FileId => latestMailViewModel?.FileId ?? Guid.Empty;
/// <summary>
/// Gets the folder ID from the latest email
/// </summary>
public Guid FolderId => latestMailViewModel?.FolderId ?? Guid.Empty;
/// <summary>
/// Gets the unique ID from the latest email
/// </summary>
public Guid UniqueId => latestMailViewModel?.UniqueId ?? Guid.Empty;
public string Base64ContactPicture => latestMailViewModel?.MailCopy?.SenderContact?.Base64ContactPicture ?? string.Empty;
public bool ThumbnailUpdatedEvent => latestMailViewModel?.ThumbnailUpdatedEvent ?? false;
/// <summary> /// <summary>
/// Gets all emails in this thread (observable) /// Gets all emails in this thread (observable)
@@ -60,42 +142,40 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IDisposable,
[ObservableProperty] [ObservableProperty]
public partial ObservableCollection<MailItemViewModel> ThreadEmails { get; set; } = []; public partial ObservableCollection<MailItemViewModel> ThreadEmails { get; set; } = [];
public MailItemViewModel LatestMailViewModel => ThreadEmails.OrderByDescending(e => e.MailCopy?.CreationDate).FirstOrDefault()!; private MailItemViewModel latestMailViewModel => ThreadEmails.OrderByDescending(e => e.MailCopy?.CreationDate).FirstOrDefault()!;
public ThreadMailItemViewModel(string threadId) public ThreadMailItemViewModel(string threadId)
{ {
_threadId = threadId; _threadId = threadId;
} }
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
ThreadEmails.Clear();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public void NotifyPropertyChanges() public void NotifyPropertyChanges()
{ {
OnPropertyChanged(nameof(Subject)); OnPropertyChanged(nameof(Subject));
OnPropertyChanged(nameof(FromName)); OnPropertyChanged(nameof(FromName));
OnPropertyChanged(nameof(CreationDate)); OnPropertyChanged(nameof(CreationDate));
OnPropertyChanged(nameof(LatestMailViewModel)); OnPropertyChanged(nameof(FromAddress));
OnPropertyChanged(nameof(PreviewText));
OnPropertyChanged(nameof(HasAttachments));
OnPropertyChanged(nameof(IsFlagged));
OnPropertyChanged(nameof(IsFocused));
OnPropertyChanged(nameof(IsRead));
OnPropertyChanged(nameof(IsDraft));
OnPropertyChanged(nameof(DraftId));
OnPropertyChanged(nameof(Id));
OnPropertyChanged(nameof(Importance));
OnPropertyChanged(nameof(ThreadId));
OnPropertyChanged(nameof(MessageId));
OnPropertyChanged(nameof(References));
OnPropertyChanged(nameof(InReplyTo));
OnPropertyChanged(nameof(FileId));
OnPropertyChanged(nameof(FolderId));
OnPropertyChanged(nameof(UniqueId));
OnPropertyChanged(nameof(ThreadEmails)); OnPropertyChanged(nameof(ThreadEmails));
OnPropertyChanged(nameof(EmailCount));
OnPropertyChanged(nameof(Base64ContactPicture));
} }
/// <summary> /// <summary>
/// Adds an email to this thread /// Adds an email to this thread
/// </summary> /// </summary>
@@ -49,7 +49,7 @@
VerticalAlignment="Top" VerticalAlignment="Top"
Canvas.ZIndex="0" Canvas.ZIndex="0"
Fill="{ThemeResource SystemAccentColor}" Fill="{ThemeResource SystemAccentColor}"
Visibility="{x:Bind helpers:XamlHelpers.ReverseBoolToVisibilityConverter(MailItem.IsRead), Mode=OneWay}" /> Visibility="{x:Bind helpers:XamlHelpers.ReverseBoolToVisibilityConverter(IsRead), Mode=OneWay}" />
</Grid> </Grid>
@@ -73,9 +73,9 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="14" FontSize="14"
FromAddress="{x:Bind MailItem.FromAddress, Mode=OneWay}" FromAddress="{x:Bind FromAddress, Mode=OneWay}"
FromName="{x:Bind MailItem.FromName, Mode=OneWay}" FromName="{x:Bind FromName, Mode=OneWay}"
SenderContactPicture="{x:Bind MailItem.SenderContact.Base64ContactPicture}" SenderContactPicture="{x:Bind Base64ContactPicture, Mode=OneWay}"
ThumbnailUpdatedEvent="{x:Bind IsThumbnailUpdated, Mode=OneWay}" ThumbnailUpdatedEvent="{x:Bind IsThumbnailUpdated, Mode=OneWay}"
Visibility="{x:Bind IsAvatarVisible, Mode=OneWay}" /> Visibility="{x:Bind IsAvatarVisible, Mode=OneWay}" />
@@ -104,7 +104,7 @@
<TextBlock <TextBlock
x:Name="DraftTitle" x:Name="DraftTitle"
Margin="0,0,4,0" Margin="0,0,4,0"
x:Load="{x:Bind MailItem.IsDraft, Mode=OneWay}" x:Load="{x:Bind IsDraft, Mode=OneWay}"
Foreground="{StaticResource DeleteBrush}"> Foreground="{StaticResource DeleteBrush}">
<Run Text="[" /><Run Text="{x:Bind domain:Translator.Draft}" /><Run Text="]" /> <Run Text=" " /> <Run Text="[" /><Run Text="{x:Bind domain:Translator.Draft}" /><Run Text="]" /> <Run Text=" " />
@@ -114,17 +114,17 @@
<TextBlock <TextBlock
x:Name="SenderTextFromName" x:Name="SenderTextFromName"
Grid.Column="1" Grid.Column="1"
Text="{x:Bind MailItem.FromName}" Text="{x:Bind FromName}"
TextTrimming="WordEllipsis" TextTrimming="WordEllipsis"
Visibility="{x:Bind helpers:XamlHelpers.StringToVisibilityConverter(MailItem.FromName)}" /> Visibility="{x:Bind helpers:XamlHelpers.StringToVisibilityConverter(FromName)}" />
<!-- Sender --> <!-- Sender -->
<TextBlock <TextBlock
x:Name="SenderTextFromAddress" x:Name="SenderTextFromAddress"
Grid.Column="1" Grid.Column="1"
Text="{x:Bind MailItem.FromAddress}" Text="{x:Bind FromAddress}"
TextTrimming="CharacterEllipsis" TextTrimming="CharacterEllipsis"
Visibility="{x:Bind helpers:XamlHelpers.StringToVisibilityReversedConverter(MailItem.FromName)}" /> Visibility="{x:Bind helpers:XamlHelpers.StringToVisibilityReversedConverter(FromName)}" />
<!-- Hover button --> <!-- Hover button -->
<StackPanel <StackPanel
@@ -194,6 +194,7 @@
x:Name="TitleText" x:Name="TitleText"
Grid.Column="1" Grid.Column="1"
MaxLines="1" MaxLines="1"
Text="{x:Bind Subject, Mode=OneWay}"
TextTrimming="CharacterEllipsis" /> TextTrimming="CharacterEllipsis" />
<TextBlock <TextBlock
@@ -203,7 +204,7 @@
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="11" FontSize="11"
Opacity="0.7" Opacity="0.7"
Text="{x:Bind helpers:XamlHelpers.GetMailItemDisplaySummaryForListing(MailItem.IsDraft, MailItem.CreationDate, Prefer24HourTimeFormat)}" /> Text="{x:Bind helpers:XamlHelpers.GetMailItemDisplaySummaryForListing(IsDraft, CreationDate, Prefer24HourTimeFormat)}" />
</Grid> </Grid>
<!-- Message --> <!-- Message -->
@@ -219,10 +220,10 @@
<Grid x:Name="PreviewTextContainer"> <Grid x:Name="PreviewTextContainer">
<TextBlock <TextBlock
x:Name="PreviewTextblock" x:Name="PreviewTextblock"
x:Load="{x:Bind helpers:XamlHelpers.ShouldDisplayPreview(MailItem.PreviewText), Mode=OneWay}" x:Load="{x:Bind helpers:XamlHelpers.ShouldDisplayPreview(PreviewText), Mode=OneWay}"
MaxLines="1" MaxLines="1"
Opacity="0.7" Opacity="0.7"
Text="{x:Bind MailItem.PreviewText}" Text="{x:Bind PreviewText}"
TextTrimming="CharacterEllipsis" /> TextTrimming="CharacterEllipsis" />
</Grid> </Grid>
@@ -236,12 +237,12 @@
<ContentPresenter <ContentPresenter
x:Name="HasAttachmentContent" x:Name="HasAttachmentContent"
x:Load="{x:Bind MailItem.HasAttachments, Mode=OneWay}" x:Load="{x:Bind HasAttachments, Mode=OneWay}"
ContentTemplate="{StaticResource AttachmentSymbolControlTemplate}" /> ContentTemplate="{StaticResource AttachmentSymbolControlTemplate}" />
<ContentPresenter <ContentPresenter
x:Name="IsFlaggedContent" x:Name="IsFlaggedContent"
x:Load="{x:Bind MailItem.IsFlagged, Mode=OneWay}" x:Load="{x:Bind IsFlagged, Mode=OneWay}"
ContentTemplate="{StaticResource FlaggedSymbolControlTemplate}" /> ContentTemplate="{StaticResource FlaggedSymbolControlTemplate}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
@@ -255,7 +256,7 @@
<VisualStateGroup x:Name="ReadStates"> <VisualStateGroup x:Name="ReadStates">
<VisualState x:Name="Unread"> <VisualState x:Name="Unread">
<VisualState.StateTriggers> <VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind MailItem.IsRead, Converter={StaticResource ReverseBooleanConverter}, Mode=OneWay}" /> <StateTrigger IsActive="{x:Bind IsRead, Converter={StaticResource ReverseBooleanConverter}, Mode=OneWay}" />
</VisualState.StateTriggers> </VisualState.StateTriggers>
<VisualState.Setters> <VisualState.Setters>
@@ -1,13 +1,14 @@
using System.Numerics; using System;
using System.Linq;
using System.Numerics;
using System.Windows.Input; using System.Windows.Input;
using CommunityToolkit.WinUI; using CommunityToolkit.WinUI;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Enums; using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.MailItem; using Wino.Core.Domain.Models.MailItem;
using Wino.Extensions; using Wino.Extensions;
using Wino.Mail.ViewModels.Data;
namespace Wino.Controls; namespace Wino.Controls;
@@ -17,116 +18,88 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
public bool IsRunningHoverAction { get; set; } public bool IsRunningHoverAction { get; set; }
public static readonly DependencyProperty DisplayModeProperty = DependencyProperty.Register(nameof(DisplayMode), typeof(MailListDisplayMode), typeof(MailItemDisplayInformationControl), new PropertyMetadata(MailListDisplayMode.Spacious)); [GeneratedDependencyProperty(DefaultValue = MailListDisplayMode.Spacious)]
public static readonly DependencyProperty ShowPreviewTextProperty = DependencyProperty.Register(nameof(ShowPreviewText), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true)); public partial MailListDisplayMode DisplayMode { get; set; }
public static readonly DependencyProperty IsAvatarVisibleProperty = DependencyProperty.Register(nameof(IsAvatarVisible), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true));
public static readonly DependencyProperty IsSubjectVisibleProperty = DependencyProperty.Register(nameof(IsSubjectVisible), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true));
public static readonly DependencyProperty ConnectedExpanderProperty = DependencyProperty.Register(nameof(ConnectedExpander), typeof(WinoExpander), typeof(MailItemDisplayInformationControl), new PropertyMetadata(null));
public static readonly DependencyProperty LeftHoverActionProperty = DependencyProperty.Register(nameof(LeftHoverAction), typeof(MailOperation), typeof(MailItemDisplayInformationControl), new PropertyMetadata(MailOperation.None));
public static readonly DependencyProperty CenterHoverActionProperty = DependencyProperty.Register(nameof(CenterHoverAction), typeof(MailOperation), typeof(MailItemDisplayInformationControl), new PropertyMetadata(MailOperation.None));
public static readonly DependencyProperty RightHoverActionProperty = DependencyProperty.Register(nameof(RightHoverAction), typeof(MailOperation), typeof(MailItemDisplayInformationControl), new PropertyMetadata(MailOperation.None));
public static readonly DependencyProperty HoverActionExecutedCommandProperty = DependencyProperty.Register(nameof(HoverActionExecutedCommand), typeof(ICommand), typeof(MailItemDisplayInformationControl), new PropertyMetadata(null));
public static readonly DependencyProperty MailItemProperty = DependencyProperty.Register(nameof(MailItem), typeof(MailCopy), typeof(MailItemDisplayInformationControl), new PropertyMetadata(null, new PropertyChangedCallback(OnMailItemChanged)));
public static readonly DependencyProperty IsHoverActionsEnabledProperty = DependencyProperty.Register(nameof(IsHoverActionsEnabled), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(true));
public static readonly DependencyProperty Prefer24HourTimeFormatProperty = DependencyProperty.Register(nameof(Prefer24HourTimeFormat), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
public static readonly DependencyProperty IsThreadExpanderVisibleProperty = DependencyProperty.Register(nameof(IsThreadExpanderVisible), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
public static readonly DependencyProperty IsThreadExpandedProperty = DependencyProperty.Register(nameof(IsThreadExpanded), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
public static readonly DependencyProperty IsThumbnailUpdatedProperty = DependencyProperty.Register(nameof(IsThumbnailUpdated), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false));
public bool IsThumbnailUpdated [GeneratedDependencyProperty(DefaultValue = true)]
{ public partial bool ShowPreviewText { get; set; }
get { return (bool)GetValue(IsThumbnailUpdatedProperty); }
set { SetValue(IsThumbnailUpdatedProperty, value); }
}
public bool IsThreadExpanded [GeneratedDependencyProperty(DefaultValue = true)]
{ public partial bool IsAvatarVisible { get; set; }
get { return (bool)GetValue(IsThreadExpandedProperty); }
set { SetValue(IsThreadExpandedProperty, value); }
}
public bool IsThreadExpanderVisible [GeneratedDependencyProperty(DefaultValue = true)]
{ public partial bool IsSubjectVisible { get; set; }
get { return (bool)GetValue(IsThreadExpanderVisibleProperty); }
set { SetValue(IsThreadExpanderVisibleProperty, value); }
}
public bool Prefer24HourTimeFormat #region Display Properties
{
get { return (bool)GetValue(Prefer24HourTimeFormatProperty); }
set { SetValue(Prefer24HourTimeFormatProperty, value); }
}
public bool IsHoverActionsEnabled [GeneratedDependencyProperty]
{ public partial string? Subject { get; set; }
get { return (bool)GetValue(IsHoverActionsEnabledProperty); }
set { SetValue(IsHoverActionsEnabledProperty, value); }
}
public MailCopy MailItem [GeneratedDependencyProperty]
{ public partial string? FromName { get; set; }
get { return (MailCopy)GetValue(MailItemProperty); }
set { SetValue(MailItemProperty, value); }
}
public ICommand HoverActionExecutedCommand [GeneratedDependencyProperty]
{ public partial string? FromAddress { get; set; }
get { return (ICommand)GetValue(HoverActionExecutedCommandProperty); }
set { SetValue(HoverActionExecutedCommandProperty, value); }
}
public MailOperation LeftHoverAction [GeneratedDependencyProperty]
{ public partial string? PreviewText { get; set; }
get { return (MailOperation)GetValue(LeftHoverActionProperty); }
set { SetValue(LeftHoverActionProperty, value); }
}
public MailOperation CenterHoverAction [GeneratedDependencyProperty]
{ public partial bool IsRead { get; set; }
get { return (MailOperation)GetValue(CenterHoverActionProperty); }
set { SetValue(CenterHoverActionProperty, value); }
}
public MailOperation RightHoverAction [GeneratedDependencyProperty]
{ public partial bool IsDraft { get; set; }
get { return (MailOperation)GetValue(RightHoverActionProperty); }
set { SetValue(RightHoverActionProperty, value); }
}
public WinoExpander ConnectedExpander [GeneratedDependencyProperty]
{ public partial bool HasAttachments { get; set; }
get { return (WinoExpander)GetValue(ConnectedExpanderProperty); }
set { SetValue(ConnectedExpanderProperty, value); }
}
public bool IsSubjectVisible [GeneratedDependencyProperty]
{ public partial bool IsFlagged { get; set; }
get { return (bool)GetValue(IsSubjectVisibleProperty); }
set { SetValue(IsSubjectVisibleProperty, value); }
}
public bool IsAvatarVisible [GeneratedDependencyProperty]
{ public partial DateTime CreationDate { get; set; }
get { return (bool)GetValue(IsAvatarVisibleProperty); }
set { SetValue(IsAvatarVisibleProperty, value); }
}
[GeneratedDependencyProperty]
public partial string? Base64ContactPicture { get; set; }
public bool ShowPreviewText #endregion
{
get { return (bool)GetValue(ShowPreviewTextProperty); }
set { SetValue(ShowPreviewTextProperty, value); }
}
public MailListDisplayMode DisplayMode [GeneratedDependencyProperty]
{ public partial WinoExpander? ConnectedExpander { get; set; }
get { return (MailListDisplayMode)GetValue(DisplayModeProperty); }
set { SetValue(DisplayModeProperty, value); } [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; }
[GeneratedDependencyProperty(DefaultValue = false)]
public partial bool IsThreadExpanded { get; set; }
[GeneratedDependencyProperty(DefaultValue = false)]
public partial bool IsThumbnailUpdated { get; set; }
[GeneratedDependencyProperty]
public partial IMailListItem? ActionItem { get; set; }
public MailItemDisplayInformationControl() public MailItemDisplayInformationControl()
{ {
this.InitializeComponent(); InitializeComponent();
var compositor = this.Visual().Compositor; var compositor = this.Visual().Compositor;
@@ -142,19 +115,9 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2(); RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2();
} }
private static void OnMailItemChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) partial void OnIsFlaggedChanged(bool newValue)
{ {
if (obj is MailItemDisplayInformationControl control)
{
control.UpdateInformation();
}
}
private void UpdateInformation()
{
if (MailItem == null) return;
TitleText.Text = string.IsNullOrWhiteSpace(MailItem.Subject) ? Translator.MailItemNoSubject : MailItem.Subject;
} }
private void ControlPointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e) private void ControlPointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
@@ -179,14 +142,13 @@ public sealed partial class MailItemDisplayInformationControl : UserControl
{ {
IsRunningHoverAction = true; IsRunningHoverAction = true;
MailOperationPreperationRequest package = null; MailOperationPreperationRequest? package = null;
//if (MailItem is MailCopy mailCopy) if (ActionItem is MailItemViewModel mailItemViewModel)
// package = new MailOperationPreperationRequest(operation, mailCopy, toggleExecution: true); package = new MailOperationPreperationRequest(operation, mailItemViewModel.MailCopy, toggleExecution: true);
//else if (MailItem is ThreadMailItemViewModel threadMailItemViewModel)
// package = new MailOperationPreperationRequest(operation, threadMailItemViewModel.GetMailCopies(), toggleExecution: true); else if (ActionItem is ThreadMailItemViewModel threadMailItemViewModel)
//else if (MailItem is ThreadMailItem threadMailItem) package = new MailOperationPreperationRequest(operation, threadMailItemViewModel.ThreadEmails.Select(a => a.MailCopy), toggleExecution: true);
// package = new MailOperationPreperationRequest(operation, threadMailItem.ThreadItems.Cast<MailItemViewModel>().Select(a => a.MailCopy), toggleExecution: true);
if (package == null) return; if (package == null) return;
+25 -5
View File
@@ -54,18 +54,28 @@
<DataTemplate x:Key="SingleMailItemTemplate" x:DataType="viewModelData:MailItemViewModel"> <DataTemplate x:Key="SingleMailItemTemplate" x:DataType="viewModelData:MailItemViewModel">
<controls:MailItemDisplayInformationControl <controls:MailItemDisplayInformationControl
x:DefaultBindMode="OneWay" 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}" CenterHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.CenterHoverAction, Mode=OneWay}"
ContextRequested="MailItemContextRequested" ContextRequested="MailItemContextRequested"
CreationDate="{x:Bind CreationDate}"
DisplayMode="{Binding ElementName=root, Path=ViewModel.PreferencesService.MailItemDisplayMode, Mode=OneWay}" 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}" HoverActionExecutedCommand="{Binding ElementName=root, Path=ViewModel.ExecuteHoverActionCommand}"
IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}" IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}"
IsDraft="{x:Bind IsDraft, Mode=OneWay}"
IsFlagged="{x:Bind IsFlagged, Mode=OneWay}"
IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}" IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}"
IsRead="{x:Bind IsRead, Mode=OneWay}"
IsThumbnailUpdated="{x:Bind ThumbnailUpdatedEvent, Mode=OneWay}" IsThumbnailUpdated="{x:Bind ThumbnailUpdatedEvent, Mode=OneWay}"
LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}" LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}"
MailItem="{x:Bind MailCopy, Mode=OneWay}"
Prefer24HourTimeFormat="{Binding ElementName=root, Path=ViewModel.PreferencesService.Prefer24HourTimeFormat, 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}" RightHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.RightHoverAction, Mode=OneWay}"
ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}" /> ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}"
Subject="{x:Bind Subject, Mode=OneWay}" />
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="ThreadMailItemTemplate" x:DataType="viewModelData:ThreadMailItemViewModel"> <DataTemplate x:Key="ThreadMailItemTemplate" x:DataType="viewModelData:ThreadMailItemViewModel">
@@ -76,20 +86,30 @@
<controls:WinoExpander.Header> <controls:WinoExpander.Header>
<controls:MailItemDisplayInformationControl <controls:MailItemDisplayInformationControl
x:DefaultBindMode="OneWay" x:DefaultBindMode="OneWay"
ActionItem="{x:Bind}"
Base64ContactPicture="{x:Bind Base64ContactPicture, Mode=OneWay, TargetNullValue=''}"
CenterHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.CenterHoverAction, Mode=OneWay}" CenterHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.CenterHoverAction, Mode=OneWay}"
ContextRequested="MailItemContextRequested" ContextRequested="MailItemContextRequested"
CreationDate="{x:Bind CreationDate}"
DisplayMode="{Binding ElementName=root, Path=ViewModel.PreferencesService.MailItemDisplayMode, Mode=OneWay}" 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}" HoverActionExecutedCommand="{Binding ElementName=root, Path=ViewModel.ExecuteHoverActionCommand}"
IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}" IsAvatarVisible="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowSenderPicturesEnabled, Mode=OneWay}"
IsDraft="{x:Bind IsDraft, Mode=OneWay}"
IsFlagged="{x:Bind IsFlagged, Mode=OneWay}"
IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}" IsHoverActionsEnabled="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsHoverActionsEnabled, Mode=OneWay}"
IsRead="{x:Bind IsRead, Mode=OneWay}"
IsThreadExpanded="{x:Bind IsThreadExpanded, Mode=OneWay}" IsThreadExpanded="{x:Bind IsThreadExpanded, Mode=OneWay}"
IsThreadExpanderVisible="True" IsThreadExpanderVisible="True"
IsThumbnailUpdated="{x:Bind LatestMailViewModel.ThumbnailUpdatedEvent, Mode=OneWay}" IsThumbnailUpdated="{x:Bind ThumbnailUpdatedEvent, Mode=OneWay}"
LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}" LeftHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.LeftHoverAction, Mode=OneWay}"
MailItem="{x:Bind LatestMailViewModel.MailCopy, Mode=OneWay}"
Prefer24HourTimeFormat="{Binding ElementName=root, Path=ViewModel.PreferencesService.Prefer24HourTimeFormat, 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}" RightHoverAction="{Binding ElementName=root, Path=ViewModel.PreferencesService.RightHoverAction, Mode=OneWay}"
ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}" /> ShowPreviewText="{Binding ElementName=root, Path=ViewModel.PreferencesService.IsShowPreviewEnabled, Mode=OneWay}"
Subject="{x:Bind Subject, Mode=OneWay}" />
</controls:WinoExpander.Header> </controls:WinoExpander.Header>
<controls:WinoExpander.Content> <controls:WinoExpander.Content>
<listview:WinoListView <listview:WinoListView
@@ -26,22 +26,28 @@
<DataTemplate x:Key="CompactDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode"> <DataTemplate x:Key="CompactDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode">
<controls1:MailItemDisplayInformationControl <controls1:MailItemDisplayInformationControl
DisplayMode="Compact" DisplayMode="Compact"
MailItem="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy}" FromAddress="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromAddress}"
ShowPreviewText="False" /> FromName="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromName}"
ShowPreviewText="False"
Subject="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.Subject}" />
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="MediumDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode"> <DataTemplate x:Key="MediumDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode">
<controls1:MailItemDisplayInformationControl <controls1:MailItemDisplayInformationControl
DisplayMode="Medium" DisplayMode="Medium"
MailItem="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy}" FromAddress="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromAddress}"
ShowPreviewText="True" /> FromName="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromName}"
ShowPreviewText="True"
Subject="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.Subject}" />
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="SpaciousDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode"> <DataTemplate x:Key="SpaciousDisplayModePreviewTemplate" x:DataType="enums:MailListDisplayMode">
<controls1:MailItemDisplayInformationControl <controls1:MailItemDisplayInformationControl
DisplayMode="Spacious" DisplayMode="Spacious"
MailItem="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy}" FromAddress="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromAddress}"
ShowPreviewText="True" /> FromName="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.FromName}"
ShowPreviewText="True"
Subject="{Binding ElementName=root, Path=ViewModel.DemoPreviewMailCopy.Subject}" />
</DataTemplate> </DataTemplate>
<mailSelectors:MailItemDisplayModePreviewTemplateSelector <mailSelectors:MailItemDisplayModePreviewTemplateSelector