Exemplo n.º 1
0
        internal void FillRectangle(Color color, int x, int y, int width, int height)
        {
            int        iOldColor = SetBkColor(__cHDC, ColorTranslator.ToWin32(color));
            Rectangle4 cRect     = new Rectangle4(x, y, x + width, y + height);

            ExtTextOut(__cHDC, 0, 0, ETOOptions.ETO_OPAQUE, ref cRect, string.Empty, 0, IntPtr.Zero);
            SetBkColor(__cHDC, iOldColor);
        }
Exemplo n.º 2
0
        internal static bool TextFix(ref Point point, Rectangle4 area, SizeF textSize)
        {
            int iY = point.Y;
            int iTextWidth = (int)textSize.Width;
            int iX = point.X - iTextWidth / 2, iW = point.X + iTextWidth / 2;

            point.X = (iX <= area.Left) ? point.X : (iW >= area.Right) ? area.Right - iTextWidth : iX;
            return(iY >= area.Top && iY <= area.Bottom);
        }
Exemplo n.º 3
0
        internal static bool RayFix(ref Point point1, ref Point point2, Rectangle4 area)
        {
            bool   bRet = true;
            double dMY = point2.Y - point1.Y, dMX = point2.X - point1.X;
            double dM         = dMY / dMX;
            Point  cBasePoint = point1;

            if (point1.X > point2.X)
            {
                if (!FixRayFromX(ref point1, cBasePoint, area, dM, area.Right))
                {
                    bRet = FixRayFromY(ref point1, cBasePoint, area, dM, (point1.Y > point2.Y) ? area.Bottom : area.Top);
                }

                if (!FixRayFromX(ref point2, cBasePoint, area, dM, area.Left))
                {
                    bRet = FixRayFromY(ref point2, cBasePoint, area, dM, (point2.Y > cBasePoint.Y) ? area.Bottom : area.Top);
                }
            }
            else
            {
                if (double.IsInfinity(dM))
                {
                    if (point1.X >= area.Left && point1.X <= area.Right)
                    {
                        if (point1.Y > point2.Y)
                        {
                            point1.Y = area.Bottom;
                            point2.Y = area.Top;
                        }
                        else
                        {
                            point1.Y = area.Top;
                            point2.Y = area.Bottom;
                        }
                    }
                    else
                    {
                        bRet = false;
                    }
                }
                else
                {
                    if (!FixRayFromX(ref point1, cBasePoint, area, dM, area.Left))
                    {
                        bRet = FixRayFromY(ref point1, cBasePoint, area, dM, (point1.Y > point2.Y) ? area.Bottom : area.Top);
                    }

                    if (!FixRayFromX(ref point2, cBasePoint, area, dM, area.Right))
                    {
                        bRet = FixRayFromY(ref point2, cBasePoint, area, dM, (point2.Y > cBasePoint.Y) ? area.Bottom : area.Top);
                    }
                }
            }
            return(bRet);
        }
Exemplo n.º 4
0
        internal static bool BoundFix(ref Point point1, ref Point point2, Rectangle4 area)
        {
            double dMY = point2.Y - point1.Y, dMX = point2.X - point1.X;
            double dM = dMY / dMX;

            bool bRet1 = CheckBound(ref point1, point1, area, dM);
            bool bRet2 = CheckBound(ref point2, point1, area, dM);

            return((bRet1 || bRet2) && point1 != point2);
        }
Exemplo n.º 5
0
        internal static bool RayRightFix(ref Point point1, ref Point point2, Rectangle4 area)
        {
            Point cPoint1 = point1;
            bool  bRet    = RayFix(ref cPoint1, ref point2, area);

            if (bRet && (point1.Y < area.Top || point1.Y > area.Bottom))
            {
                point1 = cPoint1;
            }
            return(bRet);
        }
