-
Notifications
You must be signed in to change notification settings - Fork 8
/
EditorUserControl.xaml.cs
688 lines (563 loc) · 25.8 KB
/
EditorUserControl.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
// Copyright @ MyScript. All rights reserved.
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.System;
using Windows.Graphics.Display;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI.Xaml;
using MyScript.IInk.Graphics;
using MyScript.IInk.UIReferenceImplementation.Extensions;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace MyScript.IInk.UIReferenceImplementation.UserControls
{
public sealed partial class EditorUserControl
{
public static readonly DependencyProperty EditorProperty =
DependencyProperty.Register("Editor", typeof(Editor), typeof(EditorUserControl),
new PropertyMetadata(default(Editor)));
public Editor Editor
{
get => GetValue(EditorProperty) as Editor;
set
{
SetValue(EditorProperty, value);
if (!(value is Editor editor))return;
Initialize(Editor);
}
}
}
public sealed partial class EditorUserControl : IRenderTarget
{
private ImageLoader _loader;
private bool _smartGuideEnabled = true;
public ImageLoader ImageLoader => _loader;
public SmartGuideUserControl SmartGuide => smartGuide;
private Layer _renderLayer;
private uint _nextOffscreenRenderId = 0;
private IDictionary<uint, CanvasRenderTarget> _bitmaps = new Dictionary<uint, CanvasRenderTarget>();
public bool SmartGuideEnabled
{
get
{
return _smartGuideEnabled;
}
set
{
EnableSmartGuide(value);
}
}
private int _pointerId = -1;
private bool _onScroll = false;
private Graphics.Point _lastPointerPosition;
private System.Int64 _eventTimeOffset = 0;
public EditorUserControl()
{
InitializeComponent();
var msFromEpoch = System.DateTimeOffset.Now.ToUnixTimeMilliseconds();
var msFromBoot = System.Environment.TickCount;
_eventTimeOffset = msFromEpoch - msFromBoot;
}
private void Initialize(Editor editor)
{
var engine = editor.Engine;
var dpiX = Editor?.Renderer?.DpiX ?? 96;
var dpiY = Editor?.Renderer?.DpiY ?? 96;
var render = editor.Renderer;
_renderLayer = new Layer(renderCanvas, this, render);
var tempFolder = engine.Configuration.GetString("content-package.temp-folder");
_loader = new ImageLoader(Editor, tempFolder);
_renderLayer.ImageLoader = _loader;
float verticalMarginPX = 60;
float horizontalMarginPX = 40;
var verticalMarginMM = 25.4f * verticalMarginPX / dpiY;
var horizontalMarginMM = 25.4f * horizontalMarginPX / dpiX;
engine.Configuration.SetNumber("text.margin.top", verticalMarginMM);
engine.Configuration.SetNumber("text.margin.left", horizontalMarginMM);
engine.Configuration.SetNumber("text.margin.right", horizontalMarginMM);
engine.Configuration.SetNumber("math.margin.top", verticalMarginMM);
engine.Configuration.SetNumber("math.margin.bottom", verticalMarginMM);
engine.Configuration.SetNumber("math.margin.left", horizontalMarginMM);
engine.Configuration.SetNumber("math.margin.right", horizontalMarginMM);
}
/// <summary>Force ink layer to be redrawn</summary>
public void Invalidate(LayerType layers)
{
if (!(Editor?.Renderer is Renderer renderer)) return;
Invalidate(renderer, layers);
}
/// <summary>Force ink layer to be redrawn</summary>
public void Invalidate(Renderer renderer, LayerType layers)
{
_renderLayer.Update();
}
/// <summary>Force ink layer to be redrawn according region</summary>
public void Invalidate(Renderer renderer, int x, int y, int width, int height, LayerType layers)
{
if (width > 0 && height > 0)
_renderLayer?.Update(x, y, width, height);
}
public bool SupportsOffscreenRendering()
{
return true;
}
public float GetPixelDensity()
{
var info = DisplayInformation.GetForCurrentView();
return info.RawPixelsPerViewPixel > 0 ? (float)info.RawPixelsPerViewPixel :
info.ResolutionScale != ResolutionScale.Invalid ? (float)info.ResolutionScale / 100.0f : 1.0f;
}
public uint CreateOffscreenRenderSurface(int width, int height, bool alphaMask)
{
// Use DPI 96 to specify 1:1 dip <-> pixel mapping
CanvasDevice device = CanvasDevice.GetSharedDevice();
CanvasRenderTarget offscreen = new CanvasRenderTarget(device, width, height, 96);
uint offscreenRenderId = _nextOffscreenRenderId++;
_bitmaps.Add(offscreenRenderId, offscreen);
return offscreenRenderId;
}
public void ReleaseOffscreenRenderSurface(uint surfaceId)
{
CanvasRenderTarget offscreen;
if (!_bitmaps.TryGetValue(surfaceId, out offscreen))
throw new System.NullReferenceException();
_bitmaps.Remove(surfaceId);
offscreen.Dispose();
}
public ICanvas CreateOffscreenRenderCanvas(uint offscreenID)
{
CanvasRenderTarget offscreen;
if ( !_bitmaps.TryGetValue(offscreenID, out offscreen) )
throw new System.NullReferenceException();
return new Canvas(offscreen.CreateDrawingSession(), this, _loader);
}
public void ReleaseOffscreenRenderCanvas(ICanvas canvas)
{
// The previously created DrawingSession (in CreateOffscreenRenderCanvas) must be disposed
// before we can ask the offscreen surface (CanvasRenderTarget) to recreate a new one.
// So, we ask the canvas to dispose and set to null its DrawingSession; the canvas should be destroyed soon after.
Canvas canvas_ = (Canvas)canvas;
canvas_.DisposeSession();
}
public CanvasRenderTarget GetImage(uint offscreenID)
{
CanvasRenderTarget offscreen;
if ( !_bitmaps.TryGetValue(offscreenID, out offscreen) )
throw new System.NullReferenceException();
return offscreen;
}
private void EnableSmartGuide(bool enable)
{
if (_smartGuideEnabled == enable)
return;
_smartGuideEnabled = enable;
if (!_smartGuideEnabled && smartGuide != null)
smartGuide.Visibility = Visibility.Collapsed;
}
public void OnResize(int width, int height)
{
Editor?.SetViewSize(width, height);
}
/// <summary>Resize editor when one canvas size has been changed </summary>
private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (sender == renderCanvas)
{
OnResize((int)renderCanvas.ActualWidth, (int)renderCanvas.ActualHeight);
}
((CanvasVirtualControl)(sender)).Invalidate();
}
/// <summary>Redrawing Canvas</summary>
private void Canvas_OnRegionsInvalidated(CanvasVirtualControl sender, CanvasRegionsInvalidatedEventArgs args)
{
foreach (var region in args.InvalidatedRegions)
{
if (region.Width > 0 && region.Height > 0)
{
var x = (int)System.Math.Floor(region.X);
var y = (int)System.Math.Floor(region.Y);
var width = (int)System.Math.Ceiling(region.X + region.Width) - x;
var height = (int)System.Math.Ceiling(region.Y + region.Height) - y;
if (sender == renderCanvas)
_renderLayer.OnPaint(x, y, width, height);
}
}
}
private System.Int64 GetTimestamp(Windows.UI.Input.PointerPoint point)
{
// Convert the timestamp (from boot time) to milliseconds
// and add offset to get the time from EPOCH
return _eventTimeOffset + (System.Int64)(point.Timestamp / 1000);
}
public int GetPointerId(RoutedEventArgs e)
{
if (e is PointerRoutedEventArgs)
return (int)((PointerRoutedEventArgs)e).Pointer.PointerDeviceType;
else if (e is HoldingRoutedEventArgs)
return (int)((HoldingRoutedEventArgs)e).PointerDeviceType;
return -1;
}
[System.Flags]
public enum ContextualActions
{
NONE = 0,
ADD_BLOCK = 1 << 0, /// Add block. See <c>Editor.GetSupportedAddBlockTypes</c>.
REMOVE = 1 << 1, /// Remove selection.
CONVERT = 1 << 2, /// Convert. See <c>Editor.GetSupportedTargetConversionStates</c>.
COPY = 1 << 3, /// Copy selection.
OFFICE_CLIPBOARD = 1 << 4, /// Copy selection to Microsoft Office clipboard.
PASTE = 1 << 5, /// Paste.
IMPORT = 1 << 6, /// Import. See <c>Editor.GetSupportedImportMimeTypes</c>.
EXPORT = 1 << 7, /// Export. See <c>Editor.GetSupportedExportMimeTypes</c>.
FORMAT_TEXT = 1 << 8 /// Change Text blocks format.
}
public ContextualActions GetAvailableActions(ContentBlock contentBlock)
{
if (contentBlock == null || Editor == null)
return ContextualActions.NONE;
var part = Editor.Part;
if (part == null)
return ContextualActions.NONE;
var actions = ContextualActions.NONE;
using (var rootBlock = Editor.GetRootBlock())
{
var isRoot = contentBlock.Id == rootBlock.Id;
if (!isRoot && (contentBlock.Type == "Container"))
return ContextualActions.NONE;
var onRawContent = part.Type == "Raw Content";
var onTextDocument = part.Type == "Text Document";
var isEmpty = Editor.IsEmpty(contentBlock);
var supportedTypes = Editor.SupportedAddBlockTypes;
var supportedExports = Editor.GetSupportedExportMimeTypes(onRawContent ? rootBlock : contentBlock);
var supportedImports = Editor.GetSupportedImportMimeTypes(contentBlock);
var supportedStates = Editor.GetSupportedTargetConversionStates(contentBlock);
var supportedFormats = Editor.GetSupportedTextFormats(contentBlock);
var hasTypes = (supportedTypes != null) && supportedTypes.Any();
var hasExports = (supportedExports != null) && supportedExports.Any();
var hasImports = (supportedImports != null) && supportedImports.Any();
var hasStates = (supportedStates != null) && supportedStates.Any();
var hasFormats = (supportedFormats != null) && supportedFormats.Any();
if (hasTypes && (!onTextDocument || isRoot))
actions |= ContextualActions.ADD_BLOCK;
if (!isRoot)
actions |= ContextualActions.REMOVE;
if (hasStates && !isEmpty)
actions |= ContextualActions.CONVERT;
if (!onTextDocument || !isRoot)
actions |= ContextualActions.COPY;
if (hasExports && supportedExports.Contains(MimeType.OFFICE_CLIPBOARD))
actions |= ContextualActions.OFFICE_CLIPBOARD;
if (isRoot)
actions |= ContextualActions.PASTE;
if (hasImports)
actions |= ContextualActions.IMPORT;
if (hasExports)
actions |= ContextualActions.EXPORT;
if (hasFormats)
actions |= ContextualActions.FORMAT_TEXT;
}
return actions;
}
public ContextualActions GetAvailableActions(ContentSelection contentSelection)
{
if (contentSelection == null || Editor == null || Editor.IsEmpty(contentSelection))
return ContextualActions.NONE;
var part = Editor.Part;
if (part == null)
return ContextualActions.NONE;
var actions = ContextualActions.NONE;
var supportedExports = Editor.GetSupportedExportMimeTypes(contentSelection);
var supportedStates = Editor.GetSupportedTargetConversionStates(contentSelection);
var supportedFormats = Editor.GetSupportedTextFormats(contentSelection);
var hasExports = (supportedExports != null) && supportedExports.Any();
var hasStates = (supportedStates != null) && supportedStates.Any();
var hasFormats = (supportedFormats != null) && supportedFormats.Any();
// Erase
actions |= ContextualActions.REMOVE;
if (hasStates)
actions |= ContextualActions.CONVERT;
// Copy
actions |= ContextualActions.COPY;
if (hasExports && supportedExports.Contains(MimeType.OFFICE_CLIPBOARD))
actions |= ContextualActions.OFFICE_CLIPBOARD;
if (hasExports)
actions |= ContextualActions.EXPORT;
if (hasFormats)
actions |= ContextualActions.FORMAT_TEXT;
return actions;
}
public void CancelSampling(int pointerId)
{
Editor?.PointerCancel(pointerId);
_pointerId = -1;
}
private bool HasPart()
{
return Editor?.Part != null;
}
private void Capture_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var uiElement = sender as UIElement;
var p = e.GetCurrentPoint(uiElement);
if (!HasPart())
return;
if (_pointerId != -1)
return;
// Consider left button only
if ( (!p.Properties.IsLeftButtonPressed) || (p.Properties.PointerUpdateKind != Windows.UI.Input.PointerUpdateKind.LeftButtonPressed) )
return;
// Capture the pointer to the target.
uiElement?.CapturePointer(e.Pointer);
try
{
_pointerId = (int)e.Pointer.PointerId;
_lastPointerPosition = new Graphics.Point((float)p.Position.X, (float)p.Position.Y);
_onScroll = false;
// Send pointer down event to the editor
Editor?.PointerDown((float)p.Position.X, (float)p.Position.Y, GetTimestamp(p), p.Properties.Pressure, e.Pointer.PointerDeviceType.ToNative(), GetPointerId(e));
}
catch (System.Exception ex)
{
if (ex.HResult == (int)MyScript.IInk.ExceptionHResult.POINTER_SEQUENCE_ERROR)
{
// Special case: pointerDown already called, discard previous and retry
Editor?.PointerCancel(GetPointerId(e));
Editor?.PointerDown((float)p.Position.X, (float)p.Position.Y, GetTimestamp(p), p.Properties.Pressure, e.Pointer.PointerDeviceType.ToNative(), GetPointerId(e));
}
else
{
var dlg = new MessageDialog(ex.Message);
var dlgTask = dlg.ShowAsync();
}
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
private void Capture_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var uiElement = sender as UIElement;
var p = e.GetCurrentPoint(uiElement);
if (!HasPart())
return;
if (_pointerId != (int)e.Pointer.PointerId)
return;
// Ignore pointer move when the pointing device is up
if (!p.IsInContact)
return;
// Consider left button only
if (!p.Properties.IsLeftButtonPressed)
return;
var pointerType = e.Pointer.PointerDeviceType.ToNative();
var previousPosition = _lastPointerPosition;
_lastPointerPosition = new Graphics.Point((float)p.Position.X, (float)p.Position.Y);
var pointerTool = Editor.ToolController.GetToolForType(pointerType);
if (!_onScroll && pointerTool == PointerTool.HAND)
{
var deltaMin = 3.0f;
var deltaX = _lastPointerPosition.X - previousPosition.X;
var deltaY = _lastPointerPosition.Y - previousPosition.Y;
_onScroll = Editor.IsScrollAllowed() && ((System.Math.Abs(deltaX) > deltaMin) || (System.Math.Abs(deltaY) > deltaMin));
if (_onScroll)
{
// Entering scrolling mode, cancel previous pointerDown event
Editor?.PointerCancel(GetPointerId(e));
}
}
if (_onScroll)
{
// Scroll the view
var deltaX = _lastPointerPosition.X - previousPosition.X;
var deltaY = _lastPointerPosition.Y - previousPosition.Y;
Scroll(-deltaX, -deltaY);
}
else
{
var pointList = e.GetIntermediatePoints(uiElement);
if (pointList.Count > 0)
{
var events = new PointerEvent[pointList.Count];
// Intermediate points are stored in reverse order:
// Revert the list and send the pointer events all at once
int j = 0;
for (int i = pointList.Count - 1; i >= 0; i--)
{
var p_ = pointList[i];
events[j++] = new PointerEvent(PointerEventType.MOVE, (float)p_.Position.X, (float)p_.Position.Y, GetTimestamp(p_), p_.Properties.Pressure, pointerType, GetPointerId(e));
}
// Send pointer move events to the editor
try
{
Editor?.PointerEvents(events);
}
catch
{
// Don't show error for every move event
}
}
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
private void Capture_PointerReleased(object sender, PointerRoutedEventArgs e)
{
var uiElement = sender as UIElement;
var p = e.GetCurrentPoint(uiElement);
if (!HasPart())
return;
if (_pointerId != (int)e.Pointer.PointerId)
return;
// Consider left button only
if ( (p.Properties.IsLeftButtonPressed) || (p.Properties.PointerUpdateKind != Windows.UI.Input.PointerUpdateKind.LeftButtonReleased) )
return;
var previousPosition = _lastPointerPosition;
_lastPointerPosition = new Graphics.Point((float)p.Position.X, (float)p.Position.Y);
if (_onScroll)
{
// Scroll the view
var deltaX = _lastPointerPosition.X - previousPosition.X;
var deltaY = _lastPointerPosition.Y - previousPosition.Y;
Scroll(-deltaX, -deltaY);
// Exiting scrolling mode
_onScroll = false;
}
else
{
// Send pointer up event to the editor
try
{
Editor?.PointerUp((float)p.Position.X, (float)p.Position.Y, GetTimestamp(p), p.Properties.Pressure, e.Pointer.PointerDeviceType.ToNative(), GetPointerId(e));
}
catch
{
// Don't show error for up event
}
}
_pointerId = -1;
// Release the pointer captured from the target
uiElement?.ReleasePointerCapture(e.Pointer);
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
private void Capture_PointerCanceled(object sender, PointerRoutedEventArgs e)
{
var uiElement = sender as UIElement;
var p = e.GetCurrentPoint(uiElement);
if (!HasPart())
return;
if (_pointerId != (int)e.Pointer.PointerId)
return;
// When using mouse consider left button only
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
if (!p.Properties.IsLeftButtonPressed)
return;
}
if (_onScroll)
{
// Exiting scrolling mode
_onScroll = false;
}
else
{
// Send pointer cancel event to the editor
Editor.PointerCancel(GetPointerId(e));
}
_pointerId = -1;
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
private void Capture_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
var uiElement = renderCanvas; //sender as UIElement;
var properties = e.GetCurrentPoint(uiElement).Properties;
if (!HasPart())
return;
if (properties.IsHorizontalMouseWheel == false)
{
var WHEEL_DELTA = 120;
var controlDown = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
var shiftDown = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
var wheelDelta = properties.MouseWheelDelta / WHEEL_DELTA;
if (controlDown)
{
if (wheelDelta > 0)
ZoomIn((uint)wheelDelta);
else if (wheelDelta < 0)
ZoomOut((uint)(-wheelDelta));
}
else
{
var SCROLL_SPEED = 100;
var delta = (float)(-SCROLL_SPEED * wheelDelta);
var deltaX = shiftDown ? delta : 0.0f;
var deltaY = shiftDown ? 0.0f : delta;
Scroll(deltaX, deltaY);
}
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
public void ResetView(bool forceInvalidate)
{
if (!(Editor?.Renderer is Renderer renderer) || !HasPart())
return;
// Reset view offset and scale
renderer.ViewScale = 1;
renderer.ViewOffset = new Graphics.Point(0, 0);
// Get new view transform (keep only scale and offset)
var tr = renderer.GetViewTransform();
tr = new Graphics.Transform(tr.XX, tr.YX, 0, tr.XY, tr.YY, 0);
// Compute new view offset
var offset = new Graphics.Point(0, 0);
if (Editor.Part.Type == "Raw Content")
{
// Center view on the center of content for "Raw Content" parts
var contentBox = Editor.GetRootBlock().Box;
var contentCenter = new Graphics.Point(contentBox.X + (contentBox.Width * 0.5f), contentBox.Y + (contentBox.Height * 0.5f));
// From model coordinates to view coordinates
contentCenter = tr.Apply(contentCenter.X, contentCenter.Y);
var viewCenter = new Graphics.Point(Editor.ViewWidth * 0.5f, Editor.ViewHeight * 0.5f);
offset.X = contentCenter.X - viewCenter.X;
offset.Y = contentCenter.Y - viewCenter.Y;
}
else
{
// Move the origin to the top-left corner of the page for other types of parts
var boxV = Editor.Part.ViewBox;
offset.X = boxV.X;
offset.Y = boxV.Y;
// From model coordinates to view coordinates
offset = tr.Apply(offset.X, offset.Y);
}
// Set new view offset
Editor.ClampViewOffset(offset);
renderer.ViewOffset = offset;
if (forceInvalidate)
Invalidate(renderer, LayerType.LayerType_ALL);
}
public void ZoomIn(uint delta)
{
if (!(Editor?.Renderer is Renderer renderer)) return;
renderer.Zoom((float)delta * (110.0f / 100.0f));
Invalidate(renderer, LayerType.LayerType_ALL);
}
public void ZoomOut(uint delta)
{
if (!(Editor?.Renderer is Renderer renderer)) return;
renderer.Zoom((float)delta * (100.0f / 110.0f));
Invalidate(renderer, LayerType.LayerType_ALL);
}
private void Scroll(float deltaX, float deltaY)
{
if (!(Editor?.Renderer is Renderer renderer)) return;
var oldOffset = renderer.ViewOffset;
var newOffset = new Graphics.Point(oldOffset.X + deltaX, oldOffset.Y + deltaY);
Editor.ClampViewOffset(newOffset);
renderer.ViewOffset = newOffset;
Invalidate(renderer, LayerType.LayerType_ALL);
}
}
}