-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Shapes): Match UWP StrokeThickness behaviour
- Loading branch information
Showing
12 changed files
with
312 additions
and
19 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
122 changes: 122 additions & 0 deletions
122
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Shapes_Default_StrokeThickness.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,122 @@ | ||
<UserControl x:Class="UITests.Windows_UI_Xaml_Shapes.Shapes_Default_StrokeThickness" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Shapes" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:uc="using:Uno.UI.Samples.Converters" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
<UserControl.Resources> | ||
<uc:FromNullableBoolToVisibilityConverter x:Key="FromNullableBoolToVisibilityConverter" | ||
VisibilityIfTrue="Visible" /> | ||
</UserControl.Resources> | ||
<StackPanel Margin="20" | ||
HorizontalAlignment="Center"> | ||
<StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<RadioButton Content="MyLine" | ||
x:Name="MyLineSelector" | ||
GroupName="ShapeSelector" /> | ||
<RadioButton Content="MyRect" | ||
x:Name="MyRectSelector" | ||
GroupName="ShapeSelector" /> | ||
<RadioButton Content="MyPolyline" | ||
x:Name="MyPolylineSelector" | ||
GroupName="ShapeSelector" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<RadioButton Content="MyPolygon" | ||
x:Name="MyPolygonSelector" | ||
GroupName="ShapeSelector" /> | ||
<RadioButton Content="MyEllipse" | ||
x:Name="MyEllipseSelector" | ||
GroupName="ShapeSelector" /> | ||
<RadioButton Content="MyPath" | ||
x:Name="MyPathSelector" | ||
GroupName="ShapeSelector" /> | ||
</StackPanel> | ||
<Button x:Name="StrokeThicknessButton" | ||
Content="Set StrokeThickness" /> | ||
</StackPanel> | ||
|
||
<Grid BorderBrush="HotPink" | ||
BorderThickness="1" | ||
Background="White" | ||
Width="300" | ||
Height="300" | ||
x:Name="TestZone"> | ||
<Grid x:Name="MyLineGrid" | ||
Height="10" | ||
Width="100" | ||
Visibility="{Binding IsChecked, ElementName=MyLineSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Line X1="0" | ||
Y1="5" | ||
X2="100" | ||
Y2="5" | ||
x:Name="MyLine" | ||
Stroke="Red" /> | ||
<Border BorderBrush="Green" | ||
BorderThickness="1" | ||
x:Name="MyLineTarget" | ||
Height="10" | ||
Width="10" /> | ||
</Grid> | ||
<Grid x:Name="MyRectGrid" | ||
Width="100" | ||
Height="100" | ||
Visibility="{Binding IsChecked, ElementName=MyRectSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Rectangle Fill="Blue" | ||
Width="100" | ||
x:Name="MyRect" | ||
Stroke="Red" | ||
Height="100" /> | ||
</Grid> | ||
<Grid x:Name="MyPolylineGrid" | ||
Width="101" | ||
Height="101" | ||
Visibility="{Binding IsChecked, ElementName=MyPolylineSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Polyline Points="2,2, 100,2, 100,100, 2,100, 2,2" | ||
|
||
x:Name="MyPolyline" | ||
Stroke="Red"/> | ||
</Grid> | ||
|
||
<Grid x:Name="MyPolygonGrid" | ||
Width="101" | ||
Height="101" | ||
Visibility="{Binding IsChecked, ElementName=MyPolygonSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Polygon | ||
Stroke="Red" | ||
x:Name="MyPolygon" | ||
Points="2,2, 100,2, 100,100, 2,100, 2,2"/> | ||
</Grid> | ||
|
||
<Grid x:Name="MyEllipseGrid" | ||
Width="100" | ||
Height="100" | ||
Visibility="{Binding IsChecked, ElementName=MyEllipseSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Ellipse | ||
x:Name="MyEllipse" | ||
Stroke="Red" | ||
Height="100" | ||
Width="100" /> | ||
</Grid> | ||
|
||
<Grid x:Name="MyPathGrid" | ||
Visibility="{Binding IsChecked, ElementName=MyPathSelector, Converter={StaticResource FromNullableBoolToVisibilityConverter}}"> | ||
<Path Stroke="Red" | ||
x:Name="MyPath" | ||
Data="M 10,100 C 10,300 100,-200 300,100" /> | ||
<Border BorderBrush="Green" | ||
BorderThickness="1" | ||
x:Name="MyPathTarget" | ||
HorizontalAlignment="Left" | ||
Margin="20, -3, 0, 0" | ||
Width="3" | ||
Height="3" /> | ||
</Grid> | ||
</Grid> | ||
</StackPanel> | ||
</UserControl> |
60 changes: 60 additions & 0 deletions
60
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Shapes_Default_StrokeThickness.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,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Uno.UI.Samples.Controls; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
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; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace UITests.Windows_UI_Xaml_Shapes | ||
{ | ||
[Sample("Shapes", "Default_StrokeThickness")] | ||
public sealed partial class Shapes_Default_StrokeThickness : UserControl | ||
{ | ||
public double MyStrokeThickness { get; set; } = 0d; | ||
|
||
public Shapes_Default_StrokeThickness() | ||
{ | ||
this.InitializeComponent(); | ||
StrokeThicknessButton.Click += StrokeThicknessButton_Click; | ||
} | ||
|
||
private void StrokeThicknessButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (MyLineSelector.IsChecked ?? false) | ||
{ | ||
MyLine.StrokeThickness = MyStrokeThickness; | ||
} | ||
if (MyRectSelector.IsChecked ?? false) | ||
{ | ||
MyRect.StrokeThickness = MyStrokeThickness; | ||
} | ||
if (MyPolylineSelector.IsChecked ?? false) | ||
{ | ||
MyPolyline.StrokeThickness = MyStrokeThickness; | ||
} | ||
if (MyPolygonSelector.IsChecked ?? false) | ||
{ | ||
MyPolygon.StrokeThickness = MyStrokeThickness; | ||
} | ||
if (MyEllipseSelector.IsChecked ?? false) | ||
{ | ||
MyEllipse.StrokeThickness = MyStrokeThickness; | ||
} | ||
if (MyPathSelector.IsChecked ?? false) | ||
{ | ||
MyPath.StrokeThickness = MyStrokeThickness; | ||
} | ||
} | ||
} | ||
} |
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
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
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.