Skip to content
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

Infinite canvas #1958

Merged
merged 71 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c21f3bb
Adding infinite canvas initial commit
IbraheemOsama Mar 29, 2018
4ba9f47
Merge remote-tracking branch 'refs/remotes/Microsoft/master' into Inf…
IbraheemOsama Mar 29, 2018
6c81f9f
Editing samples.json
IbraheemOsama Mar 29, 2018
7d1984e
Infinite Canvas Integrated and no build errors
IbraheemOsama Mar 29, 2018
75a1f8d
Adding drwabeList
IbraheemOsama Mar 30, 2018
ff38584
Adding resize events
IbraheemOsama Mar 31, 2018
cf69a6e
Adding erase first step
IbraheemOsama Apr 1, 2018
eaafe34
Fixing bounding rect problem
IbraheemOsama Apr 1, 2018
5c04d5d
adding clear all
IbraheemOsama Apr 1, 2018
c47e4ff
adding custom text button
IbraheemOsama Apr 1, 2018
32d64ac
addign text box click functionality
IbraheemOsama Apr 1, 2018
743c99c
Text working with inking
IbraheemOsama Apr 2, 2018
919bd55
Fixing textbox issues
IbraheemOsama Apr 3, 2018
914fdbf
Adding extract text basic logic
IbraheemOsama Apr 3, 2018
afc9cf4
Infinite canvas finally working with virtualization
IbraheemOsama Apr 4, 2018
55748f8
Adding canvas Text Drawable.
IbraheemOsama Apr 4, 2018
090ecb6
Everything is working start to remove the textbox
IbraheemOsama Apr 4, 2018
414e83f
Removing margin
IbraheemOsama Apr 4, 2018
324550b
Removing text border
IbraheemOsama Apr 4, 2018
9f32997
refactoring
IbraheemOsama Apr 4, 2018
06ebb05
Adding transparent textbox
IbraheemOsama Apr 5, 2018
3b46c14
Text is working fine but in case of mouse only need to handle pan
IbraheemOsama Apr 5, 2018
0001962
Now text is working fine :)
IbraheemOsama Apr 5, 2018
26aa07a
Adding reverse process for text and it is working
IbraheemOsama Apr 5, 2018
e65538c
Tring to fix textbox right navigation problem
IbraheemOsama Apr 5, 2018
de9ed80
Everything is working after disableing interaction
IbraheemOsama Apr 5, 2018
0a5c040
Adding button bold and italic
IbraheemOsama Apr 5, 2018
4b7fdb0
Hahahaha TextBox With Scroll you loose
IbraheemOsama Apr 6, 2018
edb8bb8
Fixing scaling issue
IbraheemOsama Apr 6, 2018
c1b5cbe
Ink Drawing matches the canvas
IbraheemOsama Apr 6, 2018
8b19bdc
Mapping between ink and drawing surface is accurate
IbraheemOsama Apr 6, 2018
e3face0
Fixing textbox heightlight problem
IbraheemOsama Apr 7, 2018
edb8550
Next is Undo and Redo
IbraheemOsama Apr 8, 2018
427a5fd
Refactoring and adding commands
IbraheemOsama Apr 8, 2018
42a22b8
Adding Create Text and Change text Command
IbraheemOsama Apr 8, 2018
3d73f61
Adding the reset of text edit commands
IbraheemOsama Apr 8, 2018
d307174
Adding ink do undo
IbraheemOsama Apr 8, 2018
5286edf
Adding clear all command
IbraheemOsama Apr 8, 2018
fac5611
Refactoring everything to match the toolkit guidelines
IbraheemOsama Apr 8, 2018
71b9278
Adding import export methods
IbraheemOsama Apr 8, 2018
380639c
Adding export import
IbraheemOsama Apr 8, 2018
73dd3b0
Adding header files
IbraheemOsama Apr 8, 2018
7a3aeb3
Adding header files
IbraheemOsama Apr 8, 2018
27905a3
Merge remote-tracking branch 'refs/remotes/Microsoft/master' into Inf…
IbraheemOsama Apr 8, 2018
0da4475
Fixing missing header agaaaaaaaaaaaaaaaaain
IbraheemOsama Apr 8, 2018
6f6aad0
Fixing headers
IbraheemOsama Apr 8, 2018
765b3b5
Renaming unexecute to undo and adding trim(0)
IbraheemOsama Apr 10, 2018
11bfa1c
Adding hide/show
IbraheemOsama Apr 10, 2018
c4d4241
Addign min max zoom
IbraheemOsama Apr 10, 2018
1a6ff40
Adding header file
IbraheemOsama Apr 10, 2018
b16b516
handling PR comments
IbraheemOsama Apr 11, 2018
d0fba89
Adding icon color and fix textbox scroll and view issues
IbraheemOsama Apr 18, 2018
a7949e3
Fixing PR Comments
IbraheemOsama Apr 18, 2018
bdc77bd
Fixing last Nikola comment (Hopefully)
IbraheemOsama Apr 18, 2018
c5ac903
resolving conflicts
IbraheemOsama Apr 18, 2018
d5b73db
addign do redo fixing execption
IbraheemOsama Apr 30, 2018
9209c9e
Adding styles
IbraheemOsama Apr 30, 2018
a4ad3f8
Merging from master
IbraheemOsama Apr 30, 2018
5fa9b22
Making color red
IbraheemOsama Apr 30, 2018
34733e9
Fixing PR Comments
IbraheemOsama May 10, 2018
27b954c
Fixing theming issue
IbraheemOsama May 10, 2018
3ebe1cd
Merge remote-tracking branch 'refs/remotes/Microsoft/master' into Inf…
IbraheemOsama May 11, 2018
2e84e1b
Adding number only textbox
IbraheemOsama May 18, 2018
a16634a
Adding Icon
IbraheemOsama May 18, 2018
c5074b6
Adding control documenations
IbraheemOsama May 18, 2018
f57fbd4
Merge branch 'master' into InfiniteCanvas
IbraheemOsama May 18, 2018
8a69256
Merge branch 'master' into InfiniteCanvas
azchohfi May 18, 2018
db3b096
Fixing typo
IbraheemOsama May 18, 2018
aee31d8
Merging from master
IbraheemOsama May 18, 2018
4df09aa
Merge branch 'master' into InfiniteCanvas
nmetulev May 22, 2018
7a00d8f
Merge branch 'master' into InfiniteCanvas
azchohfi May 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
{
"Name": "InfiniteCanvas",
"Type": "InfiniteCanvasPage",
"About": "InfiniteCanvas is a canvas that supports Ink, Text, Format Text, Zoom in/out, Redo, Undo, Export canvas data, Import canvas data.",
"About": "InfiniteCanvas is a canvas that supports Infinite Scrolling, Ink, Text, Format Text, Zoom in/out, Redo, Undo, Export canvas data, Import canvas data.",
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/InfiniteCanvas",
"XamlCodeFile": "InfiniteCanvas.bind",
"Icon": "/SamplePages/InfiniteCanvas/InfiniteCanvas.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Linq;
using System.Text.RegularExpressions;
using Windows.Foundation;
using Windows.System;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;

namespace Microsoft.Toolkit.Uwp.UI.Controls
Expand All @@ -26,6 +27,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
public partial class InfiniteCanvas
{
private const int DefaultFontValue = 22;
private readonly string[] _allowedCommands =
{
"Shift",
"Escape",
"Delete",
"Back",
"Right",
"Up",
"Left",
"Down"
};

private Point _lastInputPoint;

private TextDrawable SelectedTextDrawable => _drawingSurfaceRenderer.GetSelectedTextDrawable();
Expand All @@ -47,7 +60,7 @@ private int TextFontSize
}
}

private void InkScrollViewer_PreviewKeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
private void InkScrollViewer_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
// fixing scroll viewer issue with text box when you hit UP/DOWN/Right/LEFT
if (_canvasTextBox.Visibility != Visibility.Visible)
Expand Down Expand Up @@ -155,7 +168,7 @@ private void CanvasTextBox_TextChanged(object sender, string text)
_drawingSurfaceRenderer.UpdateSelectedTextDrawable();
}

private void InkScrollViewer_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArgs e)
{
if (_enableTextButton.IsChecked ?? false)
{
Expand Down Expand Up @@ -201,5 +214,25 @@ private void ClearTextBoxValue()
_drawingSurfaceRenderer.ResetSelectedTextDrawable();
_canvasTextBox.Clear();
}

private void CanvasTextBoxFontSizeTextBox_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (_allowedCommands.Contains(e.Key.ToString()))
{
e.Handled = false;
return;
}

for (int i = 0; i < 10; i++)
{
if (e.Key.ToString() == string.Format("Number{0}", i))
{
e.Handled = false;
return;
}
}

e.Handled = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private void UnRegisterEvents()
Unloaded -= InfiniteCanvas_Unloaded;
Application.Current.LeavingBackground -= Current_LeavingBackground;
_drawingSurfaceRenderer.CommandExecuted -= DrawingSurfaceRenderer_CommandExecuted;
_canvasTextBoxFontSizeTextBox.PreviewKeyDown -= CanvasTextBoxFontSizeTextBox_PreviewKeyDown;
}

