Пример #1
0
        public override void paintText(ref Graphics graphics, ref Bitmap bitmap)
        {
            Rectangle rcText    = mRectItem;
            int       newLeft   = rcText.Left + mTextPadding.Left;
            int       newRight  = rcText.Right - mTextPadding.Right;
            int       newTop    = rcText.Top + mTextPadding.Top;
            int       newBottom = rcText.Bottom - mTextPadding.Bottom;

            rcText.X      = newLeft;
            rcText.Width  = newRight - newLeft;
            rcText.Y      = newTop;
            rcText.Height = newBottom - newTop;

            if (mCurSel >= 0)
            {
                ControlUI   pControl = (ControlUI)mItems[mCurSel];
                IListItemUI pElement = (IListItemUI)pControl.getInterface("ListItem");
                if (pElement != null)
                {
                    pElement.drawItemText(ref graphics, ref bitmap, ref rcText);
                }
                else
                {
                    Rectangle rcOldPos = pControl.getPos();
                    pControl.setPos(rcText);
                    pControl.doPaint(ref graphics, ref bitmap, rcText);
                    pControl.setPos(rcOldPos);
                }
            }
        }
Пример #2
0
        public override void doPaint(ref Graphics graphics, ref Bitmap bitmap, Rectangle rectPaint)
        {
            Rectangle rcTemp;

            if (rectPaint.IntersectsWith(mRectItem) == false)
            {
                return;
            }
            rcTemp = rectPaint;
            rcTemp.Intersect(mRectItem);

            RenderClip clip = new RenderClip();

            RenderClip.generateClip(ref graphics, rcTemp, ref clip);

            base.doPaint(ref graphics, ref bitmap, rectPaint);

            if (mItems.Count > 0)
            {
                Rectangle rc        = mRectItem;
                int       newLeft   = rc.Left + mRectInset.Left;
                int       newRight  = rc.Right - mRectInset.Right;
                int       newTop    = rc.Top + mRectInset.Top;
                int       newBottom = rc.Bottom - mRectInset.Bottom;

                rc.X      = newLeft;
                rc.Width  = newRight - newLeft;
                rc.Y      = newTop;
                rc.Height = newBottom - newTop;

                // 绘制滚动条
                if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
                {
                    rc.Width = rc.Right - mVerticalScrollbar.getFixedWidth() - rc.Left;
                }
                if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
                {
                    rc.Height = rc.Bottom - mHorizontalScrollbar.getFixedHeight() - rc.Top;
                }

                // 绘制子控件
                if (rectPaint.IntersectsWith(rc) == false)
                {
                    for (int i = mItems.Count - 1; i >= 0; i--)
                    {
                        ControlUI item = mItems[i];
                        if (item.isVisible() == false)
                        {
                            continue;
                        }
                        if (rectPaint.IntersectsWith(item.getPos()) == false)
                        {
                            continue;
                        }
                        if (item.isFloat())
                        {
                            if (mRectItem.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                        }
                    }
                }
                else
                {
                    RenderClip childClip = new RenderClip();
                    RenderClip.generateClip(ref graphics, rcTemp, ref childClip);

                    for (int i = mItems.Count - 1; i >= 0; i--)
                    {
                        ControlUI item = mItems[i];
                        if (item.isVisible() == false)
                        {
                            continue;
                        }
                        if (rectPaint.IntersectsWith(item.getPos()) == false)
                        {
                            continue;
                        }
                        if (item.isFloat())
                        {
                            if (mRectItem.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            RenderClip.useOldClipBegin(ref graphics, ref childClip);
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                            RenderClip.useOldClipEnd(ref graphics, ref childClip);
                        }
                        else
                        {
                            if (rc.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                        }
                    }
                }
            }

            if (mVerticalScrollbar != null &&
                mVerticalScrollbar.isVisible())
            {
                if (rectPaint.IntersectsWith(mVerticalScrollbar.getPos()))
                {
                    mVerticalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                }
            }

            if (mHorizontalScrollbar != null &&
                mHorizontalScrollbar.isVisible())
            {
                if (rectPaint.IntersectsWith(mHorizontalScrollbar.getPos()))
                {
                    mHorizontalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                }
            }
        }
Пример #3
0
        public override void doPaint(ref Graphics graphics, ref Bitmap bitmap, Rectangle rectPaint)
        {
            lock (lockObj)
            {
                Rectangle rcTemp = rectPaint;
                rcTemp.Intersect(mRectItem);
                if (rcTemp.IsEmpty == true)
                {
                    return;
                }
                Region oldRgn = graphics.Clip.Clone();
                graphics.IntersectClip(rcTemp);

                base.doPaint(ref graphics, ref bitmap, rectPaint);

                if (mItems.Count > 0)
                {
                    Rectangle rc        = mRectItem;
                    int       newLeft   = rc.Left + mRectInset.Left;
                    int       newRight  = rc.Right - mRectInset.Right;
                    int       newTop    = rc.Top + mRectInset.Top;
                    int       newBottom = rc.Bottom - mRectInset.Bottom;

                    rc.X      = newLeft;
                    rc.Width  = newRight - newLeft;
                    rc.Y      = newTop;
                    rc.Height = newBottom - newTop;

                    // 绘制滚动条
                    if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
                    {
                        rc.Width -= mVerticalScrollbar.getFixedWidth();
                    }
                    if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
                    {
                        rc.Height -= mHorizontalScrollbar.getFixedHeight();
                    }

                    // 绘制子控件
                    rcTemp = rectPaint;
                    rcTemp.Intersect(rc);
                    if (rcTemp.IsEmpty == true)
                    {
                        foreach (var item in mItems)
                        {
                            if (item.isVisible() == false)
                            {
                                continue;
                            }
                            if (rectPaint.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            if (item.isFloat())
                            {
                                if (mRectItem.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                            }
                        }
                    }
                    else
                    {
                        Region oldRgn1 = graphics.Clip.Clone();
                        graphics.IntersectClip(rcTemp);

                        for (int i = 0; i < mItems.Count; i++)
                        {
                            ControlUI item = mItems[i];
                            if (item.isVisible() == false)
                            {
                                continue;
                            }
                            if (rectPaint.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            if (item.isFloat())
                            {
                                if (mRectItem.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                Region oldRgn2 = graphics.Clip;
                                graphics.Clip = oldRgn1;
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                                graphics.Clip = oldRgn2;
                            }
                            else
                            {
                                if (rc.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                            }
                        }
                        graphics.Clip = oldRgn1;
                    }
                }

                if (mVerticalScrollbar != null &&
                    mVerticalScrollbar.isVisible())
                {
                    if (rectPaint.IntersectsWith(mVerticalScrollbar.getPos()))
                    {
                        mVerticalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                    }
                }

                if (mHorizontalScrollbar != null &&
                    mHorizontalScrollbar.isVisible())
                {
                    if (rectPaint.IntersectsWith(mHorizontalScrollbar.getPos()))
                    {
                        mHorizontalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                    }
                }
                graphics.Clip = oldRgn;
            }
        }