Esempio n. 1
0
        public void Round()
        {
            Assert.AreEqual(sizeI, sizeD.Round());
            Assert.AreEqual(sizeI, new SizeD(0.6, 1.6).Round());
            Assert.AreEqual(sizeI, new SizeD(1.4, 2.4).Round());

            Assert.AreEqual(sizeI, sizeF.Round());
            Assert.AreEqual(sizeI, new SizeF(0.6f, 1.6f).Round());
            Assert.AreEqual(sizeI, new SizeF(1.4f, 2.4f).Round());
        }
Esempio n. 2
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            var size = SizeD.Round(Conversion.WorldToScreen(
                                       new SizeD(barWidth / 100.0, 0.0), worldRect, canvasRect));
            var barWd = Math.Max(size.Width, 2);

            var left  = worldRect.Left <= 0 ? 0 : (int)worldRect.Left;
            var right = worldRect.Right >= data.Count ? data.Count - 1 : (int)worldRect.Right;

            if (right <= left)
            {
                return;
            }

            for (var i = left; i <= right; i++)
            //foreach (var bar in data)
            {
                var   bar      = data[i];
                Point pointTop =
                    Conversion.WorldToScreen(
                        new PointD(bar.index - 0.45, bar.y),
                        worldRect,
                        canvasRect).Round();
                Point pointBottom =
                    Conversion.WorldToScreen(
                        new PointD(bar.index - 0.45, 0),
                        worldRect,
                        canvasRect).Round();
                using (var brush = new SolidBrush(bar.color))
                {
                    var low    = Math.Min(pointTop.Y, pointBottom.Y);
                    var height = Math.Abs(pointTop.Y - pointBottom.Y);

                    g.FillRectangle(brush, pointTop.X - (barWd / 2), low,
                                    barWd, height);
                }
            }
        }