Files
Wino-Mail/Wino.Mail/Views/MailListPage.xaml.cs
T

502 lines
18 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml.Controls;
using MoreLinq;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;
using Wino.Controls;
using Wino.Controls.Advanced;
using Wino.Core.Domain;
2024-04-18 01:44:37 +02:00
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;
using Wino.MenuFlyouts.Context;
using Wino.Messaging.Client.Mails;
2024-04-18 01:44:37 +02:00
using Wino.Views.Abstract;
2025-02-16 11:54:23 +01:00
namespace Wino.Views;
public sealed partial class MailListPage : MailListPageAbstract,
IRecipient<ClearMailSelectionsRequested>,
IRecipient<ActiveMailItemChangedEvent>,
IRecipient<SelectMailItemContainerEvent>,
IRecipient<DisposeRenderingFrameRequested>
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
private const double RENDERING_COLUMN_MIN_WIDTH = 375;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private IStatePersistanceService StatePersistenceService { get; } = App.Current.Services.GetService<IStatePersistanceService>();
private IKeyPressService KeyPressService { get; } = App.Current.Services.GetService<IKeyPressService>();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public MailListPage()
{
InitializeComponent();
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Bindings.Update();
2025-02-16 11:54:23 +01:00
// Delegate to ViewModel.
if (e.Parameter is NavigateMailFolderEventArgs folderNavigationArgs)
{
WeakReferenceMessenger.Default.Send(new ActiveMailFolderChangedEvent(folderNavigationArgs.BaseFolderMenuItem, folderNavigationArgs.FolderInitLoadAwaitTask));
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2025-02-16 11:54:23 +01:00
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Dispose all WinoListView items.
2024-06-26 20:00:10 +02:00
2025-02-16 11:54:23 +01:00
MailListView.Dispose();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
this.Bindings.StopTracking();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
RenderingFrame.Navigate(typeof(IdlePage));
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
GC.Collect();
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void UpdateSelectAllButtonStatus()
{
// Check all checkbox if all is selected.
// Unhook events to prevent selection overriding.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
SelectAllCheckbox.Checked -= SelectAllCheckboxChecked;
SelectAllCheckbox.Unchecked -= SelectAllCheckboxUnchecked;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
SelectAllCheckbox.IsChecked = MailListView.Items.Count > 0 && MailListView.SelectedItems.Count == MailListView.Items.Count;
2025-02-16 11:43:30 +01:00
2025-02-16 11:54:23 +01:00
SelectAllCheckbox.Checked += SelectAllCheckboxChecked;
SelectAllCheckbox.Unchecked += SelectAllCheckboxUnchecked;
}
2025-02-16 11:43:30 +01:00
2025-02-16 11:54:23 +01:00
private void SelectionModeToggleChecked(object sender, RoutedEventArgs e)
{
ChangeSelectionMode(ListViewSelectionMode.Multiple);
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void FolderPivotChanged(object sender, SelectionChangedEventArgs e)
{
foreach (var addedItem in e.AddedItems)
2025-02-16 11:35:43 +01:00
{
2025-02-16 11:54:23 +01:00
if (addedItem is FolderPivotViewModel pivotItem)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
pivotItem.IsSelected = true;
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
foreach (var removedItem in e.RemovedItems)
{
if (removedItem is FolderPivotViewModel pivotItem)
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
pivotItem.IsSelected = false;
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
SelectAllCheckbox.IsChecked = false;
SelectionModeToggle.IsChecked = false;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
MailListView.ClearSelections();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
UpdateSelectAllButtonStatus();
ViewModel.SelectedPivotChangedCommand.Execute(null);
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void ChangeSelectionMode(ListViewSelectionMode mode)
{
MailListView.ChangeSelectionMode(mode);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (ViewModel?.PivotFolders != null)
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
ViewModel.PivotFolders.ForEach(a => a.IsExtendedMode = mode == ListViewSelectionMode.Extended);
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void SelectionModeToggleUnchecked(object sender, RoutedEventArgs e)
{
ChangeSelectionMode(ListViewSelectionMode.Extended);
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private void SelectAllCheckboxChecked(object sender, RoutedEventArgs e)
{
MailListView.SelectAllWino();
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private void SelectAllCheckboxUnchecked(object sender, RoutedEventArgs e)
{
MailListView.ClearSelections();
}
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.
if (sender is MailItemDisplayInformationControl control && args.TryGetPosition(sender, out Point p))
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
await FocusManager.TryFocusAsync(control, FocusState.Keyboard);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (control.DataContext is IMailItem clickedMailItemContext)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var targetItems = ViewModel.GetTargetMailItemViewModels(clickedMailItemContext);
var availableActions = ViewModel.GetAvailableMailActions(targetItems);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (!availableActions?.Any() ?? false) return;
var t = targetItems.ElementAt(0);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
ViewModel.ChangeCustomFocusedState(targetItems, true);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var clickedOperation = await GetMailOperationFromFlyoutAsync(availableActions, control, p.X, p.Y);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
ViewModel.ChangeCustomFocusedState(targetItems, false);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (clickedOperation == null) return;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var prepRequest = new MailOperationPreperationRequest(clickedOperation.Operation, targetItems.Select(a => a.MailCopy));
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await ViewModel.ExecuteMailOperationAsync(prepRequest);
2024-04-18 01:44:37 +02:00
}
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private async Task<MailOperationMenuItem> GetMailOperationFromFlyoutAsync(IEnumerable<MailOperationMenuItem> availableActions,
UIElement showAtElement,
double x,
double y)
{
var source = new TaskCompletionSource<MailOperationMenuItem>();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var flyout = new MailOperationFlyout(availableActions, source);
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
flyout.ShowAt(showAtElement, new FlyoutShowOptions()
{
ShowMode = FlyoutShowMode.Standard,
Position = new Point(x + 30, y - 20)
});
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
return await source.Task;
}
void IRecipient<ClearMailSelectionsRequested>.Receive(ClearMailSelectionsRequested message)
{
MailListView.ClearSelections(null, preserveThreadExpanding: true);
}
2025-02-16 11:43:30 +01:00
2025-02-16 11:54:23 +01:00
void IRecipient<ActiveMailItemChangedEvent>.Receive(ActiveMailItemChangedEvent message)
{
// No active mail item. Go to empty page.
if (message.SelectedMailItemViewModel == null)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
else
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
// Navigate to composing page.
if (message.SelectedMailItemViewModel.IsDraft)
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
NavigationTransitionType composerPageTransition = NavigationTransitionType.None;
// Dispose active rendering if there is any and go to composer.
if (IsRenderingPageActive())
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
// Prepare WebView2 animation from Rendering to Composing page.
PrepareRenderingPageWebViewTransition();
// Dispose existing HTML content from rendering page webview.
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
2025-02-16 11:35:43 +01:00
}
2025-02-16 11:54:23 +01:00
else if (IsComposingPageActive())
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
// Composer is already active. Prepare composer WebView2 animation.
PrepareComposePageWebViewTransition();
}
else
composerPageTransition = NavigationTransitionType.DrillIn;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
ViewModel.NavigationService.Navigate(WinoPage.ComposePage, message.SelectedMailItemViewModel, NavigationReferenceFrame.RenderingFrame, composerPageTransition);
}
else
{
// Find the MIME and go to rendering page.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (message.SelectedMailItemViewModel == null) return;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (IsComposingPageActive())
{
PrepareComposePageWebViewTransition();
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
ViewModel.NavigationService.Navigate(WinoPage.MailRenderingPage, message.SelectedMailItemViewModel, NavigationReferenceFrame.RenderingFrame);
}
2025-02-16 11:43:30 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
UpdateAdaptiveness();
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private bool IsRenderingPageActive() => RenderingFrame.Content is MailRenderingPage;
private bool IsComposingPageActive() => RenderingFrame.Content is ComposePage;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void PrepareComposePageWebViewTransition()
{
var webView = GetComposerPageWebView();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (webView != null)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("WebViewConnectedAnimation", webView);
animation.Configuration = new BasicConnectedAnimationConfiguration();
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void PrepareRenderingPageWebViewTransition()
{
var webView = GetRenderingPageWebView();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (webView != null)
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
var animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("WebViewConnectedAnimation", webView);
animation.Configuration = new BasicConnectedAnimationConfiguration();
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
#region Connected Animation Helpers
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private WebView2 GetRenderingPageWebView()
{
if (RenderingFrame.Content is MailRenderingPage renderingPage)
return renderingPage.GetWebView();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
return null;
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private WebView2 GetComposerPageWebView()
{
if (RenderingFrame.Content is ComposePage composePage)
return composePage.GetWebView();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
return null;
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
#endregion
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
public async void Receive(SelectMailItemContainerEvent message)
{
if (message.SelectedMailViewModel == null) return;
await ViewModel.ExecuteUIThread(async () =>
{
MailListView.ClearSelections(message.SelectedMailViewModel, true);
2025-02-16 11:43:30 +01:00
2025-02-16 11:54:23 +01:00
int retriedSelectionCount = 0;
trySelection:
bool isSelected = MailListView.SelectMailItemContainer(message.SelectedMailViewModel);
if (!isSelected)
{
for (int i = retriedSelectionCount; i < 5;)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
// Retry with delay until the container is realized. Max 1 second.
await Task.Delay(200);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
retriedSelectionCount++;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
goto trySelection;
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Automatically scroll to the selected item.
// This is useful when creating draft.
if (isSelected && message.ScrollToItem)
{
var collectionContainer = ViewModel.MailCollection.GetMailItemContainer(message.SelectedMailViewModel.UniqueId);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Scroll to thread if available.
if (collectionContainer.ThreadViewModel != null)
{
MailListView.ScrollIntoView(collectionContainer.ThreadViewModel, ScrollIntoViewAlignment.Default);
}
else if (collectionContainer.ItemViewModel != null)
{
MailListView.ScrollIntoView(collectionContainer.ItemViewModel, ScrollIntoViewAlignment.Default);
2025-02-16 11:43:30 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
}
});
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private void SearchBoxFocused(object sender, RoutedEventArgs e)
{
SearchBar.PlaceholderText = string.Empty;
}
private void SearchBarUnfocused(object sender, RoutedEventArgs e)
{
SearchBar.PlaceholderText = Translator.SearchBarPlaceholder;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
/// <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)
{
if (sender is MailItemDisplayInformationControl control
&& control.ConnectedExpander?.Content is WinoListView contentListView)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var allItems = contentListView.Items.Where(a => a is IMailItem);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Highlight all items.
allItems.Cast<MailItemViewModel>().ForEach(a => a.IsCustomFocused = true);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Set native drag arg properties.
args.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Move;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var dragPackage = new MailDragPackage(allItems.Cast<IMailItem>());
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
args.Data.Properties.Add(nameof(MailDragPackage), dragPackage);
args.DragUI.SetContentFromDataPackage();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
control.ConnectedExpander.IsExpanded = true;
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void ThreadHeaderDragFinished(UIElement sender, DropCompletedEventArgs args)
{
if (sender is MailItemDisplayInformationControl control && control.ConnectedExpander != null && control.ConnectedExpander.Content is WinoListView contentListView)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
contentListView.Items.Where(a => a is MailItemViewModel).Cast<MailItemViewModel>().ForEach(a => a.IsCustomFocused = false);
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private async void LeftSwipeItemInvoked(Microsoft.UI.Xaml.Controls.SwipeItem sender, Microsoft.UI.Xaml.Controls.SwipeItemInvokedEventArgs args)
{
// Delete item for now.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var swipeControl = args.SwipeControl;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
swipeControl.Close();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (swipeControl.Tag is MailItemViewModel mailItemViewModel)
{
var package = new MailOperationPreperationRequest(MailOperation.SoftDelete, mailItemViewModel.MailCopy);
await ViewModel.ExecuteMailOperationAsync(package);
2025-02-16 11:35:43 +01:00
}
2025-02-16 11:54:23 +01:00
else if (swipeControl.Tag is ThreadMailItemViewModel threadMailItemViewModel)
2025-02-16 11:43:30 +01:00
{
2025-02-16 11:54:23 +01:00
var package = new MailOperationPreperationRequest(MailOperation.SoftDelete, threadMailItemViewModel.GetMailCopies());
await ViewModel.ExecuteMailOperationAsync(package);
}
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private async void RightSwipeItemInvoked(Microsoft.UI.Xaml.Controls.SwipeItem sender, Microsoft.UI.Xaml.Controls.SwipeItemInvokedEventArgs args)
{
// Toggle status only for now.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var swipeControl = args.SwipeControl;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
swipeControl.Close();
2025-02-16 11:54:23 +01:00
if (swipeControl.Tag is MailItemViewModel mailItemViewModel)
{
var operation = mailItemViewModel.IsRead ? MailOperation.MarkAsUnread : MailOperation.MarkAsRead;
var package = new MailOperationPreperationRequest(operation, mailItemViewModel.MailCopy);
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
await ViewModel.ExecuteMailOperationAsync(package);
}
2025-02-16 11:54:23 +01:00
else if (swipeControl.Tag is ThreadMailItemViewModel threadMailItemViewModel)
{
2025-02-16 11:54:23 +01:00
bool isAllRead = threadMailItemViewModel.ThreadItems.All(a => a.IsRead);
2024-08-19 16:26:15 +02:00
2025-02-16 11:54:23 +01:00
var operation = isAllRead ? MailOperation.MarkAsUnread : MailOperation.MarkAsRead;
var package = new MailOperationPreperationRequest(operation, threadMailItemViewModel.GetMailCopies());
await ViewModel.ExecuteMailOperationAsync(package);
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
private void PullToRefreshRequested(Microsoft.UI.Xaml.Controls.RefreshContainer sender, Microsoft.UI.Xaml.Controls.RefreshRequestedEventArgs args)
{
ViewModel.SyncFolderCommand?.Execute(null);
}
2024-08-19 16:26:15 +02:00
2025-02-16 11:54:23 +01:00
private async void SearchBar_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
2025-02-22 00:22:00 +01:00
// User clicked 'x' button to clearout the search text.
2025-02-16 11:54:23 +01:00
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput && string.IsNullOrWhiteSpace(sender.Text))
2025-02-16 11:43:30 +01:00
{
2025-02-22 00:22:00 +01:00
ViewModel.IsOnlineSearchButtonVisible = false;
2025-02-16 11:54:23 +01:00
await ViewModel.PerformSearchAsync();
2025-02-16 11:43:30 +01:00
}
2025-02-16 11:54:23 +01:00
}
2024-08-19 16:26:15 +02:00
2025-02-16 11:54:23 +01:00
public void Receive(DisposeRenderingFrameRequested message)
{
ViewModel.NavigationService.Navigate(WinoPage.IdlePage, null, NavigationReferenceFrame.RenderingFrame, NavigationTransitionType.DrillIn);
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private void PageSizeChanged(object sender, SizeChangedEventArgs e)
{
ViewModel.MaxMailListLength = e.NewSize.Width - RENDERING_COLUMN_MIN_WIDTH;
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
StatePersistenceService.IsReaderNarrowed = e.NewSize.Width < StatePersistenceService.MailListPaneLength + RENDERING_COLUMN_MIN_WIDTH;
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
UpdateAdaptiveness();
}
private void MailListSizerManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
StatePersistenceService.MailListPaneLength = ViewModel.MailListLength;
}
private void UpdateAdaptiveness()
{
bool isMultiSelectionEnabled = ViewModel.IsMultiSelectionModeEnabled || KeyPressService.IsCtrlKeyPressed();
if (StatePersistenceService.IsReaderNarrowed)
2024-08-19 17:15:59 +02:00
{
2025-02-16 11:54:23 +01:00
if (ViewModel.HasSingleItemSelection && !isMultiSelectionEnabled)
{
VisualStateManager.GoToState(this, "NarrowRenderer", true);
}
else
{
VisualStateManager.GoToState(this, "NarrowMailList", true);
}
2024-08-19 17:15:59 +02:00
}
2025-02-16 11:54:23 +01:00
else
2024-08-19 16:26:15 +02:00
{
2025-02-16 11:54:23 +01:00
if (ViewModel.HasSingleItemSelection && !isMultiSelectionEnabled)
2024-08-19 16:26:15 +02:00
{
2025-02-16 11:54:23 +01:00
VisualStateManager.GoToState(this, "BothPanelsMailSelected", true);
2024-08-19 16:26:15 +02:00
}
else
{
2025-02-16 11:54:23 +01:00
VisualStateManager.GoToState(this, "BothPanelsNoMailSelected", true);
2024-08-19 16:26:15 +02:00
}
}
2024-04-18 01:44:37 +02:00
}
2025-03-15 17:43:57 +01:00
private void SelectAllInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
=> MailListView.SelectAllWino();
private void DeleteAllInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
=> ViewModel.ExecuteMailOperationCommand.Execute(MailOperation.SoftDelete);
2024-04-18 01:44:37 +02:00
}