Skip to content

Commit

Permalink
feat: WinUI PagerControl
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 29, 2021
1 parent 723ea79 commit 76cdc72
Show file tree
Hide file tree
Showing 12 changed files with 1,154 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
xmlns:local="using:UITests.Microsoft_UI_Xaml_Controls.PagerControlTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
xmlns:Windows10FallCreatorsUpdate="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 5)"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="12">
Expand Down
7 changes: 7 additions & 0 deletions src/Uno.UI/Helpers/WinUI/ResourceAccessor.ResourceKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ internal partial class ResourceAccessor
public const string SR_DefaultItemString = "DefaultItemString";
public const string SR_DropIntoNodeString = "DropIntoNodeString";
public const string SR_FallBackPlaceString = "FallBackPlaceString";
public const string SR_PagerControlPageTextName = "PagerControlPageText";
public const string SR_PagerControlPrefixTextName = "PagerControlPrefixText";
public const string SR_PagerControlSuffixTextName = "PagerControlPrefixText";
public const string SR_PagerControlFirstPageButtonTextName = "PagerControlFirstPageButtonText";
public const string SR_PagerControlPreviousPageButtonTextName = "PagerControlPreviousPageButtonText";
public const string SR_PagerControlNextPageButtonTextName = "PagerControlNextPageButtonText";
public const string SR_PagerControlLastPageButtonTextName = "PagerControlLastPageButtonText";
public const string SR_PlaceAfterString = "PlaceAfterString";
public const string SR_PlaceBeforeString = "PlaceBeforeString";
public const string SR_PlaceBetweenString = "PlaceBetweenString";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// MUX reference PagerControl.cpp.h, commit a08f765
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Uno.Disposables;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Microsoft.UI.Xaml.Controls
{
public partial class PagerControl
{
private int m_lastSelectedPageIndex = -1;
private int m_lastNumberOfPagesCount = 0;

private ComboBox m_comboBox;
private NumberBox m_numberBox;
private ItemsRepeater m_numberPanelRepeater;
private FrameworkElement m_selectedPageIndicator;

private SerialDisposable m_rootGridKeyDownRevoker = new SerialDisposable();
private SerialDisposable m_comboBoxSelectionChangedRevoker = new SerialDisposable();
private SerialDisposable m_numberBoxValueChangedRevoker = new SerialDisposable();
private SerialDisposable m_firstPageButtonClickRevoker = new SerialDisposable();
private SerialDisposable m_previousPageButtonClickRevoker = new SerialDisposable();
private SerialDisposable m_nextPageButtonClickRevoker = new SerialDisposable();
private SerialDisposable m_lastPageButtonClickRevoker = new SerialDisposable();

IObservableVector<object> m_comboBoxEntries;
IObservableVector<object> m_numberPanelElements;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// MUX reference PagerControl.properties.cpp, commit a08f765
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Windows.Input;
using Windows.Foundation;
using Windows.UI.Xaml;

namespace Microsoft.UI.Xaml.Controls
{
public partial class PagerControl
{
public bool ButtonPanelAlwaysShowFirstLastPageIndex
{
get => (bool)GetValue(ButtonPanelAlwaysShowFirstLastPageIndexProperty);
set => SetValue(ButtonPanelAlwaysShowFirstLastPageIndexProperty, value);
}

public static DependencyProperty ButtonPanelAlwaysShowFirstLastPageIndexProperty { get; } =
DependencyProperty.Register(nameof(ButtonPanelAlwaysShowFirstLastPageIndex), typeof(bool), typeof(PagerControl), new PropertyMetadata(true, OnPropertyChanged));

public PagerControlDisplayMode DisplayMode
{
get => (PagerControlDisplayMode)GetValue(DisplayModeProperty);
set => SetValue(DisplayModeProperty, value);
}

public static DependencyProperty DisplayModeProperty { get; } =
DependencyProperty.Register(nameof(DisplayMode), typeof(PagerControlDisplayMode), typeof(PagerControl), new PropertyMetadata(default(PagerControlDisplayMode), OnPropertyChanged));

public ICommand FirstButtonCommand
{
get => (ICommand)GetValue(FirstButtonCommandProperty);
set => SetValue(FirstButtonCommandProperty, value);
}

public static DependencyProperty FirstButtonCommandProperty { get; } =
DependencyProperty.Register(nameof(FirstButtonCommand), typeof(ICommand), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));
public Style FirstButtonStyle
{
get => (Style)GetValue(FirstButtonStyleProperty);
set => SetValue(FirstButtonStyleProperty, value);
}

public static DependencyProperty FirstButtonStyleProperty { get; } =
DependencyProperty.Register(nameof(FirstButtonStyle), typeof(Style), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));
public PagerControlButtonVisibility FirstButtonVisibility
{
get => (PagerControlButtonVisibility)GetValue(FirstButtonVisibilityProperty);
set => SetValue(FirstButtonVisibilityProperty, value);
}

public static DependencyProperty FirstButtonVisibilityProperty { get; } =
DependencyProperty.Register(nameof(FirstButtonVisibility), typeof(PagerControlButtonVisibility), typeof(PagerControl), new PropertyMetadata(default(PagerControlButtonVisibility), OnPropertyChanged));

public ICommand LastButtonCommand
{
get => (ICommand)GetValue(LastButtonCommandProperty);
set => SetValue(LastButtonCommandProperty, value);
}

public static DependencyProperty LastButtonCommandProperty { get; } =
DependencyProperty.Register(nameof(LastButtonCommand), typeof(ICommand), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public Style LastButtonStyle
{
get => (Style)GetValue(LastButtonStyleProperty);
set => SetValue(LastButtonStyleProperty, value);
}

public static DependencyProperty LastButtonStyleProperty { get; } =
DependencyProperty.Register(nameof(LastButtonStyle), typeof(Style), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public PagerControlButtonVisibility LastButtonVisibility
{
get => (PagerControlButtonVisibility)GetValue(LastButtonVisibilityProperty);
set => SetValue(LastButtonVisibilityProperty, value);
}

public static DependencyProperty LastButtonVisibilityProperty { get; } =
DependencyProperty.Register(nameof(LastButtonVisibility), typeof(PagerControlButtonVisibility), typeof(PagerControl), new PropertyMetadata(default(PagerControlButtonVisibility), OnPropertyChanged));

public ICommand NextButtonCommand
{
get => (ICommand)GetValue(NextButtonCommandProperty);
set => SetValue(NextButtonCommandProperty, value);
}

public static DependencyProperty NextButtonCommandProperty { get; } =
DependencyProperty.Register(nameof(NextButtonCommand), typeof(ICommand), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public Style NextButtonStyle
{
get => (Style)GetValue(NextButtonStyleProperty);
set => SetValue(NextButtonStyleProperty, value);
}

public static DependencyProperty NextButtonStyleProperty { get; } =
DependencyProperty.Register(nameof(NextButtonStyle), typeof(Style), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public PagerControlButtonVisibility NextButtonVisibility
{
get => (PagerControlButtonVisibility)GetValue(NextButtonVisibilityProperty);
set => SetValue(NextButtonVisibilityProperty, value);
}

public static DependencyProperty NextButtonVisibilityProperty { get; } =
DependencyProperty.Register(nameof(NextButtonVisibility), typeof(PagerControlButtonVisibility), typeof(PagerControl), new PropertyMetadata(default(PagerControlButtonVisibility), OnPropertyChanged));

public int NumberOfPages
{
get => (int)GetValue(NumberOfPagesProperty);
set => SetValue(NumberOfPagesProperty, value);
}

public static DependencyProperty NumberOfPagesProperty { get; } =
DependencyProperty.Register(nameof(NumberOfPages), typeof(int), typeof(PagerControl), new PropertyMetadata(0, OnPropertyChanged));

public string PrefixText
{
get => (string)GetValue(PrefixTextProperty);
set => SetValue(PrefixTextProperty, value);
}

public static DependencyProperty PrefixTextProperty { get; } =
DependencyProperty.Register(nameof(PrefixText), typeof(string), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public ICommand PreviousButtonCommand
{
get => (ICommand)GetValue(PreviousButtonCommandProperty);
set => SetValue(PreviousButtonCommandProperty, value);
}

public static DependencyProperty PreviousButtonCommandProperty { get; } =
DependencyProperty.Register(nameof(PreviousButtonCommand), typeof(ICommand), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public Style PreviousButtonStyle
{
get => (Style)GetValue(PreviousButtonStyleProperty);
set => SetValue(PreviousButtonStyleProperty, value);
}

public static DependencyProperty PreviousButtonStyleProperty { get; } =
DependencyProperty.Register(nameof(PreviousButtonStyle), typeof(Style), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public PagerControlButtonVisibility PreviousButtonVisibility
{
get => (PagerControlButtonVisibility)GetValue(PreviousButtonVisibilityProperty);
set => SetValue(PreviousButtonVisibilityProperty, value);
}

public static DependencyProperty PreviousButtonVisibilityProperty { get; } =
DependencyProperty.Register(nameof(PreviousButtonVisibility), typeof(PagerControlButtonVisibility), typeof(PagerControl), new PropertyMetadata(default(PagerControlButtonVisibility), OnPropertyChanged));

public int SelectedPageIndex
{
get => (int)GetValue(SelectedPageIndexProperty);
set => SetValue(SelectedPageIndexProperty, value);
}

public static DependencyProperty SelectedPageIndexProperty { get; } =
DependencyProperty.Register(nameof(SelectedPageIndex), typeof(int), typeof(PagerControl), new PropertyMetadata(0, OnPropertyChanged));

public string SuffixText
{
get => (string)GetValue(SuffixTextProperty);
set => SetValue(SuffixTextProperty, value);
}

public static DependencyProperty SuffixTextProperty { get; } =
DependencyProperty.Register(nameof(SuffixText), typeof(string), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

public PagerControlTemplateSettings TemplateSettings
{
get => (PagerControlTemplateSettings)GetValue(TemplateSettingsProperty);
set => SetValue(TemplateSettingsProperty, value);
}

public static DependencyProperty TemplateSettingsProperty { get; } =
DependencyProperty.Register(nameof(TemplateSettings), typeof(PagerControlTemplateSettings), typeof(PagerControl), new PropertyMetadata(null, OnPropertyChanged));

private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
var owner = (PagerControl)sender;
owner.OnPropertyChanged(args);
}

public event TypedEventHandler<PagerControl, PagerControlSelectedIndexChangedEventArgs> SelectedIndexChanged;
}
}
Loading

0 comments on commit 76cdc72

Please sign in to comment.