2025-09-29 11:16:14 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
2025-10-26 14:53:22 +01:00
|
|
|
using CommunityToolkit.WinUI;
|
2025-09-29 11:16:14 +02:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
|
|
|
|
using Microsoft.UI.Xaml.Input;
|
|
|
|
|
using Microsoft.UI.Xaml.Media.Animation;
|
|
|
|
|
using Microsoft.UI.Xaml.Navigation;
|
|
|
|
|
using MoreLinq;
|
|
|
|
|
using Windows.Foundation;
|
2025-10-22 03:45:38 +02:00
|
|
|
using Windows.System;
|
2025-10-28 16:47:06 +01:00
|
|
|
using Wino.Controls;
|
2025-09-29 11:16:14 +02:00
|
|
|
using Wino.Core.Domain;
|
|
|
|
|
using Wino.Core.Domain.Enums;
|
|
|
|
|
using Wino.Core.Domain.Interfaces;
|
|
|
|
|
using Wino.Core.Domain.Models.MailItem;
|
|
|
|
|
using Wino.Core.Domain.Models.Menus;
|
|
|
|
|
using Wino.Core.Domain.Models.Navigation;
|
|
|
|
|
using Wino.Mail.ViewModels.Data;
|
|
|
|
|
using Wino.Mail.ViewModels.Messages;
|
2025-10-27 01:00:38 +01:00
|
|
|
using Wino.Mail.WinUI.Controls.ListView;
|
2025-10-29 17:02:58 +01:00
|
|
|
using Wino.Mail.WinUI.Extensions;
|
2025-09-29 11:16:14 +02:00
|
|
|
using Wino.MenuFlyouts.Context;
|
|
|
|
|
using Wino.Messaging.Client.Mails;
|
|
|
|
|
using Wino.Views.Abstract;
|
|
|
|
|
|
|
|
|
|
namespace Wino.Views;
|
|
|
|
|
|
|
|
|
|
public sealed partial class MailListPage : MailListPageAbstract,
|
|
|
|
|
IRecipient<ClearMailSelectionsRequested>,
|
|
|
|
|
IRecipient<ActiveMailItemChangedEvent>,
|
|
|
|
|
IRecipient<SelectMailItemContainerEvent>,
|
|
|
|
|
IRecipient<DisposeRenderingFrameRequested>
|
|
|
|
|
{
|
|
|
|
|
private const double RENDERING_COLUMN_MIN_WIDTH = 375;
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private IStatePersistanceService StatePersistenceService { get; } = Core.WinUI.WinoApplication.Current.Services.GetService<IStatePersistanceService>() ?? throw new Exception($"Can't resolve {nameof(KeyPressService)}");
|
|
|
|
|
private IKeyPressService KeyPressService { get; } = Core.WinUI.WinoApplication.Current.Services.GetService<IKeyPressService>() ?? throw new Exception($"Can't resolve {nameof(KeyPressService)}");
|
2025-10-29 17:02:58 +01:00
|
|
|
private IKeyboardShortcutService KeyboardShortcutService { get; } = Core.WinUI.WinoApplication.Current.Services.GetService<IKeyboardShortcutService>() ?? throw new Exception($"Can't resolve {nameof(IKeyboardShortcutService)}");
|
2025-09-29 11:16:14 +02:00
|
|
|
public MailListPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedTo(e);
|
|
|
|
|
|
2025-10-12 16:23:33 +02:00
|
|
|
Bindings.Update();
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
ViewModel.MailCollection.ItemSelectionChanged += WinoMailCollectionSelectionChanged;
|
|
|
|
|
|
|
|
|
|
UpdateSelectAllButtonStatus();
|
|
|
|
|
UpdateAdaptiveness();
|
|
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
// Delegate to ViewModel.
|
|
|
|
|
if (e.Parameter is NavigateMailFolderEventArgs folderNavigationArgs)
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new ActiveMailFolderChangedEvent(folderNavigationArgs.BaseFolderMenuItem, folderNavigationArgs.FolderInitLoadAwaitTask));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-27 22:52:26 +01:00
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedFrom(e);
|
|
|
|
|
|
|
|
|
|
this.Bindings.StopTracking();
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
ViewModel.MailCollection.ItemSelectionChanged -= WinoMailCollectionSelectionChanged;
|
2025-10-27 01:43:36 +01:00
|
|
|
SelectAllCheckbox.Checked -= SelectAllCheckboxChecked;
|
|
|
|
|
SelectAllCheckbox.Unchecked -= SelectAllCheckboxUnchecked;
|
2025-10-26 14:53:22 +01:00
|
|
|
|
2025-10-29 18:45:14 +01:00
|
|
|
MailListView.Cleanup();
|
|
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
RenderingFrame.Navigate(typeof(IdlePage));
|
|
|
|
|
|
|
|
|
|
GC.Collect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSelectAllButtonStatus()
|
|
|
|
|
{
|
|
|
|
|
// Check all checkbox if all is selected.
|
|
|
|
|
// Unhook events to prevent selection overriding.
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Low, () =>
|
|
|
|
|
{
|
|
|
|
|
SelectAllCheckbox.Checked -= SelectAllCheckboxChecked;
|
|
|
|
|
SelectAllCheckbox.Unchecked -= SelectAllCheckboxUnchecked;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
SelectAllCheckbox.IsChecked = ViewModel.MailCollection.IsAllItemsSelected;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
SelectAllCheckbox.Checked += SelectAllCheckboxChecked;
|
|
|
|
|
SelectAllCheckbox.Unchecked += SelectAllCheckboxUnchecked;
|
|
|
|
|
});
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private void SelectionModeToggleChecked(object sender, RoutedEventArgs e) => ChangeSelectionMode(ListViewSelectionMode.Multiple);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
|
|
|
|
private void FolderPivotChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (var addedItem in e.AddedItems)
|
|
|
|
|
{
|
|
|
|
|
if (addedItem is FolderPivotViewModel pivotItem)
|
|
|
|
|
{
|
|
|
|
|
pivotItem.IsSelected = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var removedItem in e.RemovedItems)
|
|
|
|
|
{
|
|
|
|
|
if (removedItem is FolderPivotViewModel pivotItem)
|
|
|
|
|
{
|
|
|
|
|
pivotItem.IsSelected = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-22 03:45:38 +02:00
|
|
|
SelectAllCheckbox.IsChecked = false;
|
2025-09-29 11:16:14 +02:00
|
|
|
SelectionModeToggle.IsChecked = false;
|
|
|
|
|
|
|
|
|
|
UpdateSelectAllButtonStatus();
|
|
|
|
|
ViewModel.SelectedPivotChangedCommand.Execute(null);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private void ChangeSelectionMode(ListViewSelectionMode mode)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
2025-10-26 23:35:09 +01:00
|
|
|
MailListView.ChangeSelectionMode(mode);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
|
|
|
|
if (ViewModel?.PivotFolders != null)
|
|
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
ViewModel.PivotFolders.ForEach(a => a.IsExtendedMode = mode == ListViewSelectionMode.Extended);
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectionModeToggleUnchecked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
ChangeSelectionMode(ListViewSelectionMode.Extended);
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private async void SelectAllCheckboxChecked(object sender, RoutedEventArgs e)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
await ViewModel.MailCollection.SelectAllAsync();
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private async void SelectAllCheckboxUnchecked(object sender, RoutedEventArgs e)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
await ViewModel.MailCollection.UnselectAllAsync();
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-27 01:00:38 +01:00
|
|
|
private void WinoListViewChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args)
|
|
|
|
|
{
|
2025-10-31 00:51:27 +01:00
|
|
|
if (args.Item is ThreadMailItemViewModel && args.ItemContainer is not WinoThreadMailItemViewModelListViewItem)
|
2025-10-27 01:00:38 +01:00
|
|
|
{
|
2025-10-31 00:51:27 +01:00
|
|
|
args.ItemContainer = new WinoThreadMailItemViewModelListViewItem()
|
|
|
|
|
{
|
|
|
|
|
Item = args.Item as ThreadMailItemViewModel
|
|
|
|
|
};
|
2025-10-27 01:00:38 +01:00
|
|
|
}
|
2025-10-31 00:51:27 +01:00
|
|
|
else if (args.Item is MailItemViewModel && args.ItemContainer is not WinoMailItemViewModelListViewItem)
|
2025-10-27 01:00:38 +01:00
|
|
|
{
|
2025-10-31 00:51:27 +01:00
|
|
|
args.ItemContainer = new WinoMailItemViewModelListViewItem()
|
|
|
|
|
{
|
|
|
|
|
Item = args.Item as MailItemViewModel
|
|
|
|
|
};
|
2025-10-27 01:00:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
private async void MailItemContextRequested(UIElement sender, ContextRequestedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Context is requested from a single mail point, but we might have multiple selected items.
|
|
|
|
|
// This menu should be calculated based on all selected items by providers.
|
|
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
if (sender is MailItemDisplayInformationControl control && args.TryGetPosition(sender, out Point p))
|
|
|
|
|
{
|
2025-11-12 18:52:15 +01:00
|
|
|
IEnumerable<MailItemViewModel> targetItems;
|
|
|
|
|
if (!ViewModel.MailCollection.SelectedItems.Contains(control.ActionItem))
|
|
|
|
|
{
|
|
|
|
|
// Right clicked item is not selected. Select.
|
|
|
|
|
await WinoClickItemInternalAsync(control.ActionItem, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default to all selected items.
|
|
|
|
|
targetItems = ViewModel.MailCollection.SelectedItems;
|
2025-10-28 16:47:06 +01:00
|
|
|
var availableActions = ViewModel.GetAvailableMailActions(targetItems);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-11-14 18:51:48 +01:00
|
|
|
if (availableActions == null || !availableActions.Any()) return;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
var clickedOperation = await GetMailOperationFromFlyoutAsync(availableActions, control, p.X, p.Y);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
if (clickedOperation == null) return;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
var prepRequest = new MailOperationPreperationRequest(clickedOperation.Operation, targetItems.Select(a => a.MailCopy));
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
await ViewModel.ExecuteMailOperationAsync(prepRequest);
|
|
|
|
|
}
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<MailOperationMenuItem> GetMailOperationFromFlyoutAsync(IEnumerable<MailOperationMenuItem> availableActions,
|
|
|
|
|
UIElement showAtElement,
|
|
|
|
|
double x,
|
|
|
|
|
double y)
|
|
|
|
|
{
|
|
|
|
|
var source = new TaskCompletionSource<MailOperationMenuItem>();
|
|
|
|
|
|
|
|
|
|
var flyout = new MailOperationFlyout(availableActions, source);
|
|
|
|
|
|
|
|
|
|
flyout.ShowAt(showAtElement, new FlyoutShowOptions()
|
|
|
|
|
{
|
|
|
|
|
ShowMode = FlyoutShowMode.Standard,
|
|
|
|
|
Position = new Point(x + 30, y - 20)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return await source.Task;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
async void IRecipient<ClearMailSelectionsRequested>.Receive(ClearMailSelectionsRequested message)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
2025-10-28 16:47:06 +01:00
|
|
|
await ViewModel.MailCollection.UnselectAllAsync();
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRecipient<ActiveMailItemChangedEvent>.Receive(ActiveMailItemChangedEvent message)
|
|
|
|
|
{
|
|
|
|
|
// No active mail item. Go to empty page.
|
|
|
|
|
if (message.SelectedMailItemViewModel == null)
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Navigate to composing page.
|
|
|
|
|
if (message.SelectedMailItemViewModel.IsDraft)
|
|
|
|
|
{
|
|
|
|
|
NavigationTransitionType composerPageTransition = NavigationTransitionType.None;
|
|
|
|
|
|
|
|
|
|
// Dispose active rendering if there is any and go to composer.
|
|
|
|
|
if (IsRenderingPageActive())
|
|
|
|
|
{
|
|
|
|
|
// Prepare WebView2 animation from Rendering to Composing page.
|
|
|
|
|
PrepareRenderingPageWebViewTransition();
|
|
|
|
|
|
|
|
|
|
// Dispose existing HTML content from rendering page webview.
|
|
|
|
|
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
|
|
|
|
}
|
|
|
|
|
else if (IsComposingPageActive())
|
|
|
|
|
{
|
|
|
|
|
// Composer is already active. Prepare composer WebView2 animation.
|
|
|
|
|
PrepareComposePageWebViewTransition();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
composerPageTransition = NavigationTransitionType.DrillIn;
|
|
|
|
|
|
|
|
|
|
ViewModel.NavigationService.Navigate(WinoPage.ComposePage, message.SelectedMailItemViewModel, NavigationReferenceFrame.RenderingFrame, composerPageTransition);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Find the MIME and go to rendering page.
|
|
|
|
|
|
|
|
|
|
if (message.SelectedMailItemViewModel == null) return;
|
|
|
|
|
|
|
|
|
|
if (IsComposingPageActive())
|
|
|
|
|
{
|
|
|
|
|
PrepareComposePageWebViewTransition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ViewModel.NavigationService.Navigate(WinoPage.MailRenderingPage, message.SelectedMailItemViewModel, NavigationReferenceFrame.RenderingFrame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateAdaptiveness();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsRenderingPageActive() => RenderingFrame.Content is MailRenderingPage;
|
|
|
|
|
private bool IsComposingPageActive() => RenderingFrame.Content is ComposePage;
|
|
|
|
|
|
|
|
|
|
private void PrepareComposePageWebViewTransition()
|
|
|
|
|
{
|
|
|
|
|
var webView = GetComposerPageWebView();
|
|
|
|
|
|
|
|
|
|
if (webView != null)
|
|
|
|
|
{
|
|
|
|
|
var animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("WebViewConnectedAnimation", webView);
|
|
|
|
|
animation.Configuration = new BasicConnectedAnimationConfiguration();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PrepareRenderingPageWebViewTransition()
|
|
|
|
|
{
|
|
|
|
|
var webView = GetRenderingPageWebView();
|
|
|
|
|
|
|
|
|
|
if (webView != null)
|
|
|
|
|
{
|
|
|
|
|
var animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("WebViewConnectedAnimation", webView);
|
|
|
|
|
animation.Configuration = new BasicConnectedAnimationConfiguration();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Connected Animation Helpers
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private WebView2? GetRenderingPageWebView()
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
|
|
|
|
if (RenderingFrame.Content is MailRenderingPage renderingPage)
|
|
|
|
|
return renderingPage.GetWebView();
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private WebView2? GetComposerPageWebView()
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
|
|
|
|
if (RenderingFrame.Content is ComposePage composePage)
|
|
|
|
|
return composePage.GetWebView();
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public async void Receive(SelectMailItemContainerEvent message)
|
|
|
|
|
{
|
2025-11-12 15:44:43 +01:00
|
|
|
if (message.MailUniqueId == Guid.Empty) return;
|
|
|
|
|
|
|
|
|
|
// Find the item from the collection.
|
|
|
|
|
// Folder should be initialized already.
|
|
|
|
|
|
|
|
|
|
var item = ViewModel.MailCollection.Find(message.MailUniqueId);
|
|
|
|
|
|
|
|
|
|
if (item == null) return;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-11-01 12:11:05 +01:00
|
|
|
await DispatcherQueue.EnqueueAsync(async () =>
|
2025-10-18 22:16:28 +02:00
|
|
|
{
|
2025-11-12 15:44:43 +01:00
|
|
|
var collectionContainer = await MailListView.GetItemContainersAsync(item);
|
2025-10-18 22:16:28 +02:00
|
|
|
|
2025-11-01 12:11:05 +01:00
|
|
|
if (collectionContainer.Item1 == null && collectionContainer.Item2 == null) return;
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-10-18 22:16:28 +02:00
|
|
|
// Automatically scroll to the selected item.
|
|
|
|
|
// This is useful when creating draft.
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-11-01 12:11:05 +01:00
|
|
|
if (message.ScrollToItem)
|
2025-10-18 22:16:28 +02:00
|
|
|
{
|
|
|
|
|
// Scroll to thread if available.
|
|
|
|
|
// Find the item index on the UI. This is different than ListView.
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-10-18 22:16:28 +02:00
|
|
|
int scrollIndex = -1;
|
2025-11-01 12:11:05 +01:00
|
|
|
if (collectionContainer.Item2 != null)
|
2025-10-18 22:16:28 +02:00
|
|
|
{
|
2025-11-01 12:11:05 +01:00
|
|
|
scrollIndex = ViewModel.MailCollection.IndexOf(collectionContainer.Item2.Item);
|
2025-10-18 22:16:28 +02:00
|
|
|
}
|
2025-11-01 12:11:05 +01:00
|
|
|
else if (collectionContainer.Item1 != null)
|
2025-10-18 22:16:28 +02:00
|
|
|
{
|
2025-11-01 12:11:05 +01:00
|
|
|
scrollIndex = ViewModel.MailCollection.IndexOf(collectionContainer.Item1.Item);
|
2025-10-18 22:16:28 +02:00
|
|
|
}
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-10-18 22:16:28 +02:00
|
|
|
if (scrollIndex >= 0)
|
|
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
await MailListView.SmoothScrollIntoViewWithIndexAsync(scrollIndex);
|
2025-10-18 22:16:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-11-01 12:11:05 +01:00
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
await WinoClickItemInternalAsync(item, true);
|
2025-10-18 22:16:28 +02:00
|
|
|
});
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchBoxFocused(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SearchBar.PlaceholderText = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchBarUnfocused(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SearchBar.PlaceholderText = Translator.SearchBarPlaceholder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Thread header is mail info display control and it can be dragged spearately out of ListView.
|
|
|
|
|
/// We need to prepare a drag package for it from the items inside.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ThreadHeaderDragStart(UIElement sender, DragStartingEventArgs args)
|
|
|
|
|
{
|
2025-10-03 15:46:38 +02:00
|
|
|
//if (sender is MailItemDisplayInformationControl control
|
|
|
|
|
// && control.ConnectedExpander?.Content is WinoListView contentListView)
|
|
|
|
|
//{
|
|
|
|
|
// var allItems = contentListView.Items.Where(a => a is MailCopy);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
// // Highlight all items.
|
|
|
|
|
// allItems.Cast<MailItemViewModel>().ForEach(a => a.IsCustomFocused = true);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
// // Set native drag arg properties.
|
|
|
|
|
// args.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Move;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
// var dragPackage = new MailDragPackage(allItems.Cast<MailCopy>());
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
// args.Data.Properties.Add(nameof(MailDragPackage), dragPackage);
|
|
|
|
|
// args.DragUI.SetContentFromDataPackage();
|
2025-09-29 11:16:14 +02:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
// control.ConnectedExpander.IsExpanded = true;
|
|
|
|
|
//}
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ThreadHeaderDragFinished(UIElement sender, DropCompletedEventArgs args)
|
|
|
|
|
{
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void LeftSwipeItemInvoked(Microsoft.UI.Xaml.Controls.SwipeItem sender, Microsoft.UI.Xaml.Controls.SwipeItemInvokedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Delete item for now.
|
|
|
|
|
|
|
|
|
|
var swipeControl = args.SwipeControl;
|
|
|
|
|
|
|
|
|
|
swipeControl.Close();
|
|
|
|
|
|
|
|
|
|
if (swipeControl.Tag is MailItemViewModel mailItemViewModel)
|
|
|
|
|
{
|
|
|
|
|
var package = new MailOperationPreperationRequest(MailOperation.SoftDelete, mailItemViewModel.MailCopy);
|
|
|
|
|
await ViewModel.ExecuteMailOperationAsync(package);
|
|
|
|
|
}
|
|
|
|
|
else if (swipeControl.Tag is ThreadMailItemViewModel threadMailItemViewModel)
|
|
|
|
|
{
|
2025-10-03 15:46:38 +02:00
|
|
|
var package = new MailOperationPreperationRequest(MailOperation.SoftDelete, threadMailItemViewModel.ThreadEmails.Select(a => a.MailCopy));
|
2025-09-29 11:16:14 +02:00
|
|
|
await ViewModel.ExecuteMailOperationAsync(package);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void RightSwipeItemInvoked(Microsoft.UI.Xaml.Controls.SwipeItem sender, Microsoft.UI.Xaml.Controls.SwipeItemInvokedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Toggle status only for now.
|
|
|
|
|
|
|
|
|
|
var swipeControl = args.SwipeControl;
|
|
|
|
|
|
|
|
|
|
swipeControl.Close();
|
|
|
|
|
|
|
|
|
|
if (swipeControl.Tag is MailItemViewModel mailItemViewModel)
|
|
|
|
|
{
|
|
|
|
|
var operation = mailItemViewModel.IsRead ? MailOperation.MarkAsUnread : MailOperation.MarkAsRead;
|
|
|
|
|
var package = new MailOperationPreperationRequest(operation, mailItemViewModel.MailCopy);
|
|
|
|
|
|
|
|
|
|
await ViewModel.ExecuteMailOperationAsync(package);
|
|
|
|
|
}
|
|
|
|
|
else if (swipeControl.Tag is ThreadMailItemViewModel threadMailItemViewModel)
|
|
|
|
|
{
|
2025-10-03 15:46:38 +02:00
|
|
|
bool isAllRead = threadMailItemViewModel.ThreadEmails.All(a => a.IsRead);
|
2025-09-29 11:16:14 +02:00
|
|
|
|
|
|
|
|
var operation = isAllRead ? MailOperation.MarkAsUnread : MailOperation.MarkAsRead;
|
2025-10-03 15:46:38 +02:00
|
|
|
var package = new MailOperationPreperationRequest(operation, threadMailItemViewModel.ThreadEmails.Select(a => a.MailCopy));
|
2025-09-29 11:16:14 +02:00
|
|
|
|
|
|
|
|
await ViewModel.ExecuteMailOperationAsync(package);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void SearchBar_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// User clicked 'x' button to clearout the search text.
|
|
|
|
|
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput && string.IsNullOrWhiteSpace(sender.Text))
|
|
|
|
|
{
|
|
|
|
|
ViewModel.IsOnlineSearchButtonVisible = false;
|
|
|
|
|
await ViewModel.PerformSearchAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Receive(DisposeRenderingFrameRequested message)
|
|
|
|
|
{
|
|
|
|
|
ViewModel.NavigationService.Navigate(WinoPage.IdlePage, null, NavigationReferenceFrame.RenderingFrame, NavigationTransitionType.DrillIn);
|
2025-10-28 16:47:06 +01:00
|
|
|
UpdateAdaptiveness();
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
protected override void RegisterRecipients()
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Register<ClearMailSelectionsRequested>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Register<ActiveMailItemChangedEvent>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Register<SelectMailItemContainerEvent>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Register<DisposeRenderingFrameRequested>(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UnregisterRecipients()
|
|
|
|
|
{
|
|
|
|
|
WeakReferenceMessenger.Default.Unregister<ClearMailSelectionsRequested>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Unregister<ActiveMailItemChangedEvent>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Unregister<SelectMailItemContainerEvent>(this);
|
|
|
|
|
WeakReferenceMessenger.Default.Unregister<DisposeRenderingFrameRequested>(this);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 11:16:14 +02:00
|
|
|
private void PageSizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ViewModel.MaxMailListLength = e.NewSize.Width - RENDERING_COLUMN_MIN_WIDTH;
|
|
|
|
|
|
|
|
|
|
StatePersistenceService.IsReaderNarrowed = e.NewSize.Width < StatePersistenceService.MailListPaneLength + RENDERING_COLUMN_MIN_WIDTH;
|
|
|
|
|
|
|
|
|
|
UpdateAdaptiveness();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MailListSizerManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
StatePersistenceService.MailListPaneLength = ViewModel.MailListLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateAdaptiveness()
|
|
|
|
|
{
|
2025-10-27 22:52:26 +01:00
|
|
|
bool isMultiSelectionEnabled = ViewModel.IsMultiSelectionModeEnabled;
|
2025-09-29 11:16:14 +02:00
|
|
|
|
|
|
|
|
if (StatePersistenceService.IsReaderNarrowed)
|
|
|
|
|
{
|
2025-10-21 22:08:56 +02:00
|
|
|
if (ViewModel.MailCollection.HasSingleItemSelected && !isMultiSelectionEnabled)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "NarrowRenderer", true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "NarrowMailList", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-10-21 22:08:56 +02:00
|
|
|
if (ViewModel.MailCollection.HasSingleItemSelected && !isMultiSelectionEnabled)
|
2025-09-29 11:16:14 +02:00
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "BothPanelsMailSelected", true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
VisualStateManager.GoToState(this, "BothPanelsNoMailSelected", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 16:47:06 +01:00
|
|
|
|
2025-10-03 15:46:38 +02:00
|
|
|
|
2025-10-26 23:35:09 +01:00
|
|
|
private void WinoMailCollectionSelectionChanged(object? sender, EventArgs args)
|
2025-10-03 15:46:38 +02:00
|
|
|
{
|
|
|
|
|
UpdateSelectAllButtonStatus();
|
2025-10-20 19:17:52 +02:00
|
|
|
UpdateAdaptiveness();
|
2025-10-18 22:16:28 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-26 14:53:22 +01:00
|
|
|
private async void WinoListViewProcessKeyboardAccelerators(UIElement sender, ProcessKeyboardAcceleratorEventArgs args)
|
2025-10-21 22:08:56 +02:00
|
|
|
{
|
2025-10-28 16:47:06 +01:00
|
|
|
args.Handled = true;
|
|
|
|
|
|
2025-10-22 03:45:38 +02:00
|
|
|
if (args.Key == VirtualKey.Delete)
|
|
|
|
|
{
|
2025-10-28 16:47:06 +01:00
|
|
|
ViewModel.ExecuteMailOperationCommand.Execute(MailOperation.SoftDelete);
|
2025-10-22 03:45:38 +02:00
|
|
|
}
|
2025-10-28 16:47:06 +01:00
|
|
|
else if (args.Key == VirtualKey.A && args.Modifiers.HasFlag(VirtualKeyModifiers.Control))
|
2025-10-22 03:45:38 +02:00
|
|
|
{
|
2025-10-26 14:53:22 +01:00
|
|
|
await ViewModel.MailCollection.ToggleSelectAllAsync();
|
2025-10-21 22:08:56 +02:00
|
|
|
}
|
2025-10-29 17:02:58 +01:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Check keyboard shortcuts from service.
|
|
|
|
|
ModifierKeys modifiers = args.Modifiers.ToDomainModifierKeys();
|
|
|
|
|
|
|
|
|
|
var operation = await KeyboardShortcutService.GetMailOperationForKeyAsync(args.Key.ToString(), modifiers);
|
|
|
|
|
|
|
|
|
|
if (operation != null)
|
|
|
|
|
{
|
|
|
|
|
ViewModel.ExecuteMailOperationCommand.Execute(operation);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
args.Handled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-21 22:08:56 +02:00
|
|
|
}
|
2025-10-26 23:35:09 +01:00
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
private async Task WinoClickItemInternalAsync(object? clickedItem, bool selectExpandThread = false)
|
2025-10-26 23:35:09 +01:00
|
|
|
{
|
2025-11-01 12:11:05 +01:00
|
|
|
if (clickedItem == null) return;
|
2025-10-26 23:35:09 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
// Requirements (summary):
|
|
|
|
|
// CTRL pressed -> multi-select behaviour
|
|
|
|
|
// * Clicking single item toggles only that item.
|
|
|
|
|
// * Clicking thread header toggles selection of thread AND all its children (all on or all off).
|
|
|
|
|
// * Clicking an item inside a thread toggles only that child item.
|
|
|
|
|
// CTRL NOT pressed -> single-select (exclusive) with toggle support (can leave zero selected)
|
|
|
|
|
// * Clicking thread header: unselect everything else, collapse all other threads, select only the thread + first child.
|
|
|
|
|
// If already in that state (thread selected and first child selected), clicking again unselects all (nothing selected).
|
|
|
|
|
// * Clicking a single (non-thread) item OR a child item: collapse & unselect all others then toggle that item's selection.
|
|
|
|
|
// If it was selected, result is nothing selected.
|
2025-10-27 01:43:36 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
bool isCtrlPressed = KeyPressService.IsCtrlKeyPressed();
|
2025-10-27 22:52:26 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
// Helper local to collapse all other threads (we always collapse ALL then possibly re-expand the active thread per rules)
|
|
|
|
|
async Task CollapseAllThreadsExceptAsync(ThreadMailItemViewModel? except)
|
2025-10-27 01:43:36 +01:00
|
|
|
{
|
2025-11-12 18:52:15 +01:00
|
|
|
bool wasExpanded = except != null && except.IsThreadExpanded;
|
|
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
await ViewModel.MailCollection.CollapseAllThreadsAsync();
|
2025-11-12 18:52:15 +01:00
|
|
|
if (except != null && wasExpanded)
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// We'll expand explicitly when required by logic below.
|
2025-11-12 18:52:15 +01:00
|
|
|
except.IsThreadExpanded = true;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-27 01:43:36 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
if (isCtrlPressed)
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
switch (clickedItem)
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
case ThreadMailItemViewModel thread:
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// Determine if thread + all children currently selected
|
|
|
|
|
bool allSelected = thread.IsSelected && thread.ThreadEmails.All(e => e.IsSelected);
|
|
|
|
|
if (allSelected)
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// Unselect thread & all children
|
|
|
|
|
thread.IsSelected = false;
|
|
|
|
|
foreach (var child in thread.ThreadEmails)
|
|
|
|
|
child.IsSelected = false;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// Select thread & all children (do NOT disturb other selections in CTRL mode)
|
|
|
|
|
thread.IsSelected = true;
|
|
|
|
|
foreach (var child in thread.ThreadEmails)
|
|
|
|
|
child.IsSelected = true;
|
|
|
|
|
// Keep it expanded so user can see items
|
|
|
|
|
thread.IsThreadExpanded = true;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
break;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
case MailItemViewModel mail:
|
|
|
|
|
{
|
|
|
|
|
// Toggle just this item; no collapse/unselect of others in multi-select mode.
|
|
|
|
|
mail.IsSelected = !mail.IsSelected;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return; // Multi-select path ends here.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SINGLE-SELECTION (exclusive) MODE WITH TOGGLE SUPPORT
|
|
|
|
|
if (clickedItem is ThreadMailItemViewModel clickedThread)
|
|
|
|
|
{
|
|
|
|
|
bool wasThreadSelected = clickedThread.IsSelected;
|
2025-11-12 15:44:43 +01:00
|
|
|
bool wasThreadExpanded = clickedThread.IsThreadExpanded;
|
|
|
|
|
|
|
|
|
|
// Check if any child in this thread is already selected (e.g., from notification click)
|
|
|
|
|
var alreadySelectedChild = clickedThread.ThreadEmails.FirstOrDefault(e => e.IsSelected);
|
2025-11-06 23:54:32 +01:00
|
|
|
|
|
|
|
|
// Reset everything first (exclusive selection scenario)
|
|
|
|
|
await ViewModel.MailCollection.UnselectAllAsync();
|
|
|
|
|
await CollapseAllThreadsExceptAsync(clickedThread);
|
|
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
if (wasThreadSelected && wasThreadExpanded)
|
2025-11-06 23:54:32 +01:00
|
|
|
{
|
|
|
|
|
// Toggle off -> leave nothing selected (all unselected, thread collapsed)
|
|
|
|
|
clickedThread.IsThreadExpanded = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
// Select thread header
|
2025-11-06 23:54:32 +01:00
|
|
|
clickedThread.IsSelected = true;
|
2025-11-12 15:44:43 +01:00
|
|
|
|
|
|
|
|
// If a child was already selected (e.g., from notification), keep that selection
|
|
|
|
|
// Otherwise, select the first child
|
|
|
|
|
if (alreadySelectedChild != null)
|
2025-11-06 23:54:32 +01:00
|
|
|
{
|
2025-11-12 15:44:43 +01:00
|
|
|
alreadySelectedChild.IsSelected = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var firstChild = clickedThread.ThreadEmails.FirstOrDefault();
|
|
|
|
|
if (firstChild != null)
|
2025-11-06 23:54:32 +01:00
|
|
|
{
|
2025-11-12 15:44:43 +01:00
|
|
|
firstChild.IsSelected = true;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
}
|
2025-11-12 15:44:43 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
clickedThread.IsThreadExpanded = true; // Show contents of active thread
|
|
|
|
|
}
|
|
|
|
|
else if (clickedItem is MailItemViewModel clickedMail)
|
|
|
|
|
{
|
|
|
|
|
bool wasSelected = clickedMail.IsSelected;
|
|
|
|
|
|
|
|
|
|
// Determine if this mail belongs to an already selected & expanded thread.
|
|
|
|
|
// If so, we only want to switch the selection inside that thread without collapsing or unselecting the thread header.
|
|
|
|
|
ThreadMailItemViewModel? parentThread = null;
|
|
|
|
|
|
|
|
|
|
foreach (var group in ViewModel.MailCollection.MailItems)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in group)
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
if (item is ThreadMailItemViewModel thread && thread.ThreadEmails.Contains(clickedMail))
|
2025-10-27 22:52:26 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
parentThread = thread;
|
|
|
|
|
break;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
if (parentThread != null) break;
|
2025-10-27 22:52:26 +01:00
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
|
|
|
|
|
bool isInSelectedExpandedThread = parentThread != null && parentThread.IsSelected && parentThread.IsThreadExpanded;
|
|
|
|
|
|
|
|
|
|
if (isInSelectedExpandedThread)
|
2025-10-27 01:43:36 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// Switch selection within the thread: unselect previously selected children, select the clicked one.
|
|
|
|
|
if (parentThread?.ThreadEmails != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var child in parentThread.ThreadEmails)
|
|
|
|
|
{
|
|
|
|
|
child.IsSelected = child == clickedMail && !wasSelected; // If clicking an already selected child -> toggle off (none selected in thread except header)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-28 16:47:06 +01:00
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
if (wasSelected && parentThread != null)
|
2025-10-28 16:47:06 +01:00
|
|
|
{
|
2025-11-06 23:54:32 +01:00
|
|
|
// Clicking the already selected child should leave the thread header selected (canonical state: thread + first child previously).
|
|
|
|
|
// Decide whether to keep a child selected; spec wants toggle off allowed, so leave no child selected.
|
|
|
|
|
// Ensure parent thread stays selected & expanded.
|
|
|
|
|
parentThread.IsSelected = true;
|
|
|
|
|
parentThread.IsThreadExpanded = true;
|
2025-10-28 16:47:06 +01:00
|
|
|
}
|
2025-11-06 23:54:32 +01:00
|
|
|
return; // Done.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Normal single-item (non-thread or entering a thread via child) behavior.
|
|
|
|
|
await ViewModel.MailCollection.UnselectAllAsync();
|
|
|
|
|
await ViewModel.MailCollection.CollapseAllThreadsAsync();
|
|
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
if (parentThread != null && selectExpandThread)
|
|
|
|
|
{
|
|
|
|
|
// We're clicking an item inside a thread; select & expand the thread header as well.
|
|
|
|
|
parentThread.IsSelected = true;
|
|
|
|
|
parentThread.IsThreadExpanded = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 23:54:32 +01:00
|
|
|
if (!wasSelected)
|
|
|
|
|
{
|
|
|
|
|
clickedMail.IsSelected = true; // Toggle on
|
2025-10-27 01:43:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-01 12:11:05 +01:00
|
|
|
|
|
|
|
|
private async void WinoListViewItemClicked(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is not WinoListView listView) return;
|
|
|
|
|
|
2025-11-12 15:44:43 +01:00
|
|
|
await WinoClickItemInternalAsync(e.ClickedItem);
|
2025-11-01 12:11:05 +01:00
|
|
|
}
|
2025-11-14 18:51:48 +01:00
|
|
|
|
|
|
|
|
private void SearchbarQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (ViewModel.PerformSearchCommand.CanExecute(null))
|
|
|
|
|
ViewModel.PerformSearchCommand.Execute(null);
|
|
|
|
|
}
|
2025-09-29 11:16:14 +02:00
|
|
|
}
|