Example #1
0
        public void Draw(Win32DCSafeHandle hdc, int lineThickness, uint rgbColor)
        {
            if (lineThickness < 1)
            {
                lineThickness = 1;
            }
            Win32.LOGBRUSH lOGBRUSH = default(Win32.LOGBRUSH);
            lOGBRUSH.lbColor = rgbColor;
            lOGBRUSH.lbHatch = 0;
            lOGBRUSH.lbStyle = 0u;
            Win32ObjectSafeHandle win32ObjectSafeHandle  = Win32.ExtCreatePen(66048u, (uint)lineThickness, ref lOGBRUSH, 0u, null);
            Win32ObjectSafeHandle win32ObjectSafeHandle2 = Win32ObjectSafeHandle.Zero;

            try
            {
                win32ObjectSafeHandle2 = Win32.SelectObject(hdc, win32ObjectSafeHandle);
                Win32.MoveToEx(hdc, this.m_startPoint.X, this.m_startPoint.Y, IntPtr.Zero);
                Win32.LineTo(hdc, this.m_endPoint.X, this.m_endPoint.Y);
            }
            finally
            {
                if (!win32ObjectSafeHandle2.IsInvalid)
                {
                    Win32ObjectSafeHandle win32ObjectSafeHandle3 = Win32.SelectObject(hdc, win32ObjectSafeHandle2);
                    win32ObjectSafeHandle3.SetHandleAsInvalid();
                    win32ObjectSafeHandle2.SetHandleAsInvalid();
                }
                if (!win32ObjectSafeHandle.IsInvalid)
                {
                    win32ObjectSafeHandle.Close();
                    win32ObjectSafeHandle = null;
                }
            }
        }