-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(progressbar): Added WinUI 2.3 ProgressBar first implementation.
- Loading branch information
1 parent
3427e7a
commit 195af14
Showing
10 changed files
with
907 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
...amplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressBar/WinUIProgressBarPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<Page | ||
x:Class="UITests.Microsoft_UI_Xaml_Controls.ProgressBar.WinUIProgressBarPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:converters="using:Uno.UI.Samples.Converters" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Page.Resources> | ||
<converters:FromNullableBoolToDefaultValueConverter x:Key="NullableBooleanToBooleanConverter"> | ||
<converters:FromNullableBoolToDefaultValueConverter.TrueValue> | ||
<x:Boolean>True</x:Boolean> | ||
</converters:FromNullableBoolToDefaultValueConverter.TrueValue> | ||
<converters:FromNullableBoolToDefaultValueConverter.NullOrFalseValue> | ||
<x:Boolean>False</x:Boolean> | ||
</converters:FromNullableBoolToDefaultValueConverter.NullOrFalseValue> | ||
</converters:FromNullableBoolToDefaultValueConverter> | ||
</Page.Resources> | ||
|
||
<Grid Margin="12"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
|
||
<StackPanel Grid.ColumnSpan="3" Orientation="Horizontal"> | ||
<TextBlock Text="Sample Progressbar"/> | ||
<FontIcon Glyph="" Margin="4,0,40,3" FontSize="14" VerticalAlignment="Center"/> | ||
<controls:ProgressBar | ||
x:Name="TestProgressBar" | ||
Width="100" | ||
VerticalAlignment="Center" | ||
AutomationProperties.Name="TestProgressBar" | ||
HorizontalAlignment="Left" | ||
IsIndeterminate="{x:Bind ShowIsDeterminateCheckBox.IsChecked, Converter={StaticResource NullableBooleanToBooleanConverter}, Mode=OneWay}" | ||
ShowPaused="{x:Bind ShowPausedCheckBox.IsChecked, Converter={StaticResource NullableBooleanToBooleanConverter}, Mode=OneWay}" | ||
ShowError="{x:Bind ShowErrorCheckBox.IsChecked, Converter={StaticResource NullableBooleanToBooleanConverter}, Mode=OneWay}"/> | ||
</StackPanel> | ||
|
||
<StackPanel Grid.Row="1"> | ||
<StackPanel> | ||
<TextBlock Text="Options"/> | ||
<Grid Width="300" HorizontalAlignment="Left"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBox x:Name="MaximumInput" AutomationProperties.Name="MaximumInput" Header="Maximum" PlaceholderText="100" Width="90" HorizontalAlignment="Left" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="MaximumInputText" AutomationProperties.Name="MaximumInputText" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Maximum, Mode=TwoWay}"/> | ||
|
||
<TextBox x:Name="MinimumInput" AutomationProperties.Name="MinimumInput" Header="Minimum" PlaceholderText="0" Width="90" HorizontalAlignment="Left" Grid.Row="1" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="MinimumInputText" AutomationProperties.Name="MinimumInputText" Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Minimum, Mode=TwoWay}"/> | ||
|
||
<TextBox x:Name="WidthInput" AutomationProperties.Name="WidthInput" Header="Width" PlaceholderText="0" Width="90" HorizontalAlignment="Left" Grid.Row="2" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="WidthInputText" AutomationProperties.Name="WidthInputText" Grid.Row="2" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Width, Mode=TwoWay}"/> | ||
|
||
<TextBox x:Name="ValueInput" AutomationProperties.Name="ValueInput" Header="Value" PlaceholderText="0" Width="90" HorizontalAlignment="Left" Grid.Row="3" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="ValueText" AutomationProperties.Name="ValueText" Grid.Row="3" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Value, Mode=TwoWay}"/> | ||
</Grid> | ||
|
||
<TextBlock Text="Padding" Margin="0, 20, 0, 10"/> | ||
|
||
<Grid Width="300" HorizontalAlignment="Left"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="1*" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBox x:Name="PaddingLeftInput" AutomationProperties.Name="PaddingLeftInput" Header="Left" PlaceholderText="0" Width="90" HorizontalAlignment="Left" Grid.Row="1" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="PaddingLeftText" AutomationProperties.Name="PaddingLeftText" Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Padding.Left, Mode=TwoWay}"/> | ||
|
||
<TextBox x:Name="PaddingRightInput" AutomationProperties.Name="PaddingRightInput" Header="Right" PlaceholderText="0" Width="90" HorizontalAlignment="Left" Grid.Row="2" Grid.ColumnSpan="1"/> | ||
<TextBlock x:Name="PaddingRightText" AutomationProperties.Name="PaddingRightText" Grid.Row="2" Grid.Column="1" Text="{Binding ElementName=TestProgressBar, Path=Padding.Right, Mode=TwoWay}"/> | ||
|
||
</Grid> | ||
<TextBlock Text="States"/> | ||
<CheckBox x:Name="ShowPausedCheckBox" AutomationProperties.Name="ShowPausedCheckBox" Content="ShowPaused" /> | ||
<CheckBox x:Name="ShowErrorCheckBox" AutomationProperties.Name="ShowErrorCheckBox" Content="ShowError"/> | ||
<CheckBox x:Name="ShowIsDeterminateCheckBox" AutomationProperties.Name="ShowIsDeterminateCheckBox" Content="IsDeterminate"/> | ||
</StackPanel> | ||
|
||
<StackPanel Margin="0,16,0,0"> | ||
<TextBlock Text="Actions"/> | ||
<Button x:Name="UpdateMinMaxButton" AutomationProperties.Name="UpdateMinMaxButton" Content="Update Min and Max" Click="UpdateMinMax_Click"/> | ||
<Button x:Name="UpdateWidthButton" AutomationProperties.Name="UpdateWidthButton" Content="Update Width" Click="UpdateWidth_Click"/> | ||
<Button x:Name="UpdateValueButton" AutomationProperties.Name="UpdateValueButton" Content="Update Value" Click="UpdateValue_Click"/> | ||
<RepeatButton x:Name="ChangeValueButton" AutomationProperties.Name="ChangeValueButton" Content="Hold and Change Value" Click="ChangeValue_Click" /> | ||
<Button x:Name="UpdatePaddingButton" AutomationProperties.Name="UpdatePaddingButton" Content="Update Padding Left and Right" Click="UpdatePadding_Click"/> | ||
</StackPanel> | ||
|
||
</StackPanel> | ||
|
||
<StackPanel Grid.Column="1" Grid.Row="1" Margin="16,0,0,0"> | ||
<TextBlock Text="Properties" /> | ||
|
||
<TextBlock Text="Indicator Width" Margin="0, 20, 0, 0"/> | ||
<TextBlock x:Name="IndicatorWidthText" AutomationProperties.Name="IndicatorWidthText" Margin="0, 0, 0, 20"/> | ||
|
||
<TextBlock Text="Is paused:" Margin="0, 20, 0, 0" FontSize="20"/> | ||
<TextBlock AutomationProperties.Name="ShowPausedText" Text="{x:Bind ShowPausedCheckBox.IsChecked, Mode=OneWay}"/> | ||
|
||
<TextBlock Text="Is error:" Margin="0, 20, 0, 0" FontSize="20"/> | ||
<TextBlock AutomationProperties.Name="ShowErrorText" Text="{x:Bind ShowErrorCheckBox.IsChecked, Mode=OneWay}"/> | ||
|
||
<TextBlock Text="Is indeterminate:" Margin="0, 20, 0, 0" FontSize="20"/> | ||
<TextBlock AutomationProperties.Name="ShowIsDeterminateText" Text="{x:Bind ShowIsDeterminateCheckBox.IsChecked, Mode=OneWay}"/> | ||
|
||
<TextBlock x:Name="VisualStateText" AutomationProperties.Name="VisualStateText" Margin="0, 20, 0, 0"/> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
100 changes: 100 additions & 0 deletions
100
...lesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressBar/WinUIProgressBarPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Media; | ||
using Uno.UI.Samples.Controls; | ||
using Windows.UI.Xaml.Shapes; | ||
|
||
namespace UITests.Microsoft_UI_Xaml_Controls.ProgressBar | ||
{ | ||
[Sample("ProgressBar", "WinUI")] | ||
public sealed partial class WinUIProgressBarPage : Page | ||
{ | ||
public WinUIProgressBarPage() | ||
{ | ||
this.InitializeComponent(); | ||
Loaded += ProgressBarPage_Loaded; | ||
} | ||
|
||
private void ProgressBarPage_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
var layoutRoot = (Grid)VisualTreeHelper.GetChild(TestProgressBar, 0); | ||
|
||
VisualStateManager.GetVisualStateGroups(layoutRoot)[0].CurrentStateChanged += this.ProgressBarPage_CurrentStateChanged; | ||
VisualStateText.Text = VisualStateManager.GetVisualStateGroups(layoutRoot)[0].CurrentState.Name; | ||
|
||
var progressBarRoot = VisualTreeHelper.GetChild(layoutRoot, 0); | ||
var clip = VisualTreeHelper.GetChild(progressBarRoot, 0); | ||
var stackPanel = VisualTreeHelper.GetChild(clip, 0); | ||
var indicator = (Rectangle)VisualTreeHelper.GetChild(stackPanel, 0); | ||
|
||
if (indicator != null) | ||
{ | ||
indicator.SizeChanged += this.Indicator_SizeChanged; | ||
IndicatorWidthText.Text = indicator.ActualWidth.ToString(); | ||
} | ||
|
||
Loaded -= ProgressBarPage_Loaded; | ||
} | ||
|
||
private void Indicator_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
IndicatorWidthText.Text = ((Rectangle)sender).ActualWidth.ToString(); | ||
} | ||
|
||
private void ProgressBarPage_CurrentStateChanged(object sender, VisualStateChangedEventArgs e) | ||
{ | ||
VisualStateText.Text = e.NewState.Name; | ||
} | ||
|
||
public void UpdateMinMax_Click(object sender, RoutedEventArgs e) | ||
{ | ||
TestProgressBar.Maximum = String.IsNullOrEmpty(MaximumInput.Text) ? Double.Parse(MaximumInput.PlaceholderText) : Double.Parse(MaximumInput.Text); | ||
TestProgressBar.Minimum = String.IsNullOrEmpty(MinimumInput.Text) ? Double.Parse(MinimumInput.PlaceholderText) : Double.Parse(MinimumInput.Text); | ||
} | ||
|
||
public void UpdateWidth_Click(object sender, RoutedEventArgs e) | ||
{ | ||
TestProgressBar.Width = String.IsNullOrEmpty(WidthInput.Text) ? Double.Parse(WidthInput.PlaceholderText) : Double.Parse(WidthInput.Text); | ||
} | ||
|
||
public void UpdateValue_Click(object sender, RoutedEventArgs e) | ||
{ | ||
TestProgressBar.Value = String.IsNullOrEmpty(ValueInput.Text) ? Double.Parse(ValueInput.PlaceholderText) : Double.Parse(ValueInput.Text); | ||
} | ||
|
||
public void ChangeValue_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (TestProgressBar.Value + 1 > TestProgressBar.Maximum) | ||
{ | ||
TestProgressBar.Value = (int)(TestProgressBar.Minimum + 0.5); | ||
} | ||
else | ||
{ | ||
TestProgressBar.Value += 1; | ||
} | ||
} | ||
|
||
public void UpdatePadding_Click(object sender, RoutedEventArgs e) | ||
{ | ||
double paddingLeft = String.IsNullOrEmpty(PaddingLeftInput.Text) ? Double.Parse(PaddingLeftInput.PlaceholderText) : Double.Parse(PaddingLeftInput.Text); | ||
double paddingRight = String.IsNullOrEmpty(PaddingRightInput.Text) ? Double.Parse(PaddingRightInput.PlaceholderText) : Double.Parse(PaddingRightInput.Text); | ||
|
||
TestProgressBar.Padding = new Thickness(paddingLeft, 0, paddingRight, 0); | ||
} | ||
} | ||
|
||
public class NullableBooleanToBooleanConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
return value is bool ? (bool)value : (object)false; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
{ | ||
return value is bool ? (bool)value : (object)false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.