Created
July 14, 2016 16:16
-
-
Save naikrovek/7098f4f4b69a50bf171f9c8f6d16452b to your computer and use it in GitHub Desktop.
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
<Page | |
x:Class="BlackBoard.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:BlackBoard" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
mc:Ignorable="d"> | |
<Grid Background="White"> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="Auto" /> | |
<RowDefinition Height="*"/> | |
</Grid.RowDefinitions> | |
<InkCanvas x:Name="ink" Height="2000" Width="3000" Grid.Row="1"> | |
<InkCanvas.RenderTransform> | |
<CompositeTransform x:Name="inkTransform" /> | |
</InkCanvas.RenderTransform> | |
</InkCanvas> | |
<StackPanel Orientation="Horizontal" Grid.Row="0"> | |
<Button x:Name="btnLoad" Content="Load" Margin="10" Click="BtnLoad_Click" /> | |
<Button x:Name="btnSave" Content="Save" Margin="10" Click="BtnSave_Click" /> | |
<Button x:Name="btnClear" Content="Clear Canvas" Margin="10" Click="BtnClear_Click" /> | |
<Button x:Name="btnReset" Content="Reset Zoom" Margin="10" Click="btnReset_Click" /> | |
</StackPanel> | |
<InkToolbar | |
Grid.Row="0" | |
TargetInkCanvas="{Binding ElementName=ink}" | |
HorizontalAlignment="Center" | |
VerticalAlignment="Top" /> | |
</Grid> | |
</Page> |
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
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Threading.Tasks; | |
using Windows.Foundation; | |
using Windows.Networking.Sockets; | |
using Windows.Storage.Streams; | |
using Windows.UI.Input; | |
using Windows.UI.Input.Inking; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Input; | |
namespace BlackBoard { | |
public sealed partial class MainPage : Page { | |
public MainPage() { | |
InitializeComponent(); | |
Loaded += OnLoaded; | |
} | |
void OnLoaded(object sender, RoutedEventArgs e) { | |
ink.ManipulationMode = | |
ManipulationModes.Rotate | | |
ManipulationModes.Scale | | |
ManipulationModes.TranslateX | | |
ManipulationModes.TranslateY; | |
ink.ManipulationDelta += Ink_ManipulationDelta; | |
} | |
private void Ink_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { | |
inkTransform.Rotation += e.Delta.Rotation; | |
inkTransform.CenterX = e.Position.X; | |
inkTransform.CenterY = e.Position.Y; | |
inkTransform.ScaleX *= e.Delta.Scale; | |
inkTransform.ScaleY *= e.Delta.Scale; | |
inkTransform.TranslateX += e.Delta.Translation.X; | |
inkTransform.TranslateY += e.Delta.Translation.Y; | |
} | |
private async void BtnSave_Click(object sender, RoutedEventArgs e) { | |
// snip | |
} | |
private async void BtnLoad_Click(object sender, RoutedEventArgs e) { | |
// snip | |
} | |
private void BtnClear_Click(object sender, RoutedEventArgs e) { | |
ink.InkPresenter.StrokeContainer.Clear(); | |
} | |
private void btnReset_Click(object sender, RoutedEventArgs e) { | |
inkTransform.Rotation = 0; | |
inkTransform.ScaleX = 1; | |
inkTransform.ScaleY = 1; | |
inkTransform.TranslateX = 0; | |
inkTransform.TranslateY = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment