当前位置: 首页>>代码示例>>C#>>正文


C# PointF.Count方法代码示例

本文整理汇总了C#中System.Drawing.PointF.Count方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.Count方法的具体用法?C# PointF.Count怎么用?C# PointF.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDisparitiesLK

        public double[] GetDisparitiesLK(Image<Gray, byte> leftImg, Image<Gray, byte> rightImg, PointF[] points, Image<Gray, short> precalcDepthMap, VisualOdometerDisparitiesParams parameters)
        {
            var param = (VisualOdometerDisparitiesParamsLK)parameters;
            var res = new double[points.Count()];

            Size WinSize = param.WinSize;// new Size(80, 80);
            int PyrLevel = param.PyrLevel;// 4;
            MCvTermCriteria PyrLkTerm = param.PyrLkTerm;// new MCvTermCriteria(100, 0.001);

            var status = new Byte[points.Count()];
            var error = new float[points.Count()];
            var rightPoints = new PointF[points.Count()];

            var subCorners = new PointF[1][];
            subCorners[0] = points;
            leftImg.FindCornerSubPix(
                subCorners,
                new Size(11, 11),
                new Size(-1, -1),
                new MCvTermCriteria(30, 0.01));

            var leftCorners = subCorners[0];

            var gpuP = new GpuPyrLKOpticalFlow(WinSize, PyrLevel, 30, false);

            OpticalFlow.PyrLK(
                leftImg,
                rightImg,
                leftCorners,
                WinSize,
                PyrLevel,
                PyrLkTerm,
                out rightPoints,
                out status,
                out error);

            for (int i = 0; i < points.Count(); ++i)
            {
                if (status[i] == 1)
                {
                    var disp = leftCorners[i].X - rightPoints[i].X;
                    if (disp < 0)
                    {
                        res[i] = -1;
                    }
                    else
                    {
                        res[i] = disp;
                    }
                }
                else
                {
                    res[i] = -1;
                }
            }

            return res;
        }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:58,代码来源:VisualOdometer.cs

示例2: FindMinRectangle

        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);
        }
开发者ID:Bubeee,项目名称:RoadSigns.VBP,代码行数:35,代码来源:Homoraphy.cs

示例3: isPointInPolygon

 private static bool isPointInPolygon(PointF[] polygon, PointF testPoint)
 {
     bool result = false;
     int j = polygon.Count() - 1;
     for (int i = 0; i < polygon.Count(); i++)
     {
         if (polygon[i].Y < testPoint.Y && polygon[j].Y >= testPoint.Y || polygon[j].Y < testPoint.Y && polygon[i].Y >= testPoint.Y)
         {
             if (polygon[i].X + (testPoint.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) * (polygon[j].X - polygon[i].X) < testPoint.X)
             {
                 result = !result;
             }
         }
         j = i;
     }
     return result;
 }
开发者ID:pmichna,项目名称:Clipping_Dolphin,代码行数:17,代码来源:MainForm.cs

示例4: GetDisparities

        public double[] GetDisparities(Image<Gray, byte> leftImg, Image<Gray, byte> rightImg, PointF[] points, Image<Gray, short> precalcDepthMap, VisualOdometerDisparitiesParams parameters)
        {
            //TEST LK
            //return this.GetDisparitiesLK(leftImg, rightImg, points, precalcDepthMap, parameters);
            ////
            var res = new double[points.Count()];

            for (int i = 0; i < points.Count(); ++i)
            {
                if (points[i].X >= leftImg.Width || points[i].X < 0 || points[i].Y >= leftImg.Height || points[i].Y < 0)
                {
                    res[i] = -1;
                    continue;
                }

                res[i] = precalcDepthMap[(int)points[i].Y, (int)points[i].X].Intensity;
            }

            return res;
        }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:20,代码来源:VisualOdometer.cs

示例5: CalcCircumference

        public static float CalcCircumference(PointF[] points)
        {
            float P = 0;

            int type = points.Count();
            for (int i = 0; i < type - 1; i++)
            {
                P += sideLength(points[i], points[i + 1]);
            }
            P += sideLength(points[0], points[type - 1]);
            Console.WriteLine(P);
            return P;
        }
开发者ID:nutinka,项目名称:HackBulgariaCourse,代码行数:13,代码来源:PolygonCircumference.cs