private void RegisterEvents()
Expand All @@ -228,6 +229,7 @@ private void RegisterEvents()
Unloaded += InfiniteCanvas_Unloaded;
Application.Current.LeavingBackground += Current_LeavingBackground;
_drawingSurfaceRenderer.CommandExecuted += DrawingSurfaceRenderer_CommandExecuted;
_canvasTextBoxFontSizeTextBox.PreviewKeyDown += CanvasTextBoxFontSizeTextBox_PreviewKeyDown;
}

private void ConfigureControls()
Expand Down
82 changes: 82 additions & 0 deletions docs/controls/InfiniteCanvas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: InfiniteCanvas XAML Control
author: IbraheemOsama
description: InfiniteCanvas is a canvas that supports Infinite Scrolling, Ink, Text, Format Text, Zoom in/out, Redo, Undo, Export canvas data, Import canvas data.
keywords: windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, InfiniteCanvas, XAML Control, xaml
---

# InfiniteCanvas XAML Control

The [InfiniteCanvas Control](https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.ui.controls.infinitecanvas) is a canvas that supports Infinite Scrolling, Ink, Text, Format Text, Zoom in/out, Redo, Undo, Export canvas data, Import canvas data.

## Syntax

```xaml
<Page ...
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"/>

<controls:InfiniteCanvas Name="canvas"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some Properties and Events in this syntax. This look .....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default usage for the canvas is "no properties" that's why it is better this way :)

```

## Sample Output

![InfiniteCanvas animation](../resources/images/Controls/InfiniteCanvas.gif)

## Properties

| Property | Type | Description |
| -- | -- | -- |
| CanvasWidth | double | Gets or sets the width of the canvas, default value is the max value 2097152. |
| CanvasHeight | double | Gets or sets the height of the canvas, default value is the max value 2097152. |
| IsToolbarVisible | bool | Gets or sets a value indicating whether the toolbar is visible or not. |
| MaxZoomFactor | double | Gets or sets the MaxZoomFactor for the canvas, range between 1 to 10 and the default value is 4. |
| MinZoomFactor | double | Gets or sets the MinZoomFactor for the canvas, range between .1 to 1 the default value is .25. |

## Methods

| Method | Return Type | Description |
| -- | -- | -- |
| Redo() | void | Redo the last action. |
| Undo() | void | Undo the last action. |
| ExportAsJson() | string | Export the InfinitCanvas as json string. |
| ImportFromJson(string json) | void | Import InfiniteCanvas from json string and render the new canvas, this function will empty the Redo/Undo queue. |

## Events

### ReRenderCompleted

This event triggered after each render happended because of any change in the canvas elements.
This event could be used to do the Auto Save functionality.

## Examples

The following sample demonstrates how to add Grid Splitter Control
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - should be InfiniteCanvas control


```xaml
<Page ....
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">

<Grid>
<controls:InfiniteCanvas Name="canvas"/>
</Grid>
</Page>
```

## Sample Code

[InfiniteCanvas Sample Page Source](https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InfiniteCanvas). You can see this in action in [Windows Community Toolkit Sample App](https://www.microsoft.com/store/apps/9NBLGGH4TLCQ).

## Default Template

[InfiniteCanvas XAML File](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls/InfiniteCanvas/InfiniteCanvas.xaml) is the XAML template used in the toolkit for the default styling.

## Requirements

| Device family | Universal, 10.0.14393.0 or higher |
| -- | -- |
| Namespace | Microsoft.Toolkit.Uwp.UI.Controls |
| NuGet package | [Microsoft.Toolkit.Uwp.UI.Controls](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.UI.Controls/) |

## API

* [InfiniteCanvas source code](https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/InfiniteCanvas)
Binary file added docs/resources/images/Controls/InfiniteCanvas.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.