Exemplo n.º 6
0
        private static bool FixRayFromY(ref Point point, Point point1, Rectangle4 area, double m, int y)
        {
            int iX = CalculateX(point1, m, y);

            if (iX >= area.Left && iX <= area.Right)
            {
                point.X = iX;
                point.Y = y;
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
        private static bool FixRayFromX(ref Point point, Point point1, Rectangle4 area, double m, int x)
        {
            int iY = CalculateY(point1, m, x);

            if (iY >= area.Top && iY <= area.Bottom)
            {
                point.X = x;
                point.Y = iY;
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        internal _TextInfo DrawRopString(string text, Color foreColor, Color background, int x, int y, Rectangle rect)
        {
            IntPtr hMemDC     = CreateCompatibleDC(__cHDC);
            IntPtr hBitmap    = CreateCompatibleBitmap(__cHDC, rect.Width, rect.Height);
            IntPtr cOldObject = SelectObject(hMemDC, hBitmap);

            BitBlt(hMemDC, 0, 0, rect.Width, rect.Height, __cHDC, rect.X, rect.Y, TernaryRasterOperations.SRCCOPY);

            int        iOldColor     = SetTextColor(__cHDC, ColorTranslator.ToWin32(foreColor));
            int        iOldBackColor = SetBkColor(__cHDC, ColorTranslator.ToWin32(background));
            Rectangle4 cRect4        = new Rectangle4(rect);

            ExtTextOut(__cHDC, 0, 0, ETOOptions.ETO_OPAQUE, ref cRect4, string.Empty, 0, IntPtr.Zero);
            TextOut(__cHDC, rect.X + x, rect.Y + y, text, text.Length);
            SetBkColor(__cHDC, iOldBackColor);

            _TextInfo cTextInfo = new _TextInfo(new IntPtr[] { hMemDC, hBitmap, cOldObject }, rect.X, rect.Y, rect.Width, rect.Height);

            if (__bSaveRop)
            {
                __cTextInfos.Add(cTextInfo);
            }
            return(cTextInfo);
        }
Exemplo n.º 9
0
 private static extern bool ExtTextOut(IntPtr hdc, int X, int Y, ETOOptions fuOptions, [In] ref Rectangle4 lprc, [MarshalAs(UnmanagedType.LPWStr)] string lpString, uint cbCount, [In] IntPtr lpDx);
Exemplo n.º 10
0
        private static bool CheckBound(ref Point point, Point point1, Rectangle4 area, double m)
        {
            int iX = point.X, iY = point.Y;

            if (iX < area.Left)
            {
                int iAL = area.Left;
                int iFY = CalculateY(point1, m, iAL);
                if (iFY >= area.Top && iFY <= area.Bottom)
                {
                    point.X = iAL;
                    point.Y = iFY;
                    return(true);
                }
            }

            if (iX > area.Right)
            {
                int iAR = area.Right;
                int iFY = CalculateY(point1, m, iAR);
                if (iFY >= area.Top && iFY <= area.Bottom)
                {
                    point.X = iAR;
                    point.Y = iFY;
                    return(true);
                }
            }

            if (iY < area.Top)
            {
                int iAT = area.Top;
                if (double.IsInfinity(m))
                {
                    point.Y = iAT;
                    return(point.X >= area.Left && point.X <= area.Right);
                }
                else
                {
                    int iFX = CalculateX(point1, m, iAT);
                    if (iFX >= area.Left && iFX <= area.Right)
                    {
                        point.X = iFX;
                        point.Y = iAT;
                        return(true);
                    }
                }
            }

            if (iY > area.Bottom)
            {
                int iAB = area.Bottom;
                if (double.IsInfinity(m))
                {
                    point.Y = iAB;
                    return(point.X >= area.Left && point.X <= area.Right);
                }
                else
                {
                    int iFX = CalculateX(point1, m, iAB);
                    if (iFX >= area.Left && iFX <= area.Right)
                    {
                        point.X = iFX;
                        point.Y = iAB;
                        return(true);
                    }
                }
            }
            return(point.X >= area.Left && point.X <= area.Right && point.Y >= area.Top && point.Y <= area.Bottom);
        }
Exemplo n.º 11
0
 public bool Equals(Rectangle4 r)
 {
     return(r.__iLeft == __iLeft && r.__iTop == __iTop && r.__iRight == __iRight && r.__iBottom == __iBottom);
 }