Esempio n. 1
0
 public Chart3DControlLib()
 {
     InitializeComponent();
     this.cs             = new ChartStyle2D();
     this.ds             = new Bar3DStyle();
     this.d3c            = new Draw3DChart();
     this.cs.ChartCanvas = chartCanvas;
 }
Esempio n. 2
0
        public void AddColorBar2D(ChartStyle2D cs, DataSeriesSurface ds, Draw3DChart dsc, double zmin, double zmax)
        {
            TextBlock tb;

            tb            = new TextBlock();
            tb.Text       = "A";
            tb.FontFamily = cs.TickFont;
            tb.FontSize   = cs.TickFontSize;
            tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            Size tickSize = tb.DesiredSize;

            double x      = 8 * cs.ChartCanvas.Width / 9;
            double y      = 7;
            double width  = cs.ChartCanvas.Width / 25;
            double height = chart2dCanvas.Height;

            Point3D[] pts = new Point3D[64];
            double    dz  = (zmax - zmin) / 63;

            // Create the color bar:
            Polygon plg;

            for (int i = 0; i < 64; i++)
            {
                pts[i] = new Point3D(x, y, zmin + i * dz);
            }
            for (int i = 0; i < 63; i++)
            {
                SolidColorBrush brush = dsc.GetBrush(pts[i].Z, zmin, zmax);
                double          y1    = y + height - (pts[i].Z - zmin) * height / (zmax - zmin);
                double          y2    = y + height - (pts[i + 1].Z - zmin) * height / (zmax - zmin);
                plg = new Polygon();
                plg.Points.Add(new Point(x, y2));
                plg.Points.Add(new Point(x + width, y2));
                plg.Points.Add(new Point(x + width, y1));
                plg.Points.Add(new Point(x, y1));
                plg.Fill   = brush;
                plg.Stroke = brush;
                cs.ChartCanvas.Children.Add(plg);
            }
            Rectangle rect = new Rectangle();

            rect.Width  = width + 2;
            rect.Height = height + 2;
            rect.Stroke = Brushes.Black;
            Canvas.SetLeft(rect, x - 1);
            Canvas.SetTop(rect, y - 1);
            cs.ChartCanvas.Children.Add(rect);

            // Add ticks and labels to the color bar:
            double tickLength = 0.15 * width;

            for (double z = zmin; z <= zmax; z = z + (zmax - zmin) / 6)
            {
                double yy = y + height - (z - zmin) * height / (zmax - zmin);
                dsc.AddTickLine(cs, new Point(x, yy), new Point(x + tickLength, yy));
                dsc.AddTickLine(cs, new Point(x + width, yy), new Point(x + width - tickLength, yy));
                tb            = new TextBlock();
                tb.Text       = (Math.Round(z, 2)).ToString();
                tb.FontFamily = cs.TickFont;
                tb.FontSize   = cs.TickFontSize;
                cs.ChartCanvas.Children.Add(tb);
                Canvas.SetLeft(tb, x + width + 5);
                Canvas.SetTop(tb, yy - tickSize.Height / 2);
            }
        }