示例6: DrawGraps

        private void DrawGraps()
        {
            var g = Graphics.FromImage(DrawArea);

            float yStep = (float) ((DrawArea.Height - VerticalShiftLine)*0.01);
            float xStep = (float) ((DrawArea.Width - HorisontalShiftLine)*0.01);
            int t = 0;

            foreach (var curve in Curves) {
                if (curve.Length > 1) {
                    var points = new PointF[curve.Length];
                    float xValue = 0.0f;
                    float yValue = 0.0f;

                    for (int i = 0; i < curve.Length; i++) {
                        xValue = curve.GetData().XPercent[i];
                        yValue = curve.GetData().YPercent[i];
                        if (xValue > 100)
                            xValue = 100f;

                        if (yValue > 100)
                            yValue = 100f;

                        if (xValue < 0)
                            xValue = 0f;

                        if (yValue < 0)
                            yValue = 0f;

                        points[i].X = xValue*xStep + HorisontalShiftLine;
                        points[i].Y = DrawArea.Height - yValue*yStep - VerticalShiftLine;
                    }
                    if (points.Count() > 1)
                        g.DrawCurve(new Pen(curve.ColorCurve, 3), points);
                }
            }
        }
开发者ID:pulse-computer-consulting,项目名称:NucleusPub,代码行数:37,代码来源:SimpleGrp.cs

示例7: drawGrid

 private void drawGrid(Graphics graphics, double maxValue, PointF[] avgpoints, float yScale, float xScale)
 {
     using (var gridPen = new Pen(Color.LightGray))
     {
         for (int i = 10; i < maxValue; i += 10)
         {
             var gridLine = new PointF[2];
             gridLine[0] = new PointF(0, i);
             gridLine[1] = new PointF(avgpoints.Count() - 1, i);
             drawGraphLine(graphics, gridLine, gridPen, yScale, xScale);
         }
         for (int i = 50; i < avgpoints.Count(); i += 50)
         {
             var gridLine = new PointF[2];
             gridLine[0] = new PointF(i, 0);
             gridLine[1] = new PointF(i, (int)maxValue);
             drawGraphLine(graphics, gridLine, gridPen, yScale, xScale);
         }
     }
 }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:20,代码来源:Graph.cs

示例8: ReprojectTo3d

        public Matrix<double>[] ReprojectTo3d(Image<Gray, byte> leftImg, double[] disps, PointF[] points, Matrix<double> Q)
        {
            var res = new Matrix<double>[points.Count()];
            for (int i = 0; i < points.Count(); ++i)
            {
                if (points[i].X >= leftImg.Width || points[i].X < 0 || points[i].Y >= leftImg.Height || points[i].Y < 0)
                {
                    res[i] = null;
                    continue;
                }

                //
                if (disps[i] <= 0)
                {
                    res[i] = null;
                    continue;
                }

                var p = new Matrix<double>(new double[,]
                {
                    {points[i].X},
                    {points[i].Y},
                    {disps[i]},
                    {1}
                });

                var ph3d = Q.Mul(p);
                if (ph3d[3, 0] == 0)
                {
                    res[i] = null;
                    continue;
                }

                res[i] = new Matrix<double>(new double[,]
                    {
                        {ph3d[0, 0] / ph3d[3, 0]},
                        {ph3d[1, 0] / ph3d[3, 0]},
                        {ph3d[2, 0] / ph3d[3, 0]}
                    });
            }
            return res;
        }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:42,代码来源:VisualOdometer.cs

示例9: GetFeaturesOpticFlow

        public void GetFeaturesOpticFlow(PointF[] origF, Image<Gray, byte> img1, Image<Gray, byte> img2, out PointF[] prevCorrFeatures, out PointF[] currCorrFeatures, VisualOdometerFeaturesOpticFlowParams parameters)
        {
            var param = (VisualOdometerFeaturesOpticFlowParamsLK)parameters;
            Size WinSize = param.WinSize;// new Size(80, 80);
            int PyrLevel = param.PyrLevel;// 4;
            MCvTermCriteria PyrLkTerm = param.PyrLkTerm;// new MCvTermCriteria(100, 0.001);

            var status = new Byte[origF.Count()];
            var error = new float[origF.Count()];
            var currFeatures = new PointF[origF.Count()];

            OpticalFlow.PyrLK(
                img1,
                img2,
                origF,
                WinSize,
                PyrLevel,
                PyrLkTerm,
                out currFeatures,
                out status,
                out error);

            List<PointF> pAct = new List<PointF>();
            List<PointF> cAct = new List<PointF>();

            for (int i = 0; i < origF.Count(); ++i)
            {
                if (status[i] == 1)
                {
                    pAct.Add(origF[i]);
                    cAct.Add(currFeatures[i]);
                }
            }

            prevCorrFeatures = pAct.ToArray();
            currCorrFeatures = cAct.ToArray();
        }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:37,代码来源:VisualOdometer.cs

