Esempio n. 1
0
        private static RectangleF FindMinRectangle(PointF[] srcPoints)
        {
            if (srcPoints == null || srcPoints.Count() == 0)
            {
                return new RectangleF();
            }

            var maxLeftPoint = srcPoints.First();
            var maxRightPoint = srcPoints.Last();

            foreach (var srcPoint in srcPoints)
            {
                if (srcPoint.X < maxLeftPoint.X)
                {
                    maxLeftPoint.X = srcPoint.X;
                }

                if (srcPoint.Y < maxLeftPoint.Y)
                {
                    maxLeftPoint.Y = srcPoint.Y;
                }

                if (srcPoint.X > maxRightPoint.X)
                {
                    maxRightPoint.X = srcPoint.X;
                }

                if (srcPoint.Y > maxRightPoint.Y)
                {
                    maxRightPoint.Y = srcPoint.Y;
                }
            }

            return new RectangleF(maxLeftPoint.X, maxLeftPoint.Y, maxRightPoint.X - maxLeftPoint.X, maxRightPoint.Y - maxLeftPoint.Y);
        }
Esempio n. 2
0
        protected PointF[] GetLines(double min_length, params Point3D[] points)
        {
            var pre_calc_map = new PointF[points.Length];
            for (int i = 0; i < points.Length; i++)
            {
                pre_calc_map[i] = GetViewCoordinates(points[i]);
            }

            var point_list = new List<PointF>();
            point_list.Add(pre_calc_map.First());

            int end = points.Length - 1;
            for (int i = 0; i < end; i++)
            {
                foreach (var p in SliceLine(min_length, points[i], points[i + 1], pre_calc_map[i], pre_calc_map[i + 1]))
                {
                    point_list.Add(p);
                }
            }

            point_list.Add(pre_calc_map.Last());

            return point_list.ToArray();
        }
		public static BoundingBox Transform(this Matrix matrix, BoundingBox bbox)
		{
			PointF minPoint = new PointF((float)bbox.XMin, (float)bbox.YMin);
			PointF maxPoint = new PointF((float)bbox.XMax, (float)bbox.YMax);
			var points = new PointF[] { minPoint, maxPoint };
			matrix.TransformPoints(points);

			minPoint = points.First();
			maxPoint = points.Last();

			return new BoundingBox(minPoint.X, maxPoint.X, minPoint.Y, maxPoint.Y);
		}
        public void DrawDays(Graphics graphics, RectangleF outer, RectangleF inner, PointF[] points)
        {
            if (!points.Any()) throw new ArgumentException();

            var brush = GetSolidBrush(LineColor);
            var textBrush = GetSolidBrush(Color);
            var font = GetFont("Arial", 12);
            var oldest = GetOldestMondaiResult();
            var newest = GetNewestMondaiResult();
            var height = outer.Bottom - inner.Bottom;
            //			var oldestRectangle = new RectangleF(outer.Left, inner.Bottom, 100f, height);
            var oldestRectangle = new RectangleF(points.Last().X, inner.Bottom, 100f, height);
            var newestRectangle = new RectangleF(points.First().X, inner.Bottom, 100f, height);
            var stringFormat = new StringFormat()
            {
                Alignment = StringAlignment.Near,
                LineAlignment = StringAlignment.Near,
            };

            // 現在時刻からの最古の日数と最新の日数を表示。最新の日数は最古の日数と被らない限り表示する。
            //			var d0 = MondaiResult.GetStringFromTimeSpan(EPuzzleTime.Now - oldest.StartTime);
            var d0 = (EPuzzleTime.Now - oldest.StartTime).GetShortString();

            var size0 = MeasureString(d0, font);
            //			oldestRectangle.X -= size0.Width / 2f;
            var r0 = new RectangleF(oldestRectangle.Left, oldestRectangle.Top, size0.Width, size0.Height);
            graphics.DrawString(d0, font, textBrush, oldestRectangle, stringFormat);

            //			var d1 = MondaiResult.GetStringFromTimeSpan(EPuzzleTime.Now - newest.StartTime);
            var d1 = (EPuzzleTime.Now - newest.StartTime).GetShortString();

            var size1 = MeasureString(d1, font);
            newestRectangle.X -= size1.Width / 2f;
            var r1 = new RectangleF(newestRectangle.Left, newestRectangle.Top, size1.Width, size1.Height);
            if (!r0.IntersectsWith(r1))
            {
                graphics.DrawString(d1, font, textBrush, newestRectangle, stringFormat);
            }

            if (2 > points.Count()) return;
            var newest2 = OrderedItems[1];
            var newest2Rectangle = new RectangleF(points[1].X, inner.Bottom, 100f, height);
            //			var d2 = MondaiResult.GetStringFromTimeSpan(EPuzzleTime.Now - newest2.StartTime);
            var d2 = (EPuzzleTime.Now - newest2.StartTime).GetShortString();

            var size2 = MeasureString(d2, font);
            newest2Rectangle.X -= size2.Width / 2f;
            var r2 = new RectangleF(newest2Rectangle.Left, newest2Rectangle.Top, size2.Width, size2.Height);
            if (!(r0.IntersectsWith(r2) || r1.IntersectsWith(r2)))
            {
                graphics.DrawString(d2, font, textBrush, newest2Rectangle, stringFormat);
            }
        }