void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
     {
     case 1:
         this.ToolTip = ((Panuon.UI.Charts.PUChartToolTip)(target));
         return;
     }
     this._contentLoaded = true;
 }
Example #2
0
        private void InitLine(double actualWidth, double actualHeight, bool usingAnima)
        {
            if (XAxis == null || YAxis == null || Points == null)
            {
                return;
            }

            ScaleTransform scale;

            if (usingAnima)
            {
                scale = new ScaleTransform()
                {
                    ScaleY = 0
                }
            }
            ;
            else
            {
                scale = new ScaleTransform()
                {
                    ScaleY = 1
                }
            };

            polygon.RenderTransform  = scale;
            polyline.RenderTransform = scale;


            var cvaHeight = actualHeight - _xHeight;
            var cvaWidth  = actualWidth - _yWidth;

            var xHeight = cvaHeight / (YAxis.Count - 0.5);
            var yWidth  = cvaWidth / (XAxis.Count - 0.5);

            var realHeight = cvaHeight - xHeight * 0.5;

            polyline.Points.Clear();
            polygon.Points.Clear();
            canvasPoints.Children.Clear();

            var count = XAxis.Count > Points.Count ? Points.Count : XAxis.Count;

            for (int i = 0; i < count; i++)
            {
                var point = new Point(yWidth * i, (1 - Points[i].Value) * realHeight + 0.5 * xHeight);
                polyline.Points.Add(point);
                polygon.Points.Add(point);
                var ell     = new Ellipse();
                var toolTip = new PUChartToolTip()
                {
                    Header = XAxis[i], Value = Points[i].ValueTip
                };

                var cover = new Binding()
                {
                    Source = this, Path = new PropertyPath("LineBrush"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };
                BindingOperations.SetBinding(toolTip, PUChartToolTip.CoverBrushProperty, cover);
                ell.ToolTip = toolTip;

                var back = new Binding()
                {
                    Source = this, Path = new PropertyPath("LineBrush"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };
                BindingOperations.SetBinding(ell, Ellipse.FillProperty, back);
                var size = new Binding()
                {
                    Source = this, Path = new PropertyPath("PointSize"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };
                BindingOperations.SetBinding(ell, Ellipse.WidthProperty, size);
                BindingOperations.SetBinding(ell, Ellipse.HeightProperty, size);
                Canvas.SetLeft(ell, yWidth * i - PointSize / 2);
                if (usingAnima)
                {
                    Canvas.SetTop(ell, cvaHeight - PointSize / 2);
                    ell.BeginAnimation(Canvas.TopProperty, GetDoubleAnimation((1 - Points[i].Value) * realHeight + 0.5 * xHeight - PointSize / 2, 1));
                }
                else
                {
                    Canvas.SetTop(ell, (1 - Points[i].Value) * realHeight + 0.5 * xHeight - PointSize / 2);
                }

                canvasPoints.Children.Add(ell);
            }

            polygon.Points.Add(new Point(yWidth * (Points.Count - 1), cvaHeight));
            polygon.Points.Add(new Point(0, cvaHeight));
            if (usingAnima)
            {
                scale.BeginAnimation(ScaleTransform.ScaleYProperty, GetDoubleAnimation(1, 1));
            }
        }