public async Task Draw(CanvasVertex canvasVertex) { await Application.Current.Dispatcher.InvokeAsync(() => { var ellipse = new Ellipse { Width = EllipseSize, Height = EllipseSize, Fill = Brushes.Red }; var tb = new TextBlock { Text = canvasVertex.Id.ToString(), Background = Brushes.Transparent, FontSize = 15, }; this.SetOnCanvas(ellipse, canvasVertex); this.SetOnCanvas(tb, canvasVertex); this.VerticesOnCanvas.TryAdd(canvasVertex.PrimaryVertex, new Tuple <Ellipse, TextBlock>(ellipse, tb)); this.Canvas.Children.Add(ellipse); this.Canvas.Children.Add(tb); }); }
private void SetOnCanvas(FrameworkElement element, CanvasVertex canvasVertex) { Application.Current.Dispatcher.InvokeAsync(() => { Canvas.SetLeft(element, (this.Canvas.Width / 2) + canvasVertex.X - (element.Height / 2)); Canvas.SetTop(element, (this.Canvas.Height / 2) + canvasVertex.Y - (element.Height / 2)); }); }