/// <summary> /// Update ellipse with the most recent touch device data. If an ellipse has not /// been created yet, create one. /// </summary> /// <param name="touchDevice">the touch device to diagram</param> private void UpdateEllipse(TouchDevice touchDevice) { UIElement relativeTo = this; // Create an ellipse if one does not exist already. if (twoToneEllipse == null) { // Request an ellipse with the proper dimensions and RenderTransform. twoToneEllipse = touchDevice.GetEllipse(relativeTo); // Give the ellipse a two color fill. LinearGradientBrush twoToneBrush = new LinearGradientBrush(); twoToneBrush.StartPoint = new Point(1.0, 0.5); twoToneBrush.EndPoint = new Point(0.0, 0.5); GradientStopCollection gradientStops = new GradientStopCollection(); gradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0x57, 0x27), 0.49)); gradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF3, 0x7A, 0x53), 0.51)); twoToneBrush.GradientStops = gradientStops; twoToneEllipse.Fill = twoToneBrush; // Add the ellipse to the MainCanvas. MainCanvas.Children.Add(twoToneEllipse); // Give the Ellipse a lower ZIndex than the ConnectingLine and Description // so it is not drawn on top of them. Canvas.SetZIndex(twoToneEllipse, -1); } else { // This diagram already has an ellipse. Update the existing ellipse // dimensions and RenderTransform so the shape will match the touchDevice. touchDevice.UpdateEllipse(twoToneEllipse, relativeTo); } }