/// <summary> /// Gets the symbol for the datapoint. /// </summary> /// <param name="graphPoint">Point at which the symbol needs to be positioned.</param> /// <returns>A symbol at a specified position.</returns> protected override FrameworkElement GetPlottedDataMarker(GraphPoint graphPoint) { FrameworkElement dataMarkerTemplate = this.DataMarkerTemplate.LoadContent() as FrameworkElement; if (dataMarkerTemplate == null) { throw new ArgumentException(GraphingResources.GraphDisplayDataMarkerError); } Canvas.SetLeft(dataMarkerTemplate, graphPoint.X1Pixel + GraphBase.GetXOffset(dataMarkerTemplate)); Canvas.SetTop(dataMarkerTemplate, graphPoint.Y1Pixel + GraphBase.GetYOffset(dataMarkerTemplate)); if (true == this.DebugDataPointMarkers) { TextBlock tb = new TextBlock(); tb.FontSize = 8; markerCount++; tb.Text = (markerCount - markerCountStart).ToString(System.Globalization.CultureInfo.InvariantCulture); Canvas.SetZIndex(tb, markerCount); Canvas.SetLeft(tb, graphPoint.X1Pixel); Canvas.SetTop(tb, graphPoint.Y1Pixel); this.DynamicPlotLayer.Children.Add(tb); System.Diagnostics.Debug.WriteLine("Added point at " + graphPoint.X1Pixel + " : " + graphPoint.Y1Pixel + " : " + dataMarkerTemplate.ActualHeight + " : " + dataMarkerTemplate.ActualWidth + " Point ID IS : " + tb.Text); } GraphBase.SetDataPoint(dataMarkerTemplate, true); dataMarkerTemplate.Tag = (markerCount - markerCountStart).ToString(System.Globalization.CultureInfo.InvariantCulture); return(dataMarkerTemplate); }
/// <summary> /// Overridden. process the Point based on the previous value. /// </summary> /// <param name="previousPoint">Previous Point Plotted.</param> /// <param name="currentPoint">Current Point Plotted.</param> protected override void ProcessPlottedDataMarker(GraphPoint previousPoint, GraphPoint currentPoint) { if (this.Minimized) { base.ProcessPlottedDataMarker(previousPoint, currentPoint); } else { // override to process other information if ((previousPoint.X1Pixel != 0 || previousPoint.Y1Pixel != 0) && this.ShowInterpolationLines) { // define the zindex for the line based on that of the data marker FrameworkElement dataMarkerTemplate = this.DataMarkerTemplate.LoadContent() as FrameworkElement; int zindex = Canvas.GetZIndex(dataMarkerTemplate) - 2; Line interpolationLine = new Line(); Canvas.SetZIndex(interpolationLine, zindex); interpolationLine.Stroke = this.InterpolationLineColor; interpolationLine.StrokeThickness = this.InterpolationLineThickness; if (previousPoint.X1Pixel < 0) { interpolationLine.Y1 = TimeLineGraph.GetYAtX(0, new Point(previousPoint.X1Pixel, previousPoint.Y1Pixel), new Point(currentPoint.X1Pixel, currentPoint.Y1Pixel)); interpolationLine.X1 = 0; } else { interpolationLine.X1 = previousPoint.X1Pixel; interpolationLine.Y1 = previousPoint.Y1Pixel; } if (currentPoint.X1Pixel > this.DynamicMainLayerViewport.ActualWidth) { interpolationLine.Y2 = TimeLineGraph.GetYAtX(this.DynamicMainLayerViewport.ActualWidth, new Point(previousPoint.X1Pixel, previousPoint.Y1Pixel), new Point(currentPoint.X1Pixel, currentPoint.Y1Pixel)); interpolationLine.X2 = this.DynamicMainLayerViewport.ActualWidth; } else { interpolationLine.X2 = currentPoint.X1Pixel; interpolationLine.Y2 = currentPoint.Y1Pixel; } this.DynamicPlotLayer.Children.Add(interpolationLine); } } }
private FrameworkElement Register(FrameworkElement element, bool label) { FrameworkElement result = null; double left = Canvas.GetLeft(element); bool pad = false; if (left % 1 > 0) { // add 1 to the upper x so we include all pixels we touch pad = true; } int lowerX = (int)left; // The code below performs the measuring of the elements. // Wpf and Silverlight behave in different ways, so the code // is built for both. // SL will evaluate the size of a textblock immediately // but WPF does not. Also, Binding happens immediately but in WPF it does not. // For the above reasons we restrict the label template to be a border and a textblock, // and we assume the binding is to the ToString property of the bound // TimePoint. // The code here ensures that any TextBlock has its height and width // Set explicitly so the measure clal will report the correct size. #if SILVERLIGHT int upperX = (int)(lowerX + element.ActualWidth); if (0 == element.ActualWidth) { element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); upperX = (int)(lowerX + element.DesiredSize.Width); } #else Visibility rememberVisibility = element.Visibility; element.Visibility = Visibility.Visible; int upperX; if (true == label) { Border border = element as Border; if (null != border) { TextBlock textBlock = border.FindName("ELEMENT_labelTextBlock") as TextBlock; if (null != textBlock) { GraphPoint gp = textBlock.DataContext as GraphPoint; if (null != gp.DataContext) { if (string.IsNullOrEmpty(textBlock.Text)) { // WPF will not have bound the text for the label. // The default template for the label is ToString. // We will measure based off of this for WPF. // Should the developer using this control not want // to use the default binding of ToString of their supplied // object then this will need to be changed to set // the text to what they require. textBlock.Text = gp.DataContext.ToString(); } } } } } element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); upperX = (int)(lowerX + element.DesiredSize.Width); element.Visibility = rememberVisibility; #endif if (true == pad) { upperX++; } for (int i = lowerX; i < upperX; i++) { this.RegisterXToElement(element, i); } result = this.DoesElementClash(element); return(result); }