I have one UWP App using a UWP InkCanvas with a Load and Save Ink Buttons. I made a draw with the app on one laptop, saved the ink as a gif (+embedded isf) and sent the gif file to another laptop with a smaller screen to try it out.
When opening the ink with the same app but on this other laptop, the draw is clipped at the boundaries, as if it does not fit the screen, which arguably is due to the laptop's smaller screen size.
I tried to resize the InkCanvas as a whole by encapsulating it in a Scrollviewer but the draw follows the InkCanvas zooming, hence the draw remains clipped at the boundaries. Same with a render transform on the InkCanvas. I also tried the copy paste methods of the StrokeContainer when loading the ink. It does not work and furthermore I find it bulky as one needs to loop through all strokes to get them selected and then copy pasted.
I am looking at a way to automatically resize the InkCanvas (preferred) or the Strokes such that the drawing appears entirely on the InkCanvas, regardless of the size of the laptop's screen. I was expecting this to happen by default but somewhat it does not.
Although the code I use is very simple, I provide it as a start:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Background="White" Grid.Row="1">
<InkCanvas x:Name="inkCanvas"/>
</Grid>
<StackPanel>
<Button Content="Load" Click="LoadButton_Click"/>
<Button Content="Save" Click="SaveButton_Click"/>
</StackPanel>
</Grid>
private async void LoadButton_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.FileTypeFilter.Clear();
openPicker.FileTypeFilter.Add(".isf");
openPicker.FileTypeFilter.Add(".gif");
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
using (var inputStream = stream.GetInputStreamAt(0))
{
await inkCanvas.InkPresenter.StrokeContainer.LoadAsync(inputStream);
}
stream.Dispose();
}
}
SaveButton_Click
event handler? – Laith