private async void ColoringPage_SizeChanged(object sender, SizeChangedEventArgs e) { CanvasViewbox.MaxHeight = ColoringHolderGrid.ActualHeight; CanvasViewbox.MaxWidth = ColoringHolderGrid.ActualWidth; // Zoom out fully as the viewbox causes the context from the zoom to be lost. // Add delay to allow viewbox UI operations to complete. await Task.Delay(1); CanvasScrollViewer.ChangeView(null, null, 1, true); }
private void InitSurfaceDiao() { if (!Settings.EnableSurfaceDial) { return; } try { SurfaceDiao = new SurfaceDial(); } catch (Exception e) { var msg = Utils.GetResource("Tracing.Core/Resources/FailedInitiateSurfaceDial") + e.Message; MessageNotification.Show(msg); } // Menu Selection Message SurfaceDiao.OpacityInvoked += (sender, args) => { TxtMessage.Text = Utils.GetResource("Tracing.Core/Resources/OpacitySelected"); BorderFadeInStoryboard.Begin(); }; SurfaceDiao.UndoRedoInvoked += (sender, args) => { TxtMessage.Text = Utils.GetResource("Tracing.Core/Resources/UndoRedoSelected"); BorderFadeInStoryboard.Begin(); }; SurfaceDiao.ZoomInvoked += (sender, args) => { TxtMessage.Text = Utils.GetResource("Tracing.Core/Resources/ZoomSelected"); BorderFadeInStoryboard.Begin(); }; SurfaceDiao.AlignmentGridInvoked += (sender, args) => { TxtMessage.Text = Utils.GetResource("Tracing.Core/Resources/AlignmentGridSelected"); BorderFadeInStoryboard.Begin(); }; // Rotation Handling SurfaceDiao.Zooming += (sender, args) => { var zoomFucktor = CanvasScrollViewer.ZoomFactor; zoomFucktor += 0.01f * (args.RotationDeltaInDegrees < 0 ? -1 : 1); CanvasScrollViewer.ChangeView(0, 0, zoomFucktor); }; SurfaceDiao.UndoRedo += (sender, args) => { if (args.RotationDeltaInDegrees < 0) { ViewModel.InkOperator.UndoLastStorke(); } else { ViewModel.InkOperator.RedoLastStorke(); } }; SurfaceDiao.OpacityChanging += (sender, args) => { if (OpacitySlider.Value + args.RotationDeltaInDegrees > 100) { OpacitySlider.Value = 100; return; } if (OpacitySlider.Value + args.RotationDeltaInDegrees < 0) { OpacitySlider.Value = 0; return; } OpacitySlider.Value += args.RotationDeltaInDegrees; }; SurfaceDiao.AlignmentGridChanging += (sender, args) => { if (SldAlignmentGridSize.Value + args.RotationDeltaInDegrees > 128) { SldAlignmentGridSize.Value = 128; return; } if (SldAlignmentGridSize.Value + args.RotationDeltaInDegrees < 16) { SldAlignmentGridSize.Value = 16; return; } SldAlignmentGridSize.Value += args.RotationDeltaInDegrees; }; }