예제 #1
0
        public Bars(Plot2D plot2D, ILArray <double> barStart, ILArray <double> barEnd, ILArray <double> barPosition, ILArray <double> barThickness, BarType barType)
        {
            this.plot2D = plot2D;
            int n = barStart.Length;

            rectangles = new List <Path>();
            Geometry geometry;
            Path     rectangle;
            Rect     bounds          = new Rect();
            Rect     rectangleBounds = new Rect();

            for (int i = 0; i < n; ++i)
            {
                rectangle = new Path();
                rectangles.Add(rectangle);
                if (barType == BarType.Horizontal)
                {
                    rectangleBounds = new Rect(new Point(barStart.GetValue(i), barPosition.GetValue(i) + barThickness.GetValue(i) / 2),
                                               new Point(barEnd.GetValue(i), barPosition.GetValue(i) - barThickness.GetValue(i) / 2));
                }
                else
                {
                    rectangleBounds = new Rect(new Point(barPosition.GetValue(i) + barThickness.GetValue(i) / 2, barStart.GetValue(i)),
                                               new Point(barPosition.GetValue(i) - barThickness.GetValue(i) / 2, barEnd.GetValue(i)));
                }
                geometry                  = new RectangleGeometry(rectangleBounds);
                rectangle.Data            = geometry;
                geometry.Transform        = plot2D.GraphToCanvas;
                rectangle.Fill            = (Brush)(this.GetValue(FillProperty));
                rectangle.StrokeThickness = (double)(this.GetValue(StrokeThicknessProperty));
                rectangle.Stroke          = (Brush)(this.GetValue(StrokeProperty));
                if (i == 0)
                {
                    bounds = rectangleBounds;
                }
                else
                {
                    bounds.Union(rectangleBounds);
                }
            }
            Bounds = bounds;
            SetBindings();
        }
예제 #2
0
 public Bars(Plot2D plot2D, ILArray<double> barStart, ILArray<double> barEnd, ILArray<double> barPosition, ILArray<double> barThickness, BarType barType)
 {
     this.plot2D = plot2D;
     int n = barStart.Length;
     rectangles = new List<Path>();
     Geometry geometry;
     Path rectangle;
     Rect bounds = new Rect();
     Rect rectangleBounds = new Rect();
     for (int i = 0; i < n; ++i)
     {
         rectangle = new Path();
         rectangles.Add(rectangle);
         if (barType == BarType.Horizontal)
         {
             rectangleBounds = new Rect(new Point(barStart.GetValue(i), barPosition.GetValue(i) + barThickness.GetValue(i) / 2),
                 new Point(barEnd.GetValue(i), barPosition.GetValue(i) - barThickness.GetValue(i) / 2));
         }
         else
         {
             rectangleBounds = new Rect(new Point(barPosition.GetValue(i) + barThickness.GetValue(i) / 2, barStart.GetValue(i)),
                 new Point(barPosition.GetValue(i) - barThickness.GetValue(i) / 2, barEnd.GetValue(i)));
         }
         geometry = new RectangleGeometry(rectangleBounds);
         rectangle.Data = geometry;
         geometry.Transform = plot2D.GraphToCanvas;
         rectangle.Fill = (Brush)(this.GetValue(FillProperty));
         rectangle.StrokeThickness = (double)(this.GetValue(StrokeThicknessProperty));
         rectangle.Stroke = (Brush)(this.GetValue(StrokeProperty));
         if (i == 0) bounds = rectangleBounds;
         else
         {
             bounds.Union(rectangleBounds);
         }
     }
     Bounds = bounds;
     SetBindings();
 }