diff --git a/Wino.Core/MenuItems/MenuItemCollection.cs b/Wino.Core/MenuItems/MenuItemCollection.cs
index d6f50cb3..c96351fe 100644
--- a/Wino.Core/MenuItems/MenuItemCollection.cs
+++ b/Wino.Core/MenuItems/MenuItemCollection.cs
@@ -192,10 +192,12 @@ namespace Wino.Core.MenuItems
item.IsExpanded = false;
item.IsSelected = false;
- Remove(item);
+ try
+ {
+ Remove(item);
+ }
+ catch (Exception) { }
});
-
- // RemoveRange(itemsToRemove);
}
}
}
diff --git a/Wino.Mail/Controls/Advanced/WinoListView.cs b/Wino.Mail/Controls/Advanced/WinoListView.cs
index d50fe249..c3289800 100644
--- a/Wino.Mail/Controls/Advanced/WinoListView.cs
+++ b/Wino.Mail/Controls/Advanced/WinoListView.cs
@@ -48,7 +48,7 @@ namespace Wino.Controls.Advanced
}
public static readonly DependencyProperty LoadMoreCommandProperty = DependencyProperty.Register(nameof(LoadMoreCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
- public static readonly DependencyProperty IsThreadListViewProperty = DependencyProperty.Register(nameof(IsThreadListView), typeof(bool), typeof(WinoListView), new PropertyMetadata(false));
+ public static readonly DependencyProperty IsThreadListViewProperty = DependencyProperty.Register(nameof(IsThreadListView), typeof(bool), typeof(WinoListView), new PropertyMetadata(false, new PropertyChangedCallback(OnIsThreadViewChanged)));
public static readonly DependencyProperty ItemDeletedCommandProperty = DependencyProperty.Register(nameof(ItemDeletedCommand), typeof(ICommand), typeof(WinoListView), new PropertyMetadata(null));
public WinoListView()
@@ -64,7 +64,6 @@ namespace Wino.Controls.Advanced
DragItemsCompleted += ItemDragCompleted;
DragItemsStarting += ItemDragStarting;
SelectionChanged += SelectedItemsChanged;
- ItemClick += MailItemClicked;
ProcessKeyboardAccelerators += ProcessDelKey;
}
@@ -84,6 +83,22 @@ namespace Wino.Controls.Advanced
internalScrollviewer.ViewChanged += InternalScrollVeiwerViewChanged;
}
+ private static void OnIsThreadViewChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ if (obj is WinoListView winoListView)
+ {
+ winoListView.AdjustThreadViewContainerVisuals();
+ }
+ }
+
+ private void AdjustThreadViewContainerVisuals()
+ {
+ if (IsThreadListView)
+ {
+ ItemContainerTransitions.Clear();
+ }
+ }
+
private double lastestRaisedOffset = 0;
private int lastItemSize = 0;
@@ -159,19 +174,6 @@ namespace Wino.Controls.Advanced
}
}
- private void MailItemClicked(object sender, ItemClickEventArgs e)
- {
- if (e.ClickedItem is ThreadMailItemViewModel clickedThread)
- {
- clickedThread.IsThreadExpanded = !clickedThread.IsThreadExpanded;
-
- if (!clickedThread.IsThreadExpanded)
- {
- SelectedItems.Clear();
- }
- }
- }
-
public void ChangeSelectionMode(ListViewSelectionMode selectionMode)
{
SelectionMode = selectionMode;
@@ -293,6 +295,10 @@ namespace Wino.Controls.Advanced
removedMailItemViewModel.IsSelected = false;
WeakReferenceMessenger.Default.Send(new MailItemSelectionRemovedEvent(removedMailItemViewModel));
}
+ else if (removedItem is ThreadMailItemViewModel removedThreadItemViewModel)
+ {
+ removedThreadItemViewModel.IsThreadExpanded = false;
+ }
}
}
@@ -313,7 +319,7 @@ namespace Wino.Controls.Advanced
// threadMailItemViewModel.IsThreadExpanded = true;
// Don't select thread containers.
- SelectedItems.Remove(addedItem);
+ // SelectedItems.Remove(addedItem);
}
}
}
@@ -341,10 +347,10 @@ namespace Wino.Controls.Advanced
{
// Tell main list view to unselect all his items.
- if (SelectedItems[0] is MailItemViewModel selectedMailItemViewModel)
- {
- WeakReferenceMessenger.Default.Send(new ResetSingleMailItemSelectionEvent(selectedMailItemViewModel));
- }
+ //if (SelectedItems[0] is MailItemViewModel selectedMailItemViewModel)
+ //{
+ // WeakReferenceMessenger.Default.Send(new ResetSingleMailItemSelectionEvent(selectedMailItemViewModel));
+ //}
}
}
}
@@ -369,7 +375,6 @@ namespace Wino.Controls.Advanced
DragItemsCompleted -= ItemDragCompleted;
DragItemsStarting -= ItemDragStarting;
SelectionChanged -= SelectedItemsChanged;
- ItemClick -= MailItemClicked;
ProcessKeyboardAccelerators -= ProcessDelKey;
if (internalScrollviewer != null)
diff --git a/Wino.Mail/Controls/ImagePreviewControl.cs b/Wino.Mail/Controls/ImagePreviewControl.cs
index f8edd39f..344e1057 100644
--- a/Wino.Mail/Controls/ImagePreviewControl.cs
+++ b/Wino.Mail/Controls/ImagePreviewControl.cs
@@ -80,8 +80,6 @@ namespace Wino.Controls
control.UpdateInformation();
}
-
-
private async void UpdateInformation()
{
if (KnownHostImage == null || InitialsGrid == null || InitialsTextblock == null || (string.IsNullOrEmpty(FromName) && string.IsNullOrEmpty(FromAddress)))
diff --git a/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml b/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml
index 42e65bf8..d93700a5 100644
--- a/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml
+++ b/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml
@@ -2,10 +2,12 @@
x:Class="Wino.Controls.MailItemDisplayInformationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
xmlns:controls="using:Wino.Controls"
xmlns:domain="using:Wino.Core.Domain"
xmlns:enums="using:Wino.Core.Domain.Enums"
xmlns:helpers="using:Wino.Helpers"
+ xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
@@ -154,13 +156,29 @@
-
+
+
+
+
+
+
+
-
+
diff --git a/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml.cs b/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml.cs
index 4d1c9361..8d0cdd8c 100644
--- a/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml.cs
+++ b/Wino.Mail/Controls/MailItemDisplayInformationControl.xaml.cs
@@ -2,7 +2,6 @@
using System.Windows.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Input;
using Wino.Core.Domain.Entities;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.MailItem;
@@ -29,7 +28,7 @@ namespace Wino.Controls
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 IsThreadExpandedProperty = DependencyProperty.Register(nameof(IsThreadExpanded), typeof(bool), typeof(MailItemDisplayInformationControl), new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));
public bool IsThreadExpanded
{
@@ -85,7 +84,6 @@ namespace Wino.Controls
set { SetValue(RightHoverActionProperty, value); }
}
-
public WinoExpander ConnectedExpander
{
get { return (WinoExpander)GetValue(ConnectedExpanderProperty); }
@@ -122,8 +120,6 @@ namespace Wino.Controls
set { SetValue(DisplayModeProperty, value); }
}
- private bool tappedHandlingFlag = false;
-
public MailItemDisplayInformationControl()
{
this.InitializeComponent();
@@ -142,6 +138,20 @@ namespace Wino.Controls
RootContainerVisualWrapper.SizeChanged += (s, e) => leftBackgroundVisual.Size = e.NewSize.ToVector2();
}
+ private static void OnIsExpandedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
+ {
+ if (obj is MailItemDisplayInformationControl control)
+ {
+ control.AdjustRotation();
+ }
+ }
+
+ private void AdjustRotation()
+ {
+
+ // ExpanderChevronGrid.Rotation = IsThreadExpanded ? 45 : 0;
+ }
+
private void ControlPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if (IsHoverActionsEnabled)
@@ -169,29 +179,9 @@ namespace Wino.Controls
if (package == null) return;
- tappedHandlingFlag = true;
-
HoverActionExecutedCommand?.Execute(package);
}
- private void ThreadHeaderTapped(object sender, TappedRoutedEventArgs e)
- {
- // Due to CanDrag=True, outer expander doesn't get the click event and it doesn't expand. We expand here manually.
- // Also hover action button clicks will be delegated here after the execution runs.
- // We should not expand the thread if the reason we are here is for hover actions.
-
- //if (tappedHandlingFlag)
- //{
- // tappedHandlingFlag = false;
- // e.Handled = true;
- // return;
- //}
-
- //if (ConnectedExpander == null) return;
-
- //ConnectedExpander.IsExpanded = !ConnectedExpander.IsExpanded;
- }
-
private void FirstActionClicked(object sender, RoutedEventArgs e)
{
ExecuteHoverAction(LeftHoverAction);
diff --git a/Wino.Mail/Controls/WinoExpander.cs b/Wino.Mail/Controls/WinoExpander.cs
index 3254d9d9..cf24b5a8 100644
--- a/Wino.Mail/Controls/WinoExpander.cs
+++ b/Wino.Mail/Controls/WinoExpander.cs
@@ -1,5 +1,7 @@
-using Windows.UI.Xaml;
+using CommunityToolkit.Diagnostics;
+using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Hosting;
using Windows.UI.Xaml.Markup;
namespace Wino.Controls
@@ -7,15 +9,18 @@ namespace Wino.Controls
[ContentProperty(Name = nameof(Content))]
public class WinoExpander : Control
{
+ private const string PART_HeaderGrid = "HeaderGrid";
+ private const string PART_ContentAreaWrapper = "ContentAreaWrapper";
+ private const string PART_ContentArea = "ContentArea";
+
+ private ContentControl HeaderGrid;
+ private ContentControl ContentArea;
+ private Grid ContentAreaWrapper;
+
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(UIElement), typeof(WinoExpander), new PropertyMetadata(null));
public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(WinoExpander), new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));
-
- public bool IsExpanded
- {
- get { return (bool)GetValue(IsExpandedProperty); }
- set { SetValue(IsExpandedProperty, value); }
- }
+ public static readonly DependencyProperty TemplateSettingsProperty = DependencyProperty.Register(nameof(TemplateSettings), typeof(WinoExpanderTemplateSettings), typeof(WinoExpander), new PropertyMetadata(new WinoExpanderTemplateSettings()));
public UIElement Content
{
@@ -23,12 +28,54 @@ namespace Wino.Controls
set { SetValue(ContentProperty, value); }
}
+ public WinoExpanderTemplateSettings TemplateSettings
+ {
+ get { return (WinoExpanderTemplateSettings)GetValue(TemplateSettingsProperty); }
+ set { SetValue(TemplateSettingsProperty, value); }
+ }
+
+ public bool IsExpanded
+ {
+ get { return (bool)GetValue(IsExpandedProperty); }
+ set { SetValue(IsExpandedProperty, value); }
+ }
+
public UIElement Header
{
get { return (UIElement)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ HeaderGrid = GetTemplateChild(PART_HeaderGrid) as ContentControl;
+ ContentAreaWrapper = GetTemplateChild(PART_ContentAreaWrapper) as Grid;
+ ContentArea = GetTemplateChild(PART_ContentArea) as ContentControl;
+
+ Guard.IsNotNull(HeaderGrid, nameof(HeaderGrid));
+ Guard.IsNotNull(ContentAreaWrapper, nameof(ContentAreaWrapper));
+ Guard.IsNotNull(ContentArea, nameof(ContentArea));
+
+ var clipComposition = ElementCompositionPreview.GetElementVisual(ContentAreaWrapper);
+ clipComposition.Clip = clipComposition.Compositor.CreateInsetClip();
+
+ ContentAreaWrapper.SizeChanged += ContentSizeChanged;
+ HeaderGrid.Tapped += HeaderTapped;
+ }
+
+ private void ContentSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ TemplateSettings.ContentHeight = e.NewSize.Height;
+ TemplateSettings.NegativeContentHeight = -1 * (double)e.NewSize.Height;
+ }
+
+ private void HeaderTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
+ {
+ IsExpanded = !IsExpanded;
+ }
+
private static void OnIsExpandedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
if (obj is WinoExpander control)
@@ -40,4 +87,33 @@ namespace Wino.Controls
VisualStateManager.GoToState(this, IsExpanded ? "Expanded" : "Collapsed", true);
}
}
+
+ #region Settings
+
+ public class WinoExpanderTemplateSettings : DependencyObject
+ {
+ public static readonly DependencyProperty HeaderHeightProperty = DependencyProperty.Register(nameof(HeaderHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
+ public static readonly DependencyProperty ContentHeightProperty = DependencyProperty.Register(nameof(ContentHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
+ public static readonly DependencyProperty NegativeContentHeightProperty = DependencyProperty.Register(nameof(NegativeContentHeight), typeof(double), typeof(WinoExpanderTemplateSettings), new PropertyMetadata(0.0));
+
+ public double NegativeContentHeight
+ {
+ get { return (double)GetValue(NegativeContentHeightProperty); }
+ set { SetValue(NegativeContentHeightProperty, value); }
+ }
+
+ public double HeaderHeight
+ {
+ get { return (double)GetValue(HeaderHeightProperty); }
+ set { SetValue(HeaderHeightProperty, value); }
+ }
+
+ public double ContentHeight
+ {
+ get { return (double)GetValue(ContentHeightProperty); }
+ set { SetValue(ContentHeightProperty, value); }
+ }
+ }
+
+ #endregion
}
diff --git a/Wino.Mail/Styles/WinoExpanderStyle.xaml b/Wino.Mail/Styles/WinoExpanderStyle.xaml
index 73358147..0e455ff9 100644
--- a/Wino.Mail/Styles/WinoExpanderStyle.xaml
+++ b/Wino.Mail/Styles/WinoExpanderStyle.xaml
@@ -13,65 +13,68 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Background="{TemplateBinding Background}"
+ Content="{TemplateBinding Header}" />
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Wino.Mail/Styles/WinoExpanderStyle.xaml.cs b/Wino.Mail/Styles/WinoExpanderStyle.xaml.cs
index 817d086d..dd8a56fc 100644
--- a/Wino.Mail/Styles/WinoExpanderStyle.xaml.cs
+++ b/Wino.Mail/Styles/WinoExpanderStyle.xaml.cs
@@ -6,7 +6,7 @@ namespace Wino.Styles
{
public WinoExpanderStyle()
{
- this.InitializeComponent();
+ InitializeComponent();
}
}
}
diff --git a/Wino.Mail/Wino.Mail.csproj b/Wino.Mail/Wino.Mail.csproj
index 76655829..8d9e62e9 100644
--- a/Wino.Mail/Wino.Mail.csproj
+++ b/Wino.Mail/Wino.Mail.csproj
@@ -536,8 +536,8 @@
MSBuild:Compile
- Designer
MSBuild:Compile
+ Designer
Designer