Skip to content

Commit

Permalink
chore: Further updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Apr 15, 2024
1 parent 0e92ec6 commit f79633b
Show file tree
Hide file tree
Showing 10 changed files with 766 additions and 2,473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,47 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Uno.UI.Samples.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

#if false
using MUXControlsTestHooks = Microsoft.UI.Private.Controls.MUXControlsTestHooks;
#endif

namespace MUXControlsTestApp
namespace MUXControlsTestApp;

[Sample("CommandBarFlyout", "WinUI")]
public sealed partial class CommandBarFlyoutMainPage : TestPage
{
[Sample("CommandBarFlyout", "WinUI")]
public sealed partial class CommandBarFlyoutMainPage : TestPage
{
public CommandBarFlyoutMainPage()
{
this.InitializeComponent();
}
public CommandBarFlyoutMainPage()
{
this.InitializeComponent();
}

public void OnCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(CommandBarFlyoutPage), "CommandBarFlyout Tests");
}
public void OnCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(CommandBarFlyoutPage), "CommandBarFlyout Tests");
}

public void OnTextCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(TextCommandBarFlyoutPage), "TextCommandBarFlyout Tests");
}
public void OnTextCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(TextCommandBarFlyoutPage), "TextCommandBarFlyout Tests");
}

public void OnExtraCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(ExtraCommandBarFlyoutPage), "Extra CommandBarFlyout Tests");
}
private void CmbCommandBarFlyoutOutputDebugStringLevel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
public void OnExtraCommandBarFlyoutTestsClicked(object sender, object args)
{
var rootFrame = Window.Current.Content as Frame;
rootFrame.NavigateWithoutAnimation(typeof(ExtraCommandBarFlyoutPage), "Extra CommandBarFlyout Tests");
}
private void CmbCommandBarFlyoutOutputDebugStringLevel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
#if false
MUXControlsTestHooks.SetOutputDebugStringLevelForType(
"CommandBarFlyout",
cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 1 || cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 2,
cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 2);
MUXControlsTestHooks.SetOutputDebugStringLevelForType(
"CommandBarFlyout",
cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 1 || cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 2,
cmbCommandBarFlyoutOutputDebugStringLevel.SelectedIndex == 2);
#endif
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,102 +11,102 @@
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Foundation.Metadata;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

namespace MUXControlsTestApp
namespace MUXControlsTestApp;

[Sample("CommandBarFlyout", "WinUI")]
public sealed partial class ExtraCommandBarFlyoutPage : TestPage
{
[Sample("CommandBarFlyout", "WinUI")]
public sealed partial class ExtraCommandBarFlyoutPage : TestPage
{
private int customButtonsFlyoutOpenCount = 0;
private int customButtonsFlyoutOpenCount = 0;

public ExtraCommandBarFlyoutPage()
{
this.InitializeComponent();
public ExtraCommandBarFlyoutPage()
{
this.InitializeComponent();

if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedLeft"))
{
TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft;
}
else
{
TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.Top;
}
if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedLeft"))
{
TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft;
}
else
{
TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.Top;
}

if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft"))
{
TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft;
}
else
{
TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.Top;
}
if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft"))
{
TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft;
}
else
{
TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.Top;
}

if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout"))
{
TextBox1.ContextFlyout = TextCommandBarContextFlyout;
RichTextBlock1.ContextFlyout = TextCommandBarContextFlyout;
}
if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout"))
{
TextBox1.ContextFlyout = TextCommandBarContextFlyout;
RichTextBlock1.ContextFlyout = TextCommandBarContextFlyout;
}

try
{
if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBox", "SelectionFlyout"))
{
TextBox1.SelectionFlyout = TextCommandBarSelectionFlyout;
}
}
catch (InvalidCastException)
{
// RS5 interfaces can change before release, so we need to make sure we don't crash if they do.
}
try
{
if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBox", "SelectionFlyout"))
{
TextBox1.SelectionFlyout = TextCommandBarSelectionFlyout;
}
}
catch (InvalidCastException)
{
// RS5 interfaces can change before release, so we need to make sure we don't crash if they do.
}

if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichTextBlock", "SelectionFlyout"))
{
RichTextBlock1.SelectionFlyout = TextCommandBarSelectionFlyout;
}
}
if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichTextBlock", "SelectionFlyout"))
{
RichTextBlock1.SelectionFlyout = TextCommandBarSelectionFlyout;
}
}

private void OnClearClipboardContentsClicked(object sender, object args)
{
Clipboard.Clear();
}
private void OnClearClipboardContentsClicked(object sender, object args)
{
Clipboard.Clear();
}

private void OnCountPopupsClicked(object sender, object args)
{
PopupCountTextBox.Text = VisualTreeHelper.GetOpenPopups(Window.Current).Count.ToString();
CustomButtonsOpenCount.Text = customButtonsFlyoutOpenCount.ToString();
}
private void OnCountPopupsClicked(object sender, object args)
{
PopupCountTextBox.Text = VisualTreeHelper.GetOpenPopups(Window.Current).Count.ToString();
CustomButtonsOpenCount.Text = customButtonsFlyoutOpenCount.ToString();
}

private void tbloaded(object sender, RoutedEventArgs e)
{
tb.ContextFlyout = new Microsoft.UI.Xaml.Controls.TextCommandBarFlyout();
tb.ContextFlyout.Opening += ContextFlyout_Opening;
tb.ContextFlyout.Closed += ContextFlyout_Closed;
}
private void tbloaded(object sender, RoutedEventArgs e)
{
tb.ContextFlyout = new Microsoft.UI.Xaml.Controls.TextCommandBarFlyout();
tb.ContextFlyout.Opening += ContextFlyout_Opening;
tb.ContextFlyout.Closed += ContextFlyout_Closed;
}

private void tbunloaded(object sender, RoutedEventArgs e)
{
tb.ContextFlyout.Opening -= ContextFlyout_Opening;
}
private void tbunloaded(object sender, RoutedEventArgs e)
{
tb.ContextFlyout.Opening -= ContextFlyout_Opening;
}

private void ContextFlyout_Opening(object sender, object e)
{
customButtonsFlyoutOpenCount++;
var flyout = (sender as Microsoft.UI.Xaml.Controls.TextCommandBarFlyout);
flyout.PrimaryCommands.Add(new AppBarButton() {
Content = new TextBlock() { Text = "Test" }
});
}
private void ContextFlyout_Opening(object sender, object e)
{
customButtonsFlyoutOpenCount++;
var flyout = (sender as Microsoft.UI.Xaml.Controls.TextCommandBarFlyout);
flyout.PrimaryCommands.Add(new AppBarButton()
{
Content = new TextBlock() { Text = "Test" }
});
}

private void ContextFlyout_Closed(object sender, object e)
{
customButtonsFlyoutOpenCount--;
}
}
private void ContextFlyout_Closed(object sender, object e)
{
customButtonsFlyoutOpenCount--;
}
}
Loading

0 comments on commit f79633b

Please sign in to comment.