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 66 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
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
<Content Include="SamplePages\InAppNotification\InAppNotification.png" />
<Content Include="SamplePages\Incremental Loading Collection\icon.png" />
<Content Include="SamplePages\LayoutTransformControl\LayoutTransformControl.png" />
<Content Include="SamplePages\InfiniteCanvas\InfiniteCanvas.png" />
<Content Include="SamplePages\Light\LightBehavior.png" />
<Content Include="SamplePages\LinkedIn Service\LinkedInLogo.png" />
<Content Include="Assets\Helpers.png" />
Expand Down Expand Up @@ -496,6 +497,7 @@
<Content Include="SamplePages\PrintHelper\PrintHelperXaml.bind">
<SubType>Designer</SubType>
</Content>
<Content Include="SamplePages\InfiniteCanvas\InfiniteCanvas.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand Down Expand Up @@ -583,6 +585,9 @@
<Compile Include="SamplePages\LayoutTransformControl\LayoutTransformControlPage.xaml.cs">
<DependentUpon>LayoutTransformControlPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\InfiniteCanvas\InfiniteCanvasPage.xaml.cs">
<DependentUpon>InfiniteCanvasPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ListViewExtensions\ListViewExtensionsPage.xaml.cs">
<DependentUpon>ListViewExtensionsPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -938,6 +943,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\InfiniteCanvas\InfiniteCanvasPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\MarkdownParser\MarkdownParserPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid>
<controls:InfiniteCanvas Name="canvas" IsToolbarVisible="@[IsToolbarVisible:Bool:True]"/>
</Grid>
</Page>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.InfiniteCanvasPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System;
using System.Collections.Generic;
using Windows.Storage;
using Windows.UI.Popups;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.UI.Controls;
using Microsoft.Toolkit.Uwp.UI.Extensions;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
/// <summary>
/// InfinteCanvas sample page.
/// </summary>
public sealed partial class InfiniteCanvasPage : Page, IXamlRenderListener
{
private InfiniteCanvas _infiniteCanvas;

public InfiniteCanvasPage()
{
InitializeComponent();
}

public void OnXamlRendered(FrameworkElement control)
{
_infiniteCanvas = control.FindChildByName("canvas") as InfiniteCanvas;
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);

Shell.Current.RegisterNewCommand("Export & Save", async (sender, args) =>
{
if (_infiniteCanvas != null)
{
var savePicker = new Windows.Storage.Pickers.FileSavePicker
{
SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
};
savePicker.FileTypeChoices.Add("application/json", new List<string> { ".json" });
savePicker.SuggestedFileName = "Infinite Canvas Export";

StorageFile file = await savePicker.PickSaveFileAsync();
if (file != null)
{
var json = _infiniteCanvas.ExportAsJson();
CachedFileManager.DeferUpdates(file);
await FileIO.WriteTextAsync(file, json);
}
}
});

Shell.Current.RegisterNewCommand("Import and Load", async (sender, args) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update these commands to save and load files outside of the app. They should ask the user where to save or what file to import.

{
if (_infiniteCanvas != null)
{
var picker = new Windows.Storage.Pickers.FileOpenPicker
{
ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
};
picker.FileTypeFilter.Add(".json");
var file = await picker.PickSingleFileAsync();

if (file != null)
{
try
{
var json = await FileIO.ReadTextAsync(file);
_infiniteCanvas.ImportFromJson(json);
}
catch
{
var dialog = new MessageDialog("Invalid File");
await dialog.ShowAsync();
}
}
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<converters:ToolbarFormatActiveConverter x:Key="IsFormatMarkdown"
Format="MarkDown" />
Format="MarkDown" />
</Page.Resources>

<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private void AddCustomButton()
else
{
_toolbar.Formatter.Selected.Text = $"This was filled by {demoText} button ";

_toolbar.Formatter.Selected.CharacterFormat.Size = 40;
}
}
};
Expand Down
9 changes: 9 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@
"XamlCodeFile": "LayoutTransformControlXaml.bind",
"Icon": "/SamplePages/LayoutTransformControl/LayoutTransformControl.png",
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/LayoutTransformControl.md"
},
{
"Name": "InfiniteCanvas",
"Type": "InfiniteCanvasPage",
"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",
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/InfiniteCanvas.md"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal interface IInfiniteCanvasCommand
{
void Execute();

void Undo();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Collections.Generic;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class InfiniteCanvasClearAllCommand : IInfiniteCanvasCommand
{
private readonly List<IDrawable> _drawableList;
private IDrawable[] _storeList;

public InfiniteCanvasClearAllCommand(List<IDrawable> drawableList)
{
_drawableList = drawableList;
}

public void Execute()
{
_storeList = new IDrawable[_drawableList.Count];
for (int i = 0; i < _drawableList.Count; i++)
{
_storeList[i] = _drawableList[i];
}

_drawableList.Clear();
}

public void Undo()
{
foreach (var drawable in _storeList)
{
_drawableList.Add(drawable);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Collections.Generic;
using Windows.UI.Input.Inking;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class InfiniteCanvasCreateInkCommand : IInfiniteCanvasCommand
{
private readonly List<IDrawable> _drawableList;
private readonly InkDrawable _drawable;

public InfiniteCanvasCreateInkCommand(List<IDrawable> drawableList, IReadOnlyList<InkStroke> strokes)
{
_drawable = new InkDrawable(strokes);
_drawableList = drawableList;
}

public void Execute()
{
_drawableList.Add(_drawable);
}

public void Undo()
{
_drawableList.Remove(_drawable);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Collections.Generic;
using Windows.UI;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class InfiniteCanvasCreateTextBoxCommand : IInfiniteCanvasCommand
{
private readonly List<IDrawable> _drawableList;
private readonly TextDrawable _drawable;

public InfiniteCanvasCreateTextBoxCommand(List<IDrawable> drawableList, double x, double y, double width, double height, int textFontSize, string text, Color color, bool isBold, bool isItalic)
{
_drawable = new TextDrawable(
x,
y,
width,
height,
textFontSize,
text,
color,
isBold,
isItalic);
_drawableList = drawableList;
}

public void Execute()
{
_drawableList.Add(_drawable);
}

public void Undo()
{
_drawableList.Remove(_drawable);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System.Collections.Generic;

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class InfiniteCanvasEraseInkCommand : IInfiniteCanvasCommand
{
private readonly List<IDrawable> _drawableList;
private readonly IDrawable _drawable;

public InfiniteCanvasEraseInkCommand(List<IDrawable> drawableList, IDrawable drawable)
{
_drawable = drawable;
_drawableList = drawableList;
}

public void Execute()
{
_drawableList.Remove(_drawable);
}

public void Undo()
{
_drawableList.Add(_drawable);
}
}
}
Loading