Monthly calendar basics.
This commit is contained in:
87
Wino.Core.UWP/Controls/EqualGridPanel.cs
Normal file
87
Wino.Core.UWP/Controls/EqualGridPanel.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Wino.Core.UWP.Controls
|
||||
{
|
||||
public class EqualGridPanel : Panel
|
||||
{
|
||||
public int Rows
|
||||
{
|
||||
get { return (int)GetValue(RowsProperty); }
|
||||
set { SetValue(RowsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty RowsProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Rows),
|
||||
typeof(int),
|
||||
typeof(EqualGridPanel),
|
||||
new PropertyMetadata(1, OnLayoutPropertyChanged));
|
||||
|
||||
public int Columns
|
||||
{
|
||||
get { return (int)GetValue(ColumnsProperty); }
|
||||
set { SetValue(ColumnsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ColumnsProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Columns),
|
||||
typeof(int),
|
||||
typeof(EqualGridPanel),
|
||||
new PropertyMetadata(1, OnLayoutPropertyChanged));
|
||||
|
||||
private static void OnLayoutPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is EqualGridPanel panel)
|
||||
{
|
||||
panel.InvalidateMeasure();
|
||||
panel.InvalidateArrange();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
if (Rows <= 0 || Columns <= 0)
|
||||
{
|
||||
return new Size(0, 0);
|
||||
}
|
||||
|
||||
double cellWidth = availableSize.Width / Columns;
|
||||
double cellHeight = availableSize.Height / Rows;
|
||||
|
||||
foreach (UIElement child in Children)
|
||||
{
|
||||
child.Measure(new Size(cellWidth, cellHeight));
|
||||
}
|
||||
|
||||
return availableSize;
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
if (Rows <= 0 || Columns <= 0)
|
||||
{
|
||||
return new Size(0, 0);
|
||||
}
|
||||
|
||||
double cellWidth = finalSize.Width / Columns;
|
||||
double cellHeight = finalSize.Height / Rows;
|
||||
|
||||
for (int i = 0; i < Children.Count; i++)
|
||||
{
|
||||
int row = i / Columns;
|
||||
int column = i % Columns;
|
||||
|
||||
double x = column * cellWidth;
|
||||
double y = row * cellHeight;
|
||||
|
||||
Rect rect = new Rect(x, y, cellWidth, cellHeight);
|
||||
Children[i].Arrange(rect);
|
||||
}
|
||||
|
||||
return finalSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Wino.Core.UWP
|
||||
services.AddTransient(typeof(SettingOptionsPageViewModel));
|
||||
services.AddTransient(typeof(AboutPageViewModel));
|
||||
services.AddTransient(typeof(SettingsPageViewModel));
|
||||
services.AddTransient(typeof(NewAccountManagementPageViewModel));
|
||||
services.AddTransient(typeof(ManageAccountsPagePageViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@ namespace Wino.Helpers
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetColorFromHex(Color color) => color.ToHex();
|
||||
public static Color GetWindowsColorFromHex(string hex) => hex.ToColor();
|
||||
|
||||
public static SolidColorBrush GetSolidColorBrushFromHex(string colorHex) => string.IsNullOrEmpty(colorHex) ? new SolidColorBrush(Colors.Transparent) : new SolidColorBrush(colorHex.ToColor());
|
||||
public static Visibility IsSelectionModeMultiple(ListViewSelectionMode mode) => mode == ListViewSelectionMode.Multiple ? Visibility.Visible : Visibility.Collapsed;
|
||||
public static FontWeight GetFontWeightBySyncState(bool isSyncing) => isSyncing ? FontWeights.SemiBold : FontWeights.Normal;
|
||||
|
||||
@@ -11,6 +11,7 @@ using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Accounts;
|
||||
@@ -38,6 +39,18 @@ namespace Wino.Core.UWP.Services
|
||||
ApplicationResourceManager = applicationResourceManager;
|
||||
}
|
||||
|
||||
public async Task<MailAccount> ShowEditAccountDialogAsync(MailAccount account)
|
||||
{
|
||||
var editAccountDialog = new AccountEditDialog(account)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(editAccountDialog);
|
||||
|
||||
return editAccountDialog.IsSaved ? editAccountDialog.Account : null;
|
||||
}
|
||||
|
||||
public async Task<string> PickFilePathAsync(string saveFileName)
|
||||
{
|
||||
var picker = new FolderPicker()
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
</winuiControls:SettingsCard>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
|
||||
<!--#region Navigation Menu Templates-->
|
||||
|
||||
<!-- Manage Accounts etc. Other navigatable. -->
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Wino.Core.ViewModels;
|
||||
|
||||
namespace Wino.Core.UWP.Views.Abstract
|
||||
{
|
||||
public abstract class ManageAccountsPageAbstract : BasePage<ManageAccountsPagePageViewModel>
|
||||
{
|
||||
}
|
||||
}
|
||||
49
Wino.Core.UWP/Views/ManageAccountsPage.xaml
Normal file
49
Wino.Core.UWP/Views/ManageAccountsPage.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<abstract:ManageAccountsPageAbstract
|
||||
x:Class="Wino.Views.ManageAccountsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:abstract="using:Wino.Core.UWP.Views.Abstract"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:helpers="using:Wino.Helpers"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModelData="using:Wino.Mail.ViewModels.Data"
|
||||
xmlns:winuiControls="using:Microsoft.UI.Xaml.Controls"
|
||||
Style="{StaticResource PageStyle}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Border Style="{StaticResource PageRootBorderStyle}">
|
||||
<Grid
|
||||
MaxWidth="900"
|
||||
Padding="20"
|
||||
HorizontalAlignment="Stretch"
|
||||
RowSpacing="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<winuiControls:BreadcrumbBar
|
||||
x:Name="Breadcrumb"
|
||||
ItemClicked="BreadItemClicked"
|
||||
ItemsSource="{x:Bind PageHistory, Mode=OneWay}">
|
||||
<winuiControls:BreadcrumbBar.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<winuiControls:BreadcrumbBarItem Margin="0,0,8,0">
|
||||
<winuiControls:BreadcrumbBarItem.ContentTemplate>
|
||||
<DataTemplate x:DataType="viewModelData:BreadcrumbNavigationItemViewModel">
|
||||
<TextBlock
|
||||
Margin="0,0,8,10"
|
||||
FontWeight="{x:Bind helpers:XamlHelpers.GetFontWeightBySyncState(IsActive), Mode=OneWay}"
|
||||
Style="{StaticResource TitleTextBlockStyle}"
|
||||
Text="{Binding Title, Mode=OneWay}" />
|
||||
</DataTemplate>
|
||||
</winuiControls:BreadcrumbBarItem.ContentTemplate>
|
||||
</winuiControls:BreadcrumbBarItem>
|
||||
</DataTemplate>
|
||||
</winuiControls:BreadcrumbBar.ItemTemplate>
|
||||
</winuiControls:BreadcrumbBar>
|
||||
|
||||
<Frame x:Name="AccountPagesFrame" Grid.Row="1" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</abstract:ManageAccountsPageAbstract>
|
||||
102
Wino.Core.UWP/Views/ManageAccountsPage.xaml.cs
Normal file
102
Wino.Core.UWP/Views/ManageAccountsPage.xaml.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using MoreLinq;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.UWP.Views.Abstract;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
using Wino.Messaging.UI;
|
||||
|
||||
namespace Wino.Views
|
||||
{
|
||||
public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
IRecipient<BackBreadcrumNavigationRequested>,
|
||||
IRecipient<BreadcrumbNavigationRequested>,
|
||||
IRecipient<MergedInboxRenamed>
|
||||
{
|
||||
public ObservableCollection<BreadcrumbNavigationItemViewModel> PageHistory { get; set; } = new ObservableCollection<BreadcrumbNavigationItemViewModel>();
|
||||
|
||||
|
||||
public ManageAccountsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
var initialRequest = new BreadcrumbNavigationRequested(Translator.MenuManageAccounts, WinoPage.AccountManagementPage);
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true));
|
||||
|
||||
var accountManagementPageType = ViewModel.NavigationService.GetPageType(WinoPage.AccountManagementPage);
|
||||
|
||||
AccountPagesFrame.Navigate(accountManagementPageType, null, new SuppressNavigationTransitionInfo());
|
||||
}
|
||||
|
||||
|
||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
var pageType = ViewModel.NavigationService.GetPageType(message.PageType);
|
||||
|
||||
if (pageType == null) return;
|
||||
|
||||
AccountPagesFrame.Navigate(pageType, message.Parameter, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight });
|
||||
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(message, true));
|
||||
}
|
||||
|
||||
private void GoBackFrame()
|
||||
{
|
||||
if (AccountPagesFrame.CanGoBack)
|
||||
{
|
||||
PageHistory.RemoveAt(PageHistory.Count - 1);
|
||||
|
||||
AccountPagesFrame.GoBack(new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight });
|
||||
}
|
||||
}
|
||||
|
||||
private void BreadItemClicked(Microsoft.UI.Xaml.Controls.BreadcrumbBar sender, Microsoft.UI.Xaml.Controls.BreadcrumbBarItemClickedEventArgs args)
|
||||
{
|
||||
var clickedPageHistory = PageHistory[args.Index];
|
||||
|
||||
while (PageHistory.FirstOrDefault(a => a.IsActive) != clickedPageHistory)
|
||||
{
|
||||
AccountPagesFrame.GoBack(new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight });
|
||||
PageHistory.RemoveAt(PageHistory.Count - 1);
|
||||
PageHistory[PageHistory.Count - 1].IsActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(BackBreadcrumNavigationRequested message)
|
||||
{
|
||||
GoBackFrame();
|
||||
}
|
||||
|
||||
public void Receive(AccountUpdatedMessage message)
|
||||
{
|
||||
// TODO: Find better way to retrieve page history from the stack for the account.
|
||||
var activePage = PageHistory.LastOrDefault();
|
||||
|
||||
if (activePage == null) return;
|
||||
|
||||
activePage.Title = message.Account.Name;
|
||||
}
|
||||
|
||||
public void Receive(MergedInboxRenamed message)
|
||||
{
|
||||
// TODO: Find better way to retrieve page history from the stack for the merged account.
|
||||
var activePage = PageHistory.LastOrDefault();
|
||||
|
||||
if (activePage == null) return;
|
||||
|
||||
activePage.Title = message.NewName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@
|
||||
<Compile Include="BasePage.cs" />
|
||||
<Compile Include="Controls\ControlConstants.cs" />
|
||||
<Compile Include="Controls\CustomWrapPanel.cs" />
|
||||
<Compile Include="Controls\EqualGridPanel.cs" />
|
||||
<Compile Include="Controls\WinoAppTitleBar.xaml.cs">
|
||||
<DependentUpon>WinoAppTitleBar.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -166,9 +167,13 @@
|
||||
<Compile Include="Styles\DataTemplates.xaml.cs">
|
||||
<DependentUpon>DataTemplates.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Abstract\ManageAccountsPageAbstract.cs" />
|
||||
<Compile Include="Views\Abstract\SettingOptionsPageAbstract.cs" />
|
||||
<Compile Include="Views\Abstract\SettingsPageAbstract.cs" />
|
||||
<Compile Include="Views\Abstract\SettingsPageBase.cs" />
|
||||
<Compile Include="Views\ManageAccountsPage.xaml.cs">
|
||||
<DependentUpon>ManageAccountsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\SettingOptionsPage.xaml.cs">
|
||||
<DependentUpon>SettingOptionsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -400,6 +405,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\ManageAccountsPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\SettingOptionsPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
Reference in New Issue
Block a user