/// <summary> /// Position this tile (in viewport coordinates) /// </summary> public void MoveTo(double x, double y) { if ((int)_x == (int)x && (int)_y == (int)y) { return; } _x = x; _y = y; UiCanvas.QueueAction(canv => { if (canv == null) { return; } canv.RenderTransform = new TranslateTransform { X = (int)_x, Y = (int)_y }; }); }
/// <summary> /// Remove a control from display and return it to the pool /// </summary> public static void Retire(CanvasControlAsyncProxy ctrl) { if (ctrl == null) { return; } ctrl.RemoveFromContainer(); ctrl.QueueAction(canv => { if (canv != null) { canv.Draw -= _drawHub.Draw; } }); }
public static CanvasControlAsyncProxy Employ([NotNull] Panel container, [NotNull] CachedTile cachedTile, double x, double y) { // Need a new canvas var proxy = new CanvasControlAsyncProxy(container); var targetTile = cachedTile; container.Dispatcher?.RunAsync(CoreDispatcherPriority.High, () => { var ctrl = new CanvasControl { Margin = new Thickness(0.0), Height = 256, Width = 256, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, UseLayoutRounding = false, RenderTransform = new TranslateTransform { X = x, Y = y } }; proxy.QueueAction(canv => { // We have a single common 'Draw' event hook and use context data to pump in image & state if (canv == null) { return; } canv.Draw += _drawHub.Draw; }); proxy.AttachToContainer(ctrl, container, targetTile); }); return(proxy); }