示例10: LoadPoints

        //Allow the user to import an array of points to be used to draw a signature in the view, with new
        //lines indicated by a PointF.Empty in the array.
        public void LoadPoints(PointF[] loadedPoints)
        {
            if (loadedPoints == null || loadedPoints.Count () == 0)
                return;

            var startIndex = 0;
            var emptyIndex = loadedPoints.ToList ().IndexOf (PointF.Empty);

            if (emptyIndex == -1)
                emptyIndex = loadedPoints.Count ();

            //Clear any existing paths or points.
            paths = new List<UIBezierPath> ();
            points = new List<PointF[]> ();

            do {
                //Create a new path and set the line options
                currentPath = UIBezierPath.Create ();
                currentPath.LineWidth = StrokeWidth;
                currentPath.LineJoinStyle = CGLineJoin.Round;

                currentPoints = new List<PointF> ();

                //Move to the first point and add that point to the current_points array.
                currentPath.MoveTo (loadedPoints [startIndex]);
                currentPoints.Add (loadedPoints [startIndex]);

                //Iterate through the array until an empty point (or the end of the array) is reached,
                //adding each point to the current_path and to the current_points array.
                for (var i = startIndex + 1; i < emptyIndex; i++) {
                    currentPath.AddLineTo (loadedPoints [i]);
                    currentPoints.Add (loadedPoints [i]);
                }

                //Add the current_path and current_points list to their respective Lists before
                //starting on the next line to be drawn.
                paths.Add (currentPath);
                points.Add (currentPoints.ToArray ());

                //Obtain the indices for the next line to be drawn.
                startIndex = emptyIndex + 1;
                if (startIndex < loadedPoints.Count () - 1) {
                    emptyIndex = loadedPoints.ToList ().IndexOf (PointF.Empty, startIndex);

                    if (emptyIndex == -1)
                        emptyIndex = loadedPoints.Count ();
                } else
                    emptyIndex = startIndex;
            } while (startIndex < emptyIndex);

            //Obtain the image for the imported signature and display it in the image view.
            imageView.Image = GetImage (false);
            //Display the clear button.
            btnClear.Hidden = false;
            SetNeedsDisplay ();
        }
开发者ID:rrawla,项目名称:SignaturePad,代码行数:58,代码来源:SignaturePadView.cs

示例11: DrawSegments

        public void DrawSegments(PointF[] Stroke)
        {
            if (RenderMethod == RenderMode.Standard)
            {
                // Ensure that surface is visible
                if (!this.Visible)
                {
                    this.TopMost = true;
                    this.Show();
                }

                // Create list of points that are new this draw
                List<PointF> NewPoints = new List<PointF>();

                // Get number of points added since last draw including last point of last stroke and add new points to new points list
                int iDelta = Stroke.Count() - LastStroke.Count() + 1;
                NewPoints.AddRange(Stroke.Skip(Stroke.Count() - iDelta).Take(iDelta));

                // Draw new line segments to main drawing surface
                SurfaceGraphics.DrawLines(DrawingPen, NewPoints.Select(p => TranslatePoint(p)).ToArray());

                // Set last stroke to copy of current stroke
                // ToList method creates value copy of stroke list and assigns it to last stroke
                LastStroke = Stroke.ToList();
            }
            else
            {
                foreach (CompatibilitySurface surface in CompatibilitySurfaces)
                    surface.SurfaceGraphics.DrawLines(DrawingPen, surface.OffsetPoints(Stroke));
            }
        }
开发者ID:floatas,项目名称:highsign,代码行数:31,代码来源:Surface.cs

