Beispiel #1
0
 /// <summary>
 /// draw line
 /// </summary>
 /// <param name="hdc"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="pen"></param>
 public void DrawLine(IntPtr hdc, Point start, Point end, IntPtr pen)
 {
     NativeWindowCommon.MoveToEx(hdc, start.X, start.Y, IntPtr.Zero);
     NativeWindowCommon.SelectObject(hdc, pen);
     NativeWindowCommon.LineTo(hdc, end.X, end.Y);
 }
Beispiel #2
0
        /// <summary>
        /// drow sort marking on the column
        /// </summary>
        /// <param name="hdc"></param>
        /// <param name="rc"></param>
        /// <param name="gr"></param>
        void DrawSortMark(IntPtr hdc, NativeWindowCommon.RECT rc, Graphics gr)
        {
            int iconWidth       = SortIconWidth();
            int topBottomMargin = (this.Header.Height - iconWidth) / 2;
            int iconHeight      = SortIconHeight();


            NativeWindowCommon.POINT[] points = new NativeWindowCommon.POINT[3];
            if (SortMark == HeaderSectionSortMarks.Up)
            {
                points[0].x = rc.right - Header.SORT_ICON_LEFT_RIGHT_MARGIN;
                points[0].y = (rc.bottom + iconHeight) / 2;

                // center point
                points[1].x = points[0].x - iconWidth / 2;
                points[1].y = points[0].y - iconHeight;

                // left point
                points[2].x = points[0].x - iconWidth;
                points[2].y = points[0].y;
            }
            else if (SortMark == HeaderSectionSortMarks.Down)
            {
                //right
                points[0].x = rc.right - Header.SORT_ICON_LEFT_RIGHT_MARGIN;
                points[0].y = (rc.bottom - iconHeight) / 2;

                // center point
                points[1].x = points[0].x - iconWidth / 2;
                points[1].y = points[0].y + iconHeight;

                // left point
                points[2].x = points[0].x - iconWidth;
                points[2].y = points[0].y;
            }

#if !PocketPC
            if (Application.RenderWithVisualStyles)
            {
                //draw XP style sort triangle
                NativeWindowCommon.SelectObject(hdc, Header.SortBrush);
                NativeWindowCommon.SelectObject(hdc, Header.SortPen);
                NativeWindowCommon.Polygon(hdc, points, 3);
            }
            else
#endif
            {
                //draw windows 2000 style sort triangle
                Point[] points1 = new Point[3]
                {
                    new Point(points[0].x, points[0].y),
                    new Point(points[1].x, points[1].y),
                    new Point(points[2].x, points[2].y)
                };

                NativeWindowCommon.MoveToEx(hdc, points1[0].X, points1[0].Y, IntPtr.Zero);
                NativeWindowCommon.SelectObject(hdc, Header.WhitePen);
                NativeWindowCommon.LineTo(hdc, points1[1].X, points1[1].Y);
                NativeWindowCommon.SelectObject(hdc, Header.ButtonShadowPen);
                NativeWindowCommon.LineTo(hdc, points1[2].X, points1[2].Y);
                if (SortMark == HeaderSectionSortMarks.Up)
                {
                    NativeWindowCommon.SelectObject(hdc, Header.WhitePen);
                }
                else
                {
                    NativeWindowCommon.SelectObject(hdc, Header.ButtonShadowPen);
                }
                NativeWindowCommon.LineTo(hdc, points1[0].X, points1[0].Y);
            }
        }