public CachedTile([NotNull] Panel container, PositionKey key, double x, double y) { _key = key; _x = x; _y = y; State = TileState.Locked; UiCanvas = Win2dCanvasManager.Employ(container, this, x, 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); }