示例12: Calibrate

        private void Calibrate(IEnumerable<Image<Gray, byte>> images, int nx, int ny, int useUncalibrated, float _squareSize /* Chessboard square size in cm */)
        {
            int displayCorners = 1;
            int showUndistorted = 1;
            bool isVerticalStereo = false;//OpenCV can handle left-right
                                      //or up-down camera arrangements
            const int maxScale = 1;

            //FILE* f = fopen(imageList, "rt");
            int i, j, lr, nframes, n = nx*ny, N = 0;

               List<MCvPoint3D32f> objectPoints;

               var points = new List<MCvPoint2D64f>[2];

               List<int> npoints;
               List<char>[] active = new List<char>[2];

               var temp = new PointF[n];

            var imageSize = new System.Drawing.Size(0,0);

            // ARRAY AND VECTOR STORAGE:
            Matrix<double> _M1 = new Matrix<double>(3, 3);
            Matrix<double> _M2 = new Matrix<double>(3, 3);
            Matrix<double> _D1 = new Matrix<double>(1, 5);
            Matrix<double> _D2 = new Matrix<double>(1, 5);
            Matrix<double> _R =  new Matrix<double>(3, 3);
            Matrix<double> _T =  new Matrix<double>(3, 1);
            Matrix<double> _E =  new Matrix<double>(3, 3);
            Matrix<double> _F =  new Matrix<double>(3, 3);
            Matrix<double> _Q =  new Matrix<double>(4, 4);

            double [,] M1 = _M1.Data;
            double [,] M2 = _M2.Data;
            double [,] D1 = _D1.Data;
            double [,] D2 = _D2.Data;

            double [,] R = _R.Data;
            double [,] T = _T.Data;
            double [,] E = _E.Data;
            double [,] F = _F.Data;

            double [,] Q = _Q.Data;

            for(i=0;i<images.Count();i++)
            {
            int count = 0, result=0;

            lr = i % 2;

            List<MCvPoint2D64f> pts = points[lr];

            var img = images.ElementAt(i);

            imageSize = img.Size;

            //FIND CHESSBOARDS AND CORNERS THEREIN:
            for( int s = 1; s <= maxScale; s++ )
            {
            var timg = img;

            if( s > 1 )
            {
                timg=new Image<Gray,byte>(img.Width * s, img.Height * s);

                img.Resize(timg.Width, timg.Height, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
            }

            temp = Emgu.CV.CameraCalibration.FindChessboardCorners(timg, new Size(nx, ny),
                Emgu.CV.CvEnum.CALIB_CB_TYPE.ADAPTIVE_THRESH | Emgu.CV.CvEnum.CALIB_CB_TYPE.NORMALIZE_IMAGE);

            Emgu.CV.CameraCalibration.

            result = temp.Count();

            if( timg != img )
                timg.Dispose();

            if( result == 0 || s == maxScale)
                for( j = 0; j < count; j++ )
                {
                    temp[j].X /= s;
                    temp[j].Y /= s;
                }
            if( result )
                break;
            }
            if( displayCorners )
            {
            printf("%s\n", buf);
            IplImage* cimg = cvCreateImage( imageSize, 8, 3 );
            cvCvtColor( img, cimg, CV_GRAY2BGR );
            cvDrawChessboardCorners( cimg, cvSize(nx, ny), &temp[0],
                count, result );
            cvShowImage( "corners", cimg );
            cvReleaseImage( &cimg );
            if( cvWaitKey(0) == 27 ) //Allow ESC to quit
                exit(-1);
            }
//.........这里部分代码省略.........
开发者ID:smiron,项目名称:stereo-face-recognition,代码行数:101,代码来源:FormCalibrateCameras.cs

示例13: GetFit

        private double GetFit(PointF[] Pts, out SizeF EllipseDims)
        {
            float MinX, MinY, MaxX, MaxY;
            if (Pts.Length > 0)
            {
                MinX = MaxX = Pts[0].X;
                MinY = MaxY = Pts[0].Y;
            }
            else { EllipseDims = new SizeF(0f, 0f); return 0d; }
            Action<PointF> CheckMins = f =>
            { MinX = Math.Min(MinX, f.X); MinY = Math.Min(MinY, f.Y); MaxX = Math.Max(MaxX, f.X); MaxY = Math.Max(MaxY, f.Y); };
            for (int i = 1; i < Pts.Length; i++) CheckMins(Pts[i]);
            RectangleF BoundBox = new RectangleF(MinX, MinY, MaxX - MinX + 1, MaxY - MinY + 1);
            EllipseDims = BoundBox.Size;
            //Area of an ellipse = a*b*PI
            //We can't assume that the ellipse contains all of the specified points (e.g. hollow rectangle)
            //So we need to count which ones it does contain
            int[] temp;
            int count;
            return Constants.CalcFit(
                count = Pts.Count(
                p => p.X >=
                    (temp = GetXs(mEllHeight, mEllWidth, mImgSec.Height, mImgSec.Width, (int)p.Y, mRotation))[0] && p.X <= temp[1]),
                    (int)(BoundBox.Width / 2f * BoundBox.Height / 2f * Math.PI - count));

            //The following is brilliant but stupid
            //I'd love to follow up on all of this
            //Basically, it creates an ellipse from four points
            //But it's getting too long, so, for now, I'll cheap out and just fit the bounding box
            /*
             * http://mathforum.org/library/drmath/view/54485.html
             * http://www.algebra.com/algebra/homework/equations/THEO-20100329.lesson
             * Correlation between nonstandard
             * ax^2+cy^2+dx+ey+f=0
             * and standard
             * (x-H)^2/A^2+(y-K)^2/B^2=1
             *
             * H = -d/(2a)
             * K = -e/(2c)
             * A^2 = (-f+d^2/(4a)+e^2/(4c))/a
             * B^2 = (-f+d^2/(4a)+e^2/(4c))/c
             *
             * Now, based on that relationship, and that A > width/2, you can deduce
             * a=(-4f+d^2/a+e^2/2)/w^2
             * Where w is the maximum width needed for the ellipse
             * Now to solve for all the others: since we'll be working with four points, we can deduce four variables, C, D, E, and F
             * f = -a*k^2-c*h^2-d*k-e*h
             * c = -(a*m^2+d*m+f+e*n)/n^2
             * d = -(a*o^2+p*(c*p+e)+f)/o
             * e = -(a*q^2+c*r^2+d*q+f)/r
             *
             * For each one of those, plug in a different point
             *
             * f=-a*x1^2-c*y1-d*x1-e*y1
             * c=-(a*x2^2+d*x2+f+e*y2)/y2^2
             *  substitute and solve for f
             *  f=-a*x1^2-(-(a*x2^2+d*x2+f+e*y2)/y2^2)*y1-d*x1-e*y1
             *
             *  if x1=k, y1=h, x2=m, y2=n, x3=o, y3=p, x4=q, y4=r
             *
             *  f=-a*k^2-(-(a*m^2+d*m+f+e*n)/n^2)*h-d*k-e*h
             *  f=(a*(k^2 n^2-h m^2)+d (k n^2-h m)+e h (n-1) n)/(h-n^2)
             *  f=(((k*n^2-h*m)*(-(p*((p*(-(a*m^2)-d*m-f-e*n))/n^2+e))-a*o^2-f))/o+a*(k^2*n^2-h*m^2)+e*h*(n-1)*n)/(h-n^2)
             *  f=((a*(k^2*n^2-h*m^2))/(h-n^2)+(a*m^2*p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))-(a*o*(k*n^2-h*m))/(h-n^2)+(d*m*p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))+(g*p^2*(k*n^2-h*m))/(n*o*(h-n^2))-(g*p*(k*n^2-h*m))/(o*(h-n^2))+(g*h*(n-1)*n)/(h-n^2))/(-(p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))+(k*n^2-h*m)/(o*(h-n^2))+1)
             *  f = (f1+f2)/f3
             *   f1 = (a*(k^2*n^2-h*m^2))/(h-n^2)+(a*m^2*p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))-(a*o*(k*n^2-h*m))/(h-n^2)+(d*m*p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))
             *   f2 = (g*p^2*(k*n^2-h*m))/(n*o*(h-n^2))-(g*p*(k*n^2-h*m))/(o*(h-n^2))+(g*h*(n-1)*n)/(h-n^2)
             *   f3 = (-(p^2*(k*n^2-h*m))/(n^2*o*(h-n^2))+(k*n^2-h*m)/(o*(h-n^2))+1)
             *
             * finding c and e in terms of d,
             * c = (-(m (-a o^2-p (c p+e)-f))/o-a m^2-f-e n)/n^2
             * e = (-a o^2 q+a o q^2+c o r^2-c p^2 q+f o-f q)/(p q-o r)
             * combine
             * c = (-(m (-p ((-a o^2 q+a o q^2+c o r^2-c p^2 q+f o-f q)/(p q-o r)+c p)-a o^2-f))/o-(n (-a o^2 q+a o q^2+c o r^2-c p^2 q+f o-f q))/(p q-o r)-a m^2-f)/n^2
             * or, in terms of c
             *
             *
             *
             * so
             */
        }
开发者ID:scnerd,项目名称:Picasso,代码行数:81,代码来源:Ellipse.cs

示例14: DrawDays

        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);
            }
        }
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:53,代码来源:KirokuBox2.cs

