-
Notifications
You must be signed in to change notification settings - Fork 328
Add new scenarios to Input sample (PointerTracking, PointerPointProperties, DeviceCapabilities, XamlManipulations) #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qiutongMS
wants to merge
4
commits into
release/experimental
Choose a base branch
from
user/qiutongshen/add-input-scenarios
base: release/experimental
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,25 @@ | ||
| <!-- Copyright (c) Microsoft Corporation. | ||
| Licensed under the MIT License. --> | ||
| <Page | ||
| x:Class="Input.DeviceCapabilities" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <ScrollViewer VerticalScrollMode="Auto" VerticalScrollBarVisibility="Auto"> | ||
| <StackPanel Margin="12,10,12,12"> | ||
| <TextBlock Text="Description:" Style="{StaticResource SubtitleTextBlockStyle}"/> | ||
| <TextBlock Style="{StaticResource BodyTextBlockStyle}" TextWrapping="Wrap" Margin="0,8,0,0"> | ||
| This scenario demonstrates how to use the KeyboardCapabilities, MouseCapabilities, and TouchCapabilities classes to determine what type of input the current device an app is running on supports. | ||
| </TextBlock> | ||
| <TextBlock x:Name="keyboardHeader" Text="Keyboard Properties" Style="{StaticResource SubtitleTextBlockStyle}" Padding="0,12,0,0"/> | ||
| <TextBlock x:Name="keyboardText"/> | ||
| <TextBlock x:Name="mouseHeader" Text="Mouse Properties" Style="{StaticResource SubtitleTextBlockStyle}" Padding="0,12,0,0"/> | ||
| <TextBlock x:Name="mouseText"/> | ||
| <TextBlock x:Name="touchHeader" Text="Touch Properties" Style="{StaticResource SubtitleTextBlockStyle}" Padding="0,12,0,0"/> | ||
| <TextBlock x:Name="touchText"/> | ||
| </StackPanel> | ||
| </ScrollViewer> | ||
| </Page> |
This file contains hidden or 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,35 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Text; | ||
| using Microsoft.UI.Xaml.Controls; | ||
| using Windows.Devices.Input; | ||
|
|
||
| namespace Input | ||
| { | ||
| public sealed partial class DeviceCapabilities : Page | ||
| { | ||
| public DeviceCapabilities() | ||
| { | ||
| this.InitializeComponent(); | ||
|
|
||
| KeyboardCapabilities kbdCapabilities = new KeyboardCapabilities(); | ||
| keyboardText.Text = "Keyboard present = " + kbdCapabilities.KeyboardPresent.ToString(); | ||
|
|
||
| MouseCapabilities mouseCapabilities = new MouseCapabilities(); | ||
| StringBuilder sb = new StringBuilder(); | ||
| sb.Append("Mouse present = " + mouseCapabilities.MousePresent.ToString() + "\n"); | ||
| sb.Append("Number of buttons = " + mouseCapabilities.NumberOfButtons.ToString() + "\n"); | ||
| sb.Append("Vertical wheel present = " + mouseCapabilities.VerticalWheelPresent.ToString() + "\n"); | ||
| sb.Append("Horizontal wheel present = " + mouseCapabilities.HorizontalWheelPresent.ToString() + "\n"); | ||
| sb.Append("Buttons swapped = " + mouseCapabilities.SwapButtons.ToString()); | ||
| mouseText.Text = sb.ToString(); | ||
|
|
||
| TouchCapabilities touchCapabilities = new TouchCapabilities(); | ||
| sb = new StringBuilder(); | ||
| sb.Append("Touch present = " + touchCapabilities.TouchPresent.ToString() + "\n"); | ||
| sb.Append("Touch contacts supported = " + touchCapabilities.Contacts.ToString()); | ||
| touchText.Text = sb.ToString(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,54 @@ | ||
| <!-- Copyright (c) Microsoft Corporation. | ||
| Licensed under the MIT License. --> | ||
| <UserControl | ||
| x:Class="Input.PointerEllipse" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| d:DesignHeight="120" | ||
| d:DesignWidth="120" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <UserControl.Resources> | ||
| <Storyboard x:Name="PrimaryPointerStoryboard"> | ||
| <DoubleAnimation | ||
| Storyboard.TargetName="ellipse" | ||
| Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" | ||
| Duration="0:0:1" | ||
| AutoReverse="True" | ||
| RepeatBehavior="Forever" | ||
| From="1.0" | ||
| To="1.4" /> | ||
| <DoubleAnimation | ||
| Storyboard.TargetName="ellipse" | ||
| Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" | ||
| Duration="0:0:1" | ||
| AutoReverse="True" | ||
| RepeatBehavior="Forever" | ||
| From="1.0" | ||
| To="1.4" /> | ||
| <ColorAnimation | ||
| Storyboard.TargetName="ellipse" | ||
| Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" | ||
| Duration="0:0:1" | ||
| AutoReverse="True" | ||
| RepeatBehavior="Forever" | ||
| From="White" | ||
| To="Red" | ||
| EnableDependentAnimation="True" /> | ||
| </Storyboard> | ||
| </UserControl.Resources> | ||
|
|
||
| <Grid> | ||
| <Ellipse x:Name="ellipse" | ||
| Width="{x:Bind Diameter}" | ||
| Height="{x:Bind Diameter}" | ||
| StrokeThickness="2" | ||
| RenderTransformOrigin="0.5,0.5"> | ||
| <Ellipse.RenderTransform> | ||
| <ScaleTransform ScaleX="1" ScaleY="1" /> | ||
| </Ellipse.RenderTransform> | ||
| </Ellipse> | ||
| </Grid> | ||
| </UserControl> |
This file contains hidden or 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,52 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
|
qiutongMS marked this conversation as resolved.
Outdated
|
||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.UI; | ||
| using Microsoft.UI.Xaml.Controls; | ||
| using Microsoft.UI.Xaml.Media; | ||
|
|
||
| namespace Input | ||
| { | ||
| public sealed partial class PointerEllipse : UserControl | ||
| { | ||
| private bool primaryEllipse; | ||
|
|
||
| public PointerEllipse() | ||
| { | ||
| this.InitializeComponent(); | ||
| ApplyPointerStyle(false); | ||
| } | ||
|
|
||
| public uint PointerId { get; set; } | ||
|
|
||
| public bool PrimaryPointer { get; set; } | ||
|
|
||
| public bool PrimaryEllipse | ||
| { | ||
| get => primaryEllipse; | ||
| set | ||
| { | ||
| primaryEllipse = value; | ||
| ApplyPointerStyle(value); | ||
| } | ||
| } | ||
|
|
||
| public double Diameter => 120.0; | ||
|
|
||
| private void ApplyPointerStyle(bool isPrimary) | ||
| { | ||
| if (isPrimary) | ||
| { | ||
| ellipse.Fill = new SolidColorBrush(Colors.White); | ||
| ellipse.Stroke = new SolidColorBrush(Colors.Red); | ||
| PrimaryPointerStoryboard.Begin(); | ||
| } | ||
| else | ||
| { | ||
| PrimaryPointerStoryboard.Stop(); | ||
| ellipse.Fill = new SolidColorBrush(Colors.LightSkyBlue); | ||
| ellipse.Stroke = new SolidColorBrush(Colors.DodgerBlue); | ||
| } | ||
|
Comment on lines
+36
to
+49
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,29 @@ | ||
| <!-- Copyright (c) Microsoft Corporation. | ||
| Licensed under the MIT License. --> | ||
| <Page | ||
| x:Class="Input.PointerPointProperties" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| mc:Ignorable="d"> | ||
|
|
||
| <Grid Margin="12,10,12,12"> | ||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="Auto" /> | ||
| <RowDefinition Height="*" /> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <ScrollViewer MaxHeight="150" VerticalScrollMode="Auto" VerticalScrollBarVisibility="Auto"> | ||
| <StackPanel> | ||
| <TextBlock Text="Description:" Style="{StaticResource SubtitleTextBlockStyle}"/> | ||
| <TextBlock Style="{StaticResource BodyTextBlockStyle}" TextWrapping="Wrap" Margin="0,8,0,0"> | ||
| The PointerPoint class provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact. This scenario demonstrates how to retrieve a PointerPoint object in response to an input event, determine what type of input it is (mouse, pen, or touch), and retrieve properties present for all input types and those specific to its type. | ||
| </TextBlock> | ||
| </StackPanel> | ||
| </ScrollViewer> | ||
| <TextBlock Grid.Row="1" Text="Touch or click the screen to see information about the current pointer(s)" TextWrapping="Wrap" Padding="0,12,0,0"/> | ||
| <Canvas Grid.Row="2" x:Name="mainCanvas" Height="Auto" Margin="12,10,12,12" Background="Transparent"/> | ||
|
|
||
| </Grid> | ||
| </Page> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.