示例15: splitContainer1_Panel1_Paint

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {
            Point offset = Point.Empty;

            offset.X += splitContainer1.Panel1.AutoScrollPosition.X;
            offset.Y += splitContainer1.Panel1.AutoScrollPosition.Y;

            //RectangleF cameraRect = new RectangleF(offset.X * -1, offset.Y * -1, splitContainer1.Panel1.Width, splitContainer1.Panel1.Height);

            foreach (cObject obj in objectManager.ObjectList)
            {
                if (obj != objectManager.SelectedObject)
                {
                    //e.Graphics.DrawImage(obj.Image, obj.Rectangle);

                    e.Graphics.DrawImage(obj.Image,
                                            new RectangleF((obj.Position.X * zoomLevel + offset.X),
                                                (obj.Position.Y * zoomLevel + offset.Y) ,
                                                obj.Image.Width * zoomLevel,
                                                obj.Image.Height * zoomLevel),
                                            new RectangleF(0, 0,  obj.Image.Width,  obj.Image.Height),
                                            GraphicsUnit.Pixel);
                }
            }

            if (objectManager.SelectedObject != null)
            {
                //e.Graphics.DrawImage(objectManager.SelectedObject.Image, objectManager.SelectedObject.Rectangle);
                //e.Graphics.DrawRectangle(new Pen(Color.Black, 3), objectManager.SelectedObject.Rectangle);
                e.Graphics.DrawImage(objectManager.SelectedObject.Image,
                                            new RectangleF((objectManager.SelectedObject.Position.X * zoomLevel + offset.X) ,
                                                (objectManager.SelectedObject.Position.Y * zoomLevel + offset.Y) ,
                                                objectManager.SelectedObject.Image.Width * zoomLevel,
                                                objectManager.SelectedObject.Image.Height * zoomLevel),
                                            new RectangleF(0, 0, objectManager.SelectedObject.Image.Width, objectManager.SelectedObject.Image.Height),
                                            GraphicsUnit.Pixel);
                e.Graphics.DrawRectangle(new Pen(Color.Black, 3), (objectManager.SelectedObject.Position.X * zoomLevel + offset.X) ,
                                                (objectManager.SelectedObject.Position.Y * zoomLevel + offset.Y) ,
                                                objectManager.SelectedObject.Image.Width * zoomLevel,
                                                objectManager.SelectedObject.Image.Height * zoomLevel);

                if (collisionPolygonToolStripMenuItem.Checked)
                {
                    if (objectManager.SelectedObject.CollisionPoints.Count > 0)
                    {
                        if (objectManager.SelectedObject.CollisionPoints.Count > 1)
                        {
                            Pen pen = new Pen(Color.Red, 2);

                            PointF[] tempy = new PointF[objectManager.SelectedObject.CollisionPoints.Count];
                            objectManager.SelectedObject.CollisionPoints.CopyTo(tempy);
                            for(int i = 0; i < tempy.Count(); ++i)
                            {
                                tempy[i] = new PointF((tempy[i].X * zoomLevel + offset.X), (tempy[i].Y * zoomLevel + offset.Y));
                            }

                            e.Graphics.DrawLines(pen, tempy);

                            if (objectManager.SelectedObject.CollisionPoints.Count > 2)
                            {
                                e.Graphics.DrawLine(pen,
                                    new PointF(tempy[0].X, tempy[0].Y),
                                    new PointF(tempy[tempy.Count() - 1].X, tempy[tempy.Count() - 1].Y));

                                if (objectManager.SelectedObject.CollisionPoints.Count > 3)
                                    label_NotConvex.Visible = !isConvex;
                            }
                        }

                        foreach (PointF p in objectManager.SelectedObject.CollisionPoints)
                        {
                            if (objectManager.SelectedObject.SelectedPoint != -1 &&
                                p == objectManager.SelectedObject.CollisionPoints[objectManager.SelectedObject.SelectedPoint])
                            {
                                e.Graphics.DrawEllipse(new Pen(Color.Blue, 4), (p.X * zoomLevel - (pointSize / 2) + offset.X), (p.Y * zoomLevel - (pointSize / 2) + offset.Y), pointSize, pointSize);
                                continue;
                            }
                            e.Graphics.FillEllipse(new SolidBrush(Color.Blue), (p.X * zoomLevel - (pointSize / 2) + offset.X), (p.Y * zoomLevel - (pointSize / 2) + offset.Y), pointSize, pointSize);
                        }
                    }
                }
            }
        }
开发者ID:Ethanthecrazy,项目名称:ATHEngine,代码行数:83,代码来源:MainForm.cs


注:本文中的System.Drawing.PointF.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。