示例#1
0
        public void UpdateView(RECT aRect)
        {
            if (!FVisible)
            {
                return;
            }

            FGraphicCanvas.Brush.Color = HC.clBtnFace;
            FGraphicCanvas.FillRect(HC.Bounds(0, 0, FGraphic.Width, FGraphic.Height));
            FGraphicCanvas.Pen.Color = Color.FromArgb(240, 240, 240);
            FGraphicCanvas.MoveTo(0, 0);
            FGraphicCanvas.LineTo(0, FGraphic.Height - 2);
            FGraphicCanvas.LineTo(FGraphic.Width - 2, FGraphic.Height - 2);
            FGraphicCanvas.LineTo(FGraphic.Width - 2, 0);
            FGraphicCanvas.LineTo(0, 0);

            FGraphicCanvas.Pen.Color = Color.FromArgb(0x66, 0x66, 0x66);
            FGraphicCanvas.MoveTo(1, FGraphic.Height - 1);
            FGraphicCanvas.LineTo(FGraphic.Width - 1, FGraphic.Height - 1);
            FGraphicCanvas.LineTo(FGraphic.Width - 1, 1);

            int vLeft = FPadding;

            for (int i = 0; i < FControls.Count; i++)
            {
                if (FControls[i] is HCCustomToolButton)
                {
                    if (i == FActiveIndex)
                    {
                        FGraphicCanvas.Brush.Color = Color.FromArgb(51, 153, 255);
                        FGraphicCanvas.FillRect(HC.Bounds(vLeft, 1, FControls[i].Width, FGraphic.Height - 3));
                    }
                    else
                    if (i == FHotIndex)
                    {
                        FGraphicCanvas.Brush.Color = Color.FromArgb(0, 102, 204);
                        FGraphicCanvas.FillRect(HC.Bounds(vLeft, 1, FControls[i].Width, FGraphic.Height - 3));
                    }

                    if (FOnControlPaint != null)
                    {
                        FOnControlPaint(FControls[i], vLeft, 0, FGraphicCanvas);
                    }
                    else
                    {
                        FControls[i].PaintTo(vLeft, 0, FGraphicCanvas);
                    }
                }

                vLeft = vLeft + FControls[i].Width + FPadding;
            }

            if (FOnUpdateView != null)
            {
                FOnUpdateView(aRect, FGraphicCanvas);
            }
        }
示例#2
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom,
                         aCanvas, aPaintInfo);

            RECT vBoxRect = GetBoxRect();

            HC.OffsetRect(ref vBoxRect, aDrawRect.Left, aDrawRect.Top);

            if (aPaintInfo.Print)
            {
                if (FChecked)
                {
                    HC.HCDrawFrameControl(aCanvas, vBoxRect, HCControlState.hcsChecked, HCControlStyle.hcyCheck);
                }
                else
                {
                    HC.HCDrawFrameControl(aCanvas, vBoxRect, HCControlState.hcsCustom, HCControlStyle.hcyCheck);
                }
            }
            else
            {
                if (this.IsSelectComplate)
                {
                    aCanvas.Brush.Color = aStyle.SelColor;
                    aCanvas.FillRect(aDrawRect);
                }
                else
                if (FMouseIn)
                {
                    aCanvas.Brush.Color = HC.clBtnFace;
                    aCanvas.FillRect(aDrawRect);
                }

                if (FChecked)
                {
                    aCanvas.Brush.Style = HCBrushStyle.bsSolid;
                    User.DrawFrameControl(aCanvas.Handle, ref vBoxRect, Kernel.DFC_MENU, Kernel.DFCS_CHECKED | Kernel.DFCS_MENUCHECK);
                }

                HC.HCDrawFrameControl(aCanvas, vBoxRect, HCControlState.hcsCustom, HCControlStyle.hcyCheck);
            }

            aCanvas.Brush.Style = HCBrushStyle.bsClear;
            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            if (FBoxRight)
            {
                aCanvas.TextOut(aDrawRect.Left, aDrawRect.Top + (Height - aCanvas.TextHeight("H")) / 2, FText);
            }
            else
            {
                aCanvas.TextOut(aDrawRect.Left + FPaddingLeft + CheckBoxSize + FPaddingLeft, aDrawRect.Top + (Height - aCanvas.TextHeight("H")) / 2, FText);
            }
        }
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop,
                         aDataScreenBottom, aCanvas, aPaintInfo);

            if (aPaintInfo.Print)
            {
            }
            else
            if (this.IsSelectComplate)
            {
                aCanvas.Brush.Color = aStyle.SelColor;
                aCanvas.FillRect(aDrawRect);
            }
            else
            if (FMouseIn)
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            if (!AutoSize)
            {
                RECT vRect = new RECT();
                GDI.GetClipBox(aCanvas.Handle, ref vRect);

                IntPtr vPaintRegion = GDI.CreateRectRgn(aDrawRect.Left, aDrawRect.Top, aDrawRect.Right, aDrawRect.Bottom);
                try
                {
                    GDI.SelectClipRgn(aCanvas.Handle, vPaintRegion);
                    DoPaintItems(aCanvas, aDrawRect, aPaintInfo);
                }
                finally
                {
                    GDI.DeleteObject(vPaintRegion);
                }

                vPaintRegion = GDI.CreateRectRgnIndirect(ref vRect);
                try
                {
                    GDI.SelectClipRgn(aCanvas.Handle, vPaintRegion);
                }
                finally
                {
                    GDI.DeleteObject(vPaintRegion);
                }
            }
            else
            {
                DoPaintItems(aCanvas, aDrawRect, aPaintInfo);
            }
        }
示例#4
0
        public virtual bool SaveToBitmap(ref Bitmap aBitmap)
        {
            if ((FWidth == 0) || (FHeight == 0))
            {
                return(false);
            }

            aBitmap = new Bitmap(FWidth, FHeight);
            PaintInfo vPaintInfo = new PaintInfo();

            vPaintInfo.Print        = true;
            vPaintInfo.WindowWidth  = aBitmap.Width;
            vPaintInfo.WindowHeight = aBitmap.Height;
            vPaintInfo.ScaleX       = 1;
            vPaintInfo.ScaleY       = 1;
            vPaintInfo.Zoom         = 1;

            using (HCCanvas vCanvas = new HCCanvas())
            {
                vCanvas.Graphics    = Graphics.FromImage(aBitmap);
                vCanvas.Brush.Color = Color.White;
                vCanvas.FillRect(new RECT(0, 0, aBitmap.Width, aBitmap.Height));
                this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height),
                             0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo);

                vCanvas.Dispose();
            }

            return(true);
        }
示例#5
0
        protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom,
                                        int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo)
        {
            base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop,
                         ADataScreenBottom, ACanvas, APaintInfo);

            FButtonDrawRect = FButtonRect;
            FButtonDrawRect.Offset(ADrawRect.Left, ADrawRect.Top);
            if (FMouseInButton)
            {
                ACanvas.Brush.Color = HC.clMenu;
            }
            else
            {
                ACanvas.Brush.Color = HC.clWindow;
            }

            ACanvas.FillRect(FButtonDrawRect);
            ACanvas.Pen.Color = Color.Black;
            int vLeft = FButtonDrawRect.Left + (BTNWIDTH - 7) / 2;
            int vTop  = FButtonDrawRect.Top + (FButtonDrawRect.Height - 4) / 2;

            for (int i = 0; i <= 3; i++)
            {
                ACanvas.MoveTo(vLeft, vTop);
                ACanvas.LineTo(vLeft + 7 - i - i, vTop);
                vLeft++;
                vTop++;
            }
        }
示例#6
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom,
                         aCanvas, aPaintInfo);

            if (this.IsSelectComplate)
            {
                aCanvas.Brush.Color = aStyle.SelColor;
            }
            else
            if (FDown)
            {
                aCanvas.Brush.Color = HC.clHighlight;
            }
            else
            if (FMouseIn)
            {
                aCanvas.Brush.Color = HC.clBtnFace;
            }
            else
            {
                aCanvas.Brush.Color = HC.clMedGray;
            }

            aCanvas.FillRect(aDrawRect);

            aCanvas.Brush.Style = HCBrushStyle.bsClear;
            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            SIZE vSize = aCanvas.TextExtent(FText);

            aCanvas.TextOut(aDrawRect.Left + (aDrawRect.Width - vSize.cx) / 2, aDrawRect.Top + (aDrawRect.Height - vSize.cy) / 2, FText);
        }
示例#7
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop,
                         aDataScreenBottom, aCanvas, aPaintInfo);

            if (FMouseIn)
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);

            POINT vPoint    = new POINT();
            RECT  vItemRect = new RECT();

            for (int i = 0; i <= FItems.Count - 1; i++)
            {
                vPoint.X = FItems[i].Position.X;
                vPoint.Y = FItems[i].Position.Y;
                vPoint.Offset(aDrawRect.Left, aDrawRect.Top);
                vItemRect = HC.Bounds(vPoint.X, vPoint.Y, RadioButtonWidth, RadioButtonWidth);
                if (FItems[i].Checked)
                {
                    User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_CHECKED | Kernel.DFCS_BUTTONRADIO);
                }
                else
                {
                    User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_BUTTONRADIO);
                }

                aCanvas.TextOut(vPoint.X + RadioButtonWidth, vPoint.Y, FItems[i].Text);
            }
        }
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom,
                         aCanvas, aPaintInfo);

            if ((FMouseIn) && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            RECT vBoxRect = GetBoxRect();

            HC.OffsetRect(ref vBoxRect, aDrawRect.Left, aDrawRect.Top);

            if (this.IsSelectComplate && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = aStyle.SelColor;
                aCanvas.FillRect(aDrawRect);
            }

            aCanvas.Brush.Style = HCBrushStyle.bsClear;

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            aCanvas.TextOut(aDrawRect.Left + FMargin + CheckBoxSize + FMargin, aDrawRect.Top + (Height - aCanvas.TextHeight("H")) / 2, FText);

            if (FChecked)  // 勾选
            {
                User.DrawFrameControl(aCanvas.Handle, ref vBoxRect, Kernel.DFC_MENU, Kernel.DFCS_CHECKED | Kernel.DFCS_MENUCHECK);
            }

            aCanvas.Pen.Style = HCPenStyle.psSolid;
            if (FMouseIn && (!aPaintInfo.Print))  // 鼠标在其中,且非打印
            {
                aCanvas.Pen.Color = Color.Blue;
                aCanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
                HC.InflateRect(ref vBoxRect, 1, 1);
                aCanvas.Pen.Color = HC.clBtnFace;
                aCanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
            }
            else  // 鼠标不在其中或打印
            {
                aCanvas.Pen.Color = Color.Black;
                aCanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
            }
        }
示例#9
0
        protected int FResizeX, FResizeY;  // 拖动缩放时起始位置

        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect,
                                        int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom,
                                        HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom,
                         aCanvas, aPaintInfo);

            if ((!aPaintInfo.Print) && Active)
            {
                if (Resizing)
                {
                    switch (FResizeGrip)
                    {
                    case GripType.gtLeftTop:
                        FResizeRect = HC.Bounds(aDrawRect.Left + Width - FResizeWidth,
                                                aDrawRect.Top + Height - FResizeHeight, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtRightTop:
                        FResizeRect = HC.Bounds(aDrawRect.Left,
                                                aDrawRect.Top + Height - FResizeHeight, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtLeftBottom:
                        FResizeRect = HC.Bounds(aDrawRect.Left + Width - FResizeWidth,
                                                aDrawRect.Top, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtRightBottom:
                        FResizeRect = HC.Bounds(aDrawRect.Left, aDrawRect.Top, FResizeWidth, FResizeHeight);
                        break;
                    }

                    aPaintInfo.TopItems.Add(this);
                }

                if (AllowResize)  // 绘制缩放拖动提示锚点
                {
                    aCanvas.Brush.Color = Color.Gray;
                    aCanvas.FillRect(HC.Bounds(aDrawRect.Left, aDrawRect.Top, GripSize, GripSize));
                    aCanvas.FillRect(HC.Bounds(aDrawRect.Right - GripSize, aDrawRect.Top, GripSize, GripSize));
                    aCanvas.FillRect(HC.Bounds(aDrawRect.Left, aDrawRect.Bottom - GripSize, GripSize, GripSize));
                    aCanvas.FillRect(HC.Bounds(aDrawRect.Right - GripSize, aDrawRect.Bottom - GripSize, GripSize, GripSize));
                }
            }
        }
示例#10
0
        public void UpdateView()
        {
            if ((FUpdateCount == 0) && IsHandleCreated)
            {
                if (FMemDC != IntPtr.Zero)
                {
                    GDI.DeleteDC(FMemDC);
                }
                FMemDC = (IntPtr)GDI.CreateCompatibleDC(FDC);

                int    vViewWidth  = GetViewWidth();
                int    vViewHeight = GetViewHeight();
                IntPtr vBitmap     = (IntPtr)GDI.CreateCompatibleBitmap(FDC, vViewWidth, vViewHeight);
                GDI.SelectObject(FMemDC, vBitmap);
                try
                {
                    using (HCCanvas vDataBmpCanvas = new HCCanvas(FMemDC))
                    {
                        // 控件背景
                        vDataBmpCanvas.Brush.Color = Color.White;// $00E7BE9F;
                        vDataBmpCanvas.FillRect(new RECT(0, 0, vViewWidth, vViewHeight));

                        PaintInfo vPaintInfo = new PaintInfo();
                        try
                        {
                            FData.PaintData(this.Padding.Left - FHScrollBar.Position, // 当前页数据要绘制到的Left
                                            this.Padding.Top,                         // 当前页数据要绘制到的Top
                                            this.Width - FHScrollBar.Position - this.Padding.Right,
                                            this.Padding.Top + FData.Height,          // 当前页数据要绘制的Bottom
                                            this.Padding.Top,                         // 界面呈现当前页数据的Top位置
                                            this.Height - FHScrollBar.Height,         // 界面呈现当前页数据Bottom位置
                                            FVScrollBar.Position,                     // 指定从哪个位置开始的数据绘制到页数据起始位置
                                            vDataBmpCanvas,
                                            vPaintInfo);

                            for (int i = 0; i <= vPaintInfo.TopItems.Count - 1; i++)  // 绘制顶层Ite
                            {
                                vPaintInfo.TopItems[i].PaintTop(vDataBmpCanvas);
                            }
                        }
                        finally
                        {
                            vPaintInfo.Dispose();
                        }

                        GDI.BitBlt(FDC, 0, 0, vViewWidth, vViewHeight, FMemDC, 0, 0, GDI.SRCCOPY);
                    }
                }
                finally
                {
                    GDI.DeleteObject(vBitmap);
                }

                RECT vRect = new RECT(0, 0, vViewWidth, vViewHeight);
                User.InvalidateRect(this.Handle, ref vRect, 0);  // 只更新变动区域,防止闪烁,解决BitBlt光标滞留问题
                User.UpdateWindow(this.Handle);
            }
        }
示例#11
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop,
                         aDataScreenBottom, aCanvas, aPaintInfo);

            if (this.IsSelectComplate && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = aStyle.SelColor;
                aCanvas.FillRect(aDrawRect);
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);

            if (!this.AutoSize)
            {
                aCanvas.TextRect(aDrawRect, aDrawRect.Left + FMargin, aDrawRect.Top + FMargin, FText);
            }
            else
            {
                aCanvas.TextOut(aDrawRect.Left + FMargin, aDrawRect.Top + FMargin, FText);
            }

            if (FMouseIn && (!aPaintInfo.Print))
            {
                aCanvas.Pen.Color = Color.Blue;
            }
            else  // 鼠标不在其中或打印
            {
                aCanvas.Pen.Color = Color.Black;
            }

            aCanvas.Pen.Width = FBorderWidth;

            if (FBorderSides.Contains((byte)BorderSide.cbsLeft))
            {
                aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top);
                aCanvas.LineTo(aDrawRect.Left, aDrawRect.Bottom);
            }

            if (FBorderSides.Contains((byte)BorderSide.cbsTop))
            {
                aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top);
                aCanvas.LineTo(aDrawRect.Right, aDrawRect.Top);
            }

            if (FBorderSides.Contains((byte)BorderSide.cbsRight))
            {
                aCanvas.MoveTo(aDrawRect.Right, aDrawRect.Top);
                aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom);
            }

            if (FBorderSides.Contains((byte)BorderSide.cbsBottom))
            {
                aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Bottom);
                aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom);
            }
        }
示例#12
0
        protected int FResizeX, FResizeY;  // 拖动缩放时起始位置

        protected override void DoPaint(HCStyle AStyle, RECT ADrawRect,
                                        int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom,
                                        HCCanvas ACanvas, PaintInfo APaintInfo)
        {
            base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom,
                         ACanvas, APaintInfo);

            if ((!APaintInfo.Print) && Active)
            {
                if (Resizing)
                {
                    switch (FResizeGrip)
                    {
                    case GripType.gtLeftTop:
                        FResizeRect = HC.Bounds(ADrawRect.Left + Width - FResizeWidth,
                                                ADrawRect.Top + Height - FResizeHeight, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtRightTop:
                        FResizeRect = HC.Bounds(ADrawRect.Left,
                                                ADrawRect.Top + Height - FResizeHeight, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtLeftBottom:
                        FResizeRect = HC.Bounds(ADrawRect.Left + Width - FResizeWidth,
                                                ADrawRect.Top, FResizeWidth, FResizeHeight);
                        break;

                    case GripType.gtRightBottom:
                        FResizeRect = HC.Bounds(ADrawRect.Left, ADrawRect.Top, FResizeWidth, FResizeHeight);
                        break;
                    }

                    APaintInfo.TopItems.Add(this);
                }

                // 绘制缩放拖动提示锚点
                ACanvas.Brush.Color = Color.Gray;
                ACanvas.FillRect(HC.Bounds(ADrawRect.Left, ADrawRect.Top, GripSize, GripSize));
                ACanvas.FillRect(HC.Bounds(ADrawRect.Right - GripSize, ADrawRect.Top, GripSize, GripSize));
                ACanvas.FillRect(HC.Bounds(ADrawRect.Left, ADrawRect.Bottom - GripSize, GripSize, GripSize));
                ACanvas.FillRect(HC.Bounds(ADrawRect.Right - GripSize, ADrawRect.Bottom - GripSize, GripSize, GripSize));
            }
        }
示例#13
0
        protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom,
                                        int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo)
        {
            base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom,
                         ACanvas, APaintInfo);

            if ((FMouseIn) && (!APaintInfo.Print))
            {
                ACanvas.Brush.Color = HC.clBtnFace;
                ACanvas.FillRect(ADrawRect);
            }

            RECT vBoxRect = GetBoxRect();

            HC.OffsetRect(ref vBoxRect, ADrawRect.Left, ADrawRect.Top);

            if (this.IsSelectComplate && (!APaintInfo.Print))
            {
                ACanvas.Brush.Color = AStyle.SelColor;
                ACanvas.FillRect(ADrawRect);
            }

            AStyle.TextStyles[TextStyleNo].ApplyStyle(ACanvas, APaintInfo.ScaleY / APaintInfo.Zoom);
            ACanvas.TextOut(ADrawRect.Left + FMargin + CheckBoxSize + FMargin, ADrawRect.Top + (Height - ACanvas.TextHeight("H")) / 2, FText);

            if (FChecked)  // 勾选
            {
                User.DrawFrameControl(ACanvas.Handle, ref vBoxRect, Kernel.DFC_MENU, Kernel.DFCS_CHECKED | Kernel.DFCS_MENUCHECK);
            }

            if (FMouseIn && (!APaintInfo.Print))  // 鼠标在其中,且非打印
            {
                ACanvas.Pen.Color = Color.Blue;
                ACanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
                HC.InflateRect(ref vBoxRect, 1, 1);
                ACanvas.Pen.Color = HC.clBtnFace;
                ACanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
            }
            else  // 鼠标不在其中或打印
            {
                ACanvas.Pen.Color = Color.Black;
                ACanvas.Rectangle(vBoxRect.Left, vBoxRect.Top, vBoxRect.Right, vBoxRect.Bottom);
            }
        }
示例#14
0
        private void DoPopupFormPaint(HCCanvas ACanvas, RECT AClientRect)
        {
            ACanvas.Brush.Color = HC.clInfoBk;
            ACanvas.FillRect(GetItemRect());      // AClientRect
            ACanvas.Font.Size = DROPDOWNFONTSIZE; // 10号字,高14

            int vStartIndex = 0, vEndIndex = 0;

            GetDisplayRange(AClientRect, ref vStartIndex, ref vEndIndex);

            int vTop = 0;

            if (ScrollBarVisible())
            {
                vTop = vStartIndex * DROPDOWNITEMHEIGHT - FScrollBar.Position;
            }

            for (int i = vStartIndex; i <= vEndIndex; i++)
            {
                if (i == FMoveItemIndex)
                {
                    ACanvas.Brush.Color = HC.clHighlight;
                    ACanvas.FillRect(HC.Bounds(0, vTop, Width, DROPDOWNITEMHEIGHT));
                }
                else
                {
                    ACanvas.Brush.Color = HC.clInfoBk;
                }

                ACanvas.TextOut(2, vTop + 2, FItems[i]);
                vTop = vTop + DROPDOWNITEMHEIGHT;
            }

            if (ScrollBarVisible())
            {
                POINT vPt = new POINT();
                GDI.GetWindowOrgEx(ACanvas.Handle, ref vPt);
                GDI.SetWindowOrgEx(ACanvas.Handle, vPt.X - (Width - FScrollBar.Width), vPt.Y, ref vPt /*null*/);
                //User.MoveWindowOrg(ACanvas.Handle, Width - FScrollBar.Width, 0);
                GDI.IntersectClipRect(ACanvas.Handle, 0, 0, FScrollBar.Width, FScrollBar.Height);  // 创建新的剪切区域,该区域是当前剪切区域和一个特定矩形的交集
                FScrollBar.PaintToEx(ACanvas);
            }
        }
示例#15
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            RECT vAreaRect = FAreaRect;

            vAreaRect.Offset(aDrawRect.Left, aDrawRect.Top);

            if ((FActiveArea != DateTimeArea.dtaNone) && (!this.IsSelectComplate) && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = aStyle.SelColor;
                aCanvas.FillRect(vAreaRect);
            }

            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo);

            if ((FActiveArea == DateTimeArea.dtaYear) && (FNewYear != "") && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = aStyle.SelColor;
                aCanvas.FillRect(vAreaRect);
                User.DrawText(aCanvas.Handle, FNewYear, -1, ref vAreaRect, User.DT_RIGHT | User.DT_SINGLELINE);
            }
        }
示例#16
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            if (this.Active && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            if (!aPaintInfo.Print)
            {
                RECT vFocusRect = new RECT();
                if (FActiveArea != ExpressArea.ceaNone)
                {
                    if (FActiveArea == ExpressArea.ceaTop)
                    {
                        vFocusRect = FSupRect;
                    }
                    else
                    if (FActiveArea == ExpressArea.ceaBottom)
                    {
                        vFocusRect = FSubRect;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = Color.Blue;
                    aCanvas.Rectangle(vFocusRect);
                }

                if ((FMouseMoveArea != ExpressArea.ceaNone) && (FMouseMoveArea != FActiveArea))
                {
                    if (FMouseMoveArea == ExpressArea.ceaTop)
                    {
                        vFocusRect = FSupRect;
                    }
                    else
                    if (FMouseMoveArea == ExpressArea.ceaBottom)
                    {
                        vFocusRect = FSubRect;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = HC.clMedGray;
                    aCanvas.Rectangle(vFocusRect);
                }
            }

            ApplySupSubStyle(aStyle.TextStyles[TextStyleNo], aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            aCanvas.TextOut(aDrawRect.Left + FSupRect.Left, aDrawRect.Top + FSupRect.Top, FSupText);
            aCanvas.TextOut(aDrawRect.Left + FSubRect.Left, aDrawRect.Top + FSubRect.Top, FSubText);
        }
示例#17
0
        public override void PaintToEx(HCCanvas aCanvas)
        {
            base.PaintToEx(aCanvas);

            if (this.Orientation == Orientation.oriVertical)  // 垂直滚动条
            {
                if (FRightBlank > 0)
                {
                    aCanvas.Brush.Color = Color.FromArgb(0x52, 0x59, 0x6B);
                    aCanvas.FillRect(new RECT(2, Height - FRightBlank + 2, Width - 2, Height - 2));

                    // 上按钮
                    aCanvas.Pen.Color = Color.FromArgb(0xAA, 0xAB, 0xB3);
                    int vX = (Width - 5) / 2;
                    int vY = Height - FRightBlank + 2 + ButtonSize - 9;
                    aCanvas.MoveTo(vX, vY);
                    aCanvas.LineTo(vX + 5, vY);
                    aCanvas.MoveTo(vX + 1, vY - 1);
                    aCanvas.LineTo(vX + 4, vY - 1);
                    aCanvas.MoveTo(vX + 2, vY - 2);
                    aCanvas.LineTo(vX + 3, vY - 2);

                    vY = vY - 3;
                    aCanvas.MoveTo(vX, vY);
                    aCanvas.LineTo(vX + 5, vY);
                    aCanvas.MoveTo(vX + 1, vY - 1);
                    aCanvas.LineTo(vX + 4, vY - 1);
                    aCanvas.MoveTo(vX + 2, vY - 2);
                    aCanvas.LineTo(vX + 3, vY - 2);

                    // 下按钮
                    vY = Height - FRightBlank + 2 + ButtonSize + 2 + 3;
                    aCanvas.MoveTo(vX, vY);
                    aCanvas.LineTo(vX + 5, vY);
                    aCanvas.MoveTo(vX + 1, vY + 1);
                    aCanvas.LineTo(vX + 4, vY + 1);
                    aCanvas.MoveTo(vX + 2, vY + 2);
                    aCanvas.LineTo(vX + 3, vY + 2);

                    vY = vY + 3;
                    aCanvas.MoveTo(vX, vY);
                    aCanvas.LineTo(vX + 5, vY);
                    aCanvas.MoveTo(vX + 1, vY + 1);
                    aCanvas.LineTo(vX + 4, vY + 1);
                    aCanvas.MoveTo(vX + 2, vY + 2);
                    aCanvas.LineTo(vX + 3, vY + 2);
                }
            }
        }
示例#18
0
        protected override void DoDrawThumBefor(HCCanvas ACanvas, RECT AThumRect)
        {
            if (this.Orientation == View.Orientation.oriVertical)
            {
                if (FAreaMarks != null)
                {
                    ACanvas.Brush.Color = Color.Blue;
                    int vDrawTop = 0, vDrawHeight = 0;

                    for (int i = 0; i <= FAreaMarks.Count - 1; i++)
                    {
                        vDrawTop    = ButtonSize + (int)Math.Round(FAreaMarks[i].Position * Percent);
                        vDrawHeight = (int)Math.Round(FAreaMarks[i].Height * Percent);
                        ACanvas.FillRect(HC.Bounds(AThumRect.Left, vDrawTop, AThumRect.Width, vDrawHeight));
                    }
                }
            }
        }
示例#19
0
        protected override void DoDrawThumBefor(HCCanvas aCanvas, RECT aThumRect)
        {
            if (this.Orientation == View.Orientation.oriVertical)
            {
                if (FAreaMarks != null)  // 有标记区域
                {
                    aCanvas.Brush.Color = Color.FromArgb(0x52, 0x59, 0x6b);

                    RECT vRect;

                    for (int i = 0; i <= FAreaMarks.Count - 1; i++)
                    {
                        vRect = GetAreaMarkRect(i);
                        if ((vRect.Bottom > FLeftBlank + HCScrollBar.ButtonSize) && (vRect.Top < this.Height - FRightBlank - HCScrollBar.ButtonSize))
                        {
                            aCanvas.FillRect(vRect);
                        }
                    }
                }
            }
        }
        public override void PaintToEx(HCCanvas ACanvas)
        {
            base.PaintToEx(ACanvas);

            if (this.Orientation == Orientation.oriHorizontal)
            {
                if (FStatuses.Count > 0)
                {
                    ACanvas.Brush.Color = Color.FromArgb(0x52, 0x59, 0x6B);
                    ACanvas.FillRect(new RECT(2, 2, FLeftBtnRect.Left, this.Height - 2));
                    ACanvas.Font.BeginUpdate();
                    try
                    {
                        ACanvas.Font.Size             = 8;
                        ACanvas.Font.Color            = Color.FromArgb(0xD0, 0xD1, 0xD5);
                        ACanvas.Font.Family           = "Arial";
                        ACanvas.Font.FontStyles.Value = 0;
                    }
                    finally
                    {
                        ACanvas.Font.EndUpdate();
                    }

                    int    vLeft = 4;
                    string vText = "";
                    RECT   vRect = new RECT(0, 2, 0, Height - 2);
                    for (int i = 0; i < FStatuses.Count; i++)
                    {
                        vText       = FStatuses[i].Text;
                        vRect.Left  = vLeft;
                        vRect.Right = vLeft + FStatuses[i].Width;
                        ACanvas.TextRect(ref vRect, vText, User.DT_LEFT | User.DT_SINGLELINE | User.DT_VCENTER);
                        vLeft += FStatuses[i].Width + 2;
                    }
                }
            }
        }
示例#21
0
        public void PaintToEx(HCCanvas ACanvas)
        {
            RECT vRect = new RECT();

            ACanvas.Brush.Color = TitleBackColor;
            ACanvas.FillRect(HC.Bounds(0, 0, Width, Height));

            if (FOrientation == Orientation.oriHorizontal)  // 水平滚动条
            {
                // 左按钮
                ACanvas.Pen.Color = Color.White;
                vRect.Left        = FLeftBtnRect.Left + ((FLeftBtnRect.Right - FLeftBtnRect.Left) - 4) / 2 + 4;
                vRect.Top         = FLeftBtnRect.Top + ((FLeftBtnRect.Bottom - FLeftBtnRect.Top) - 7) / 2;
                ACanvas.DrawLine(vRect.Left, vRect.Top, vRect.Left, vRect.Top + 7);
                ACanvas.DrawLine(vRect.Left - 1, vRect.Top + 1, vRect.Left - 1, vRect.Top + 6);
                ACanvas.DrawLine(vRect.Left - 2, vRect.Top + 2, vRect.Left - 2, vRect.Top + 5);
                ACanvas.DrawLine(vRect.Left - 3, vRect.Top + 3, vRect.Left - 3, vRect.Top + 4);
                // 右按钮
                vRect.Left = FRightBtnRect.Left + ((FRightBtnRect.Right - FRightBtnRect.Left) - 4) / 2;
                vRect.Top  = FRightBtnRect.Top + ((FRightBtnRect.Bottom - FRightBtnRect.Top) - 7) / 2;
                ACanvas.DrawLine(vRect.Left, vRect.Top, vRect.Left, vRect.Top + 7);
                ACanvas.DrawLine(vRect.Left + 1, vRect.Top + 1, vRect.Left + 1, vRect.Top + 6);
                ACanvas.DrawLine(vRect.Left + 2, vRect.Top + 2, vRect.Left + 2, vRect.Top + 5);
                ACanvas.DrawLine(vRect.Left + 3, vRect.Top + 3, vRect.Left + 3, vRect.Top + 4);
                // 水平滑块
                vRect = FThumRect;
                HC.InflateRect(ref vRect, 0, -1);
                DoDrawThumBefor(ACanvas, vRect);
                ACanvas.Brush.Color = ThumBackColor;
                ACanvas.Pen.Color   = LineColor;
                ACanvas.Rectangle(vRect);
                // 滑块上的修饰
                vRect.Left = vRect.Left + (vRect.Right - vRect.Left) / 2;
                ACanvas.DrawLine(vRect.Left, 5, vRect.Left, Height - 5);
                ACanvas.DrawLine(vRect.Left + 3, 5, vRect.Left + 3, Height - 5);
                ACanvas.DrawLine(vRect.Left - 3, 5, vRect.Left - 3, Height - 5);
            }
            else  // 垂直滚动条
            {
                // 上按钮
                ACanvas.Pen.Color = Color.White;
                vRect.Left        = FLeftBtnRect.Left + ((FLeftBtnRect.Right - FLeftBtnRect.Left) - 7) / 2;
                vRect.Top         = FLeftBtnRect.Top + ((FLeftBtnRect.Bottom - FLeftBtnRect.Top) - 4) / 2 + 4;

                ACanvas.DrawLine(6, 12, 13, 12);
                ACanvas.DrawLine(vRect.Left, vRect.Top, vRect.Left + 7, vRect.Top);
                ACanvas.DrawLine(vRect.Left + 1, vRect.Top - 1, vRect.Left + 6, vRect.Top - 1);
                ACanvas.DrawLine(vRect.Left + 2, vRect.Top - 2, vRect.Left + 5, vRect.Top - 2);
                ACanvas.DrawLine(vRect.Left + 3, vRect.Top - 3, vRect.Left + 4, vRect.Top - 3);
                // 下按钮
                vRect.Left = FRightBtnRect.Left + ((FRightBtnRect.Right - FRightBtnRect.Left) - 7) / 2;
                vRect.Top  = FRightBtnRect.Top + ((FRightBtnRect.Bottom - FRightBtnRect.Top) - 4) / 2;
                ACanvas.DrawLine(vRect.Left, vRect.Top, vRect.Left + 7, vRect.Top);
                ACanvas.DrawLine(vRect.Left + 1, vRect.Top + 1, vRect.Left + 6, vRect.Top + 1);
                ACanvas.DrawLine(vRect.Left + 2, vRect.Top + 2, vRect.Left + 5, vRect.Top + 2);
                ACanvas.DrawLine(vRect.Left + 3, vRect.Top + 3, vRect.Left + 4, vRect.Top + 3);
                // 滑块
                vRect = FThumRect;
                HC.InflateRect(ref vRect, -1, 0);
                DoDrawThumBefor(ACanvas, vRect);
                ACanvas.Brush.Color = ThumBackColor;
                ACanvas.Pen.Color   = LineColor;
                ACanvas.Rectangle(vRect);
                // 滑块上的修饰
                vRect.Top = vRect.Top + (vRect.Bottom - vRect.Top) / 2;
                ACanvas.DrawLine(5, vRect.Top, Width - 5, vRect.Top);
                ACanvas.DrawLine(5, vRect.Top - 3, Width - 5, vRect.Top - 3);
                ACanvas.DrawLine(5, vRect.Top + 3, Width - 5, vRect.Top + 3);
            }
        }
        protected override void DoDrawItemPaintContent(HCCustomData aData, int aItemNo, int aDrawItemNo,
                                                       RECT aDrawRect, RECT aClearRect, string aDrawText,
                                                       int aDataDrawLeft, int aDataDrawRight, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom,
                                                       HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            if ((FOnDrawItemAnnotate != null) && DrawItemOfAnnotate(aDrawItemNo, aCanvas, aClearRect))  // 当前DrawItem是某批注中的一部分
            {
                HCDrawItemAnnotate vDrawAnnotate;
                bool vActive;
                for (int i = 0; i <= FDrawItemAnnotates.Count - 1; i++)
                {
                    vDrawAnnotate = FDrawItemAnnotates[i];

                    if (!aPaintInfo.Print)
                    {
                        vActive = vDrawAnnotate.DataAnnotate.Equals(FHotAnnotate) ||
                                  vDrawAnnotate.DataAnnotate.Equals(FActiveAnnotate);

                        if (vActive)
                        {
                            aCanvas.Brush.Color = HC.AnnotateBKActiveColor;
                        }
                        else
                        {
                            aCanvas.Brush.Color = HC.AnnotateBKColor;
                        }

                        aCanvas.FillRect(vDrawAnnotate.DrawRect);
                    }

                    if (vDrawAnnotate.First())  // 是批注头
                    {
                        aCanvas.Pen.BeginUpdate();
                        try
                        {
                            aCanvas.Pen.Color = Color.Red;
                            aCanvas.Pen.Width = 1;
                        }
                        finally
                        {
                            aCanvas.Pen.EndUpdate();
                        }

                        aCanvas.MoveTo(vDrawAnnotate.DrawRect.Left + 2, vDrawAnnotate.DrawRect.Top - 2);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Left, vDrawAnnotate.DrawRect.Top);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Left, vDrawAnnotate.DrawRect.Bottom);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Left + 2, vDrawAnnotate.DrawRect.Bottom + 2);
                    }

                    if (vDrawAnnotate.Last())  // 是批注尾
                    {
                        aCanvas.Pen.BeginUpdate();
                        try
                        {
                            aCanvas.Pen.Color = Color.Red;
                            aCanvas.Pen.Width = 1;
                        }
                        finally
                        {
                            aCanvas.Pen.EndUpdate();
                        }

                        aCanvas.MoveTo(vDrawAnnotate.DrawRect.Right - 2, vDrawAnnotate.DrawRect.Top - 2);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Right, vDrawAnnotate.DrawRect.Top);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Right, vDrawAnnotate.DrawRect.Bottom);
                        aCanvas.LineTo(vDrawAnnotate.DrawRect.Right - 2, vDrawAnnotate.DrawRect.Bottom + 2);

                        FOnDrawItemAnnotate(aData, aDrawItemNo, vDrawAnnotate.DrawRect, vDrawAnnotate.DataAnnotate);
                    }
                }
            }

            base.DoDrawItemPaintContent(aData, aItemNo, aDrawItemNo, aDrawRect, aClearRect, aDrawText,
                                        aDataDrawLeft, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo);
        }
示例#23
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop,
                         aDataScreenBottom, aCanvas, aPaintInfo);

            if (!aPaintInfo.Print)
            {
                if (FReadOnly)
                {
                    aCanvas.Brush.Color = HC.clBtnFace;
                    aCanvas.FillRect(aDrawRect);
                }
                else
                if (this.IsSelectComplate)
                {
                    aCanvas.Brush.Color = aStyle.SelColor;
                    aCanvas.FillRect(aDrawRect);
                }

                if (SelectTextExists())
                {
                    aCanvas.Brush.Color = aStyle.SelColor;
                    int vLeft  = GetCharDrawLeft(FCaretOffset);
                    int vRight = GetCharDrawLeft(FSelEnd);
                    vLeft  = Math.Max(0, Math.Min(vLeft, Width));
                    vRight = Math.Max(0, Math.Min(vRight, Width));
                    aCanvas.FillRect(new RECT(aDrawRect.Left + vLeft, aDrawRect.Top, aDrawRect.Left + vRight, aDrawRect.Bottom));
                }
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);

            if (!this.AutoSize)
            {
                aCanvas.TextRect(aDrawRect, aDrawRect.Left + FPaddingLeft - FLeftOffset, aDrawRect.Top + FPaddingTop, FText);
            }
            else
            {
                aCanvas.TextOut(aDrawRect.Left + FPaddingLeft, aDrawRect.Top + FPaddingTop, FText);
            }

            if (aPaintInfo.Print && FPrintOnlyText)
            {
                return;
            }

            if (FBorderSides.Value > 0)
            {
                if (FMouseIn || Active)
                {
                    aCanvas.Pen.Color = Color.Blue;
                }
                else  // 鼠标不在其中或打印
                {
                    aCanvas.Pen.Color = Color.Black;
                }

                aCanvas.Pen.Width = FBorderWidth;
                aCanvas.Pen.Style = HCPenStyle.psSolid;

                if (FBorderSides.Contains((byte)BorderSide.cbsLeft))
                {
                    aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top);
                    aCanvas.LineTo(aDrawRect.Left, aDrawRect.Bottom);
                }

                if (FBorderSides.Contains((byte)BorderSide.cbsTop))
                {
                    aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top);
                    aCanvas.LineTo(aDrawRect.Right, aDrawRect.Top);
                }

                if (FBorderSides.Contains((byte)BorderSide.cbsRight))
                {
                    aCanvas.MoveTo(aDrawRect.Right - 1, aDrawRect.Top);
                    aCanvas.LineTo(aDrawRect.Right - 1, aDrawRect.Bottom);
                }

                if (FBorderSides.Contains((byte)BorderSide.cbsBottom))
                {
                    aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Bottom - 1);
                    aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom - 1);
                }
            }
        }
示例#24
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            if (this.Active && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            aCanvas.Pen.Color = Color.Black;
            aCanvas.MoveTo(aDrawRect.Left + FLeftRect.Right + Padding, aDrawRect.Top + TopRect.Bottom + Padding);
            aCanvas.LineTo(aDrawRect.Left + FRightRect.Left - Padding, aDrawRect.Top + TopRect.Bottom + Padding);

            if (!aPaintInfo.Print)
            {
                RECT vFocusRect = new RECT();

                if (FActiveArea != ExpressArea.ceaNone)
                {
                    switch (FActiveArea)
                    {
                    case ExpressArea.ceaLeft:
                        vFocusRect = FLeftRect;
                        break;

                    case ExpressArea.ceaTop:
                        vFocusRect = TopRect;
                        break;

                    case ExpressArea.ceaRight:
                        vFocusRect = FRightRect;
                        break;

                    case ExpressArea.ceaBottom:
                        vFocusRect = BottomRect;
                        break;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = Color.Blue;
                    aCanvas.Rectangle(vFocusRect);
                }

                if ((FMouseMoveArea != ExpressArea.ceaNone) && (FMouseMoveArea != FActiveArea))
                {
                    switch (FMouseMoveArea)
                    {
                    case ExpressArea.ceaLeft:
                        vFocusRect = FLeftRect;
                        break;

                    case ExpressArea.ceaTop:
                        vFocusRect = TopRect;
                        break;

                    case ExpressArea.ceaRight:
                        vFocusRect = FRightRect;
                        break;

                    case ExpressArea.ceaBottom:
                        vFocusRect = BottomRect;
                        break;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = HC.clMedGray;
                    aCanvas.Rectangle(vFocusRect);
                }
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            aCanvas.TextOut(aDrawRect.Left + FLeftRect.Left, aDrawRect.Top + FLeftRect.Top, FLeftText);
            aCanvas.TextOut(aDrawRect.Left + TopRect.Left, aDrawRect.Top + TopRect.Top, TopText);
            aCanvas.TextOut(aDrawRect.Left + FRightRect.Left, aDrawRect.Top + FRightRect.Top, FRightText);
            aCanvas.TextOut(aDrawRect.Left + BottomRect.Left, aDrawRect.Top + BottomRect.Top, BottomText);
        }
示例#25
0
        protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom,
                                        int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo)
        {
            if (this.Active && (!aPaintInfo.Print))
            {
                aCanvas.Brush.Color = HC.clBtnFace;
                aCanvas.FillRect(aDrawRect);
            }

            if (!FLineHide)  // 分数线
            {
                aCanvas.Pen.Color = Color.Black;
                aCanvas.MoveTo(aDrawRect.Left + FPadding, aDrawRect.Top + FTopRect.Bottom + FPadding);
                aCanvas.LineTo(aDrawRect.Left + Width - FPadding, aDrawRect.Top + FTopRect.Bottom + FPadding);
            }

            if (!aPaintInfo.Print)
            {
                RECT vFocusRect = new RECT();

                if (FActiveArea != ExpressArea.ceaNone)
                {
                    if (FActiveArea == ExpressArea.ceaTop)
                    {
                        vFocusRect = FTopRect;
                    }
                    else
                    if (FActiveArea == ExpressArea.ceaBottom)
                    {
                        vFocusRect = FBottomRect;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = Color.Blue;
                    aCanvas.Rectangle(vFocusRect);
                }

                if ((FMouseMoveArea != ExpressArea.ceaNone) && (FMouseMoveArea != FActiveArea))
                {
                    if (FMouseMoveArea == ExpressArea.ceaTop)
                    {
                        vFocusRect = FTopRect;
                    }
                    else
                    if (FMouseMoveArea == ExpressArea.ceaBottom)
                    {
                        vFocusRect = FBottomRect;
                    }

                    vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top);
                    vFocusRect.Inflate(2, 2);
                    aCanvas.Pen.Color = HC.clMedGray;
                    aCanvas.Rectangle(vFocusRect);
                }
            }

            aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom);
            aCanvas.TextOut(aDrawRect.Left + FTopRect.Left, aDrawRect.Top + FTopRect.Top, FTopText);
            aCanvas.TextOut(aDrawRect.Left + FBottomRect.Left, aDrawRect.Top + FBottomRect.Top, FBottomText);
        }
示例#26
0
        public void SaveToImage(string path, string prefix, string imageType, bool onePaper = true)
        {
            HCCanvas         vBmpCanvas = new HCCanvas();
            SectionPaintInfo vPaintInfo = new SectionPaintInfo();

            try
            {
                vPaintInfo.ScaleX    = 1;
                vPaintInfo.ScaleY    = 1;
                vPaintInfo.Zoom      = 1;
                vPaintInfo.Print     = true;
                vPaintInfo.DPI       = HCUnitConversion.PixelsPerInchX;
                vPaintInfo.ViewModel = HCViewModel.hvmFilm;

                int vWidth = 0, vHeight = 0;
                if (onePaper)
                {
                    for (int i = 0; i < FSections.Count; i++)
                    {
                        vHeight = vHeight + FSections[i].PaperHeightPix * FSections[i].PageCount;
                        if (vWidth < FSections[i].PaperWidthPix)
                        {
                            vWidth = FSections[i].PaperWidthPix;
                        }
                    }

                    vPaintInfo.WindowWidth  = vWidth;
                    vPaintInfo.WindowHeight = vHeight;

                    using (Bitmap vBmp = new Bitmap(vWidth, vHeight))
                    {
                        vBmpCanvas.Graphics = Graphics.FromImage(vBmp);

                        int vSectionIndex = 0, vSectionPageIndex = 0, vTop = 0;
                        for (int i = 0; i < this.PageCount; i++)
                        {
                            vSectionIndex = GetSectionPageIndexByPageIndex(i, ref vSectionPageIndex);
                            //vWidth = FSections[vSectionIndex].PaperWidthPix;
                            vHeight = FSections[vSectionIndex].PaperHeightPix;

                            vBmpCanvas.Brush.Color = Color.White;
                            vBmpCanvas.FillRect(new RECT(0, vTop, vWidth, vTop + vHeight));

                            ScaleInfo vScaleInfo = vPaintInfo.ScaleCanvas(vBmpCanvas);
                            try
                            {
                                FSections[vSectionIndex].PaintPaper(vSectionPageIndex, 0, vTop, vBmpCanvas, vPaintInfo);
                                vTop = vTop + vHeight;
                            }
                            finally
                            {
                                vPaintInfo.RestoreCanvasScale(vBmpCanvas, vScaleInfo);
                            }
                        }

                        vBmpCanvas.Dispose();
                        if (imageType == "BMP")
                        {
                            vBmp.Save(path + prefix + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                        }
                        else
                        if (imageType == "JPG")
                        {
                            vBmp.Save(path + prefix + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        else
                        {
                            vBmp.Save(path + prefix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                        }
                    }
                }
                else
                {
                    int vSectionIndex = 0, vSectionPageIndex = 0;
                    for (int i = 0; i < this.PageCount; i++)
                    {
                        vSectionIndex = GetSectionPageIndexByPageIndex(i, ref vSectionPageIndex);

                        using (Bitmap vBmp = new Bitmap(FSections[vSectionIndex].PaperWidthPix, FSections[vSectionIndex].PaperHeightPix))
                        {
                            vBmpCanvas.Graphics    = Graphics.FromImage(vBmp);
                            vBmpCanvas.Brush.Color = Color.White;
                            vBmpCanvas.FillRect(new RECT(0, 0, vBmp.Width, vBmp.Height));

                            vPaintInfo.WindowWidth  = vBmp.Width;
                            vPaintInfo.WindowHeight = vBmp.Height;
                            ScaleInfo vScaleInfo = vPaintInfo.ScaleCanvas(vBmpCanvas);
                            try
                            {
                                vBmpCanvas.Brush.Color = Color.White;
                                vBmpCanvas.FillRect(new RECT(0, 0, vBmp.Width, vBmp.Height));
                                FSections[vSectionIndex].PaintPaper(vSectionPageIndex, 0, 0, vBmpCanvas, vPaintInfo);
                            }
                            finally
                            {
                                vPaintInfo.RestoreCanvasScale(vBmpCanvas, vScaleInfo);
                            }

                            vBmpCanvas.Dispose();
                            if (imageType == "BMP")
                            {
                                vBmp.Save(path + prefix + (i + 1).ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                            }
                            else
                            if (imageType == "JPG")
                            {
                                vBmp.Save(path + prefix + (i + 1).ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                            else
                            {
                                vBmp.Save(path + prefix + (i + 1).ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
                            }
                        }
                    }
                }
            }
            finally
            {
                vPaintInfo.Dispose();
            }
        }
示例#27
0
        public void PaintTo(HCCanvas canvas, RECT rect)
        {
            int            vX = 0, vHeight = this.Height, vW = 0;
            HCCodeLineType vLineType = HCCodeLineType.White;

            if (this.FTextVisible)
            {
                vHeight -= 12;
            }

            RECT vRect = new RECT();

            for (int i = 0, vLen = this.FCode.Length; i < vLen; i++)
            {
                vLineType = HCCodeLineType.White;
                this.OneBarProps(this.FCode[i], ref vW, ref vLineType);
                if (vLineType != HCCodeLineType.White)
                {
                    canvas.Brush.Color = Color.Black;
                }
                else
                {
                    canvas.Brush.Color = Color.White;
                }

                vRect.Left   = vX;
                vRect.Top    = 0;
                vRect.Right  = vX + vW * this.FZoom;
                vRect.Bottom = vHeight;
                vX           = vRect.Right;
                vRect.Offset(rect.Left, rect.Top);
                canvas.FillRect(vRect);
            }

            if (this.FCode == "")
            {
                canvas.Pen.BeginUpdate();
                try
                {
                    canvas.Pen.Width = 1;
                    canvas.Pen.Color = Color.Black;
                }
                finally
                {
                    canvas.Pen.EndUpdate();
                }

                canvas.Rectangle(rect);
            }

            if (this.FTextVisible)
            {
                canvas.Font.BeginUpdate();
                try
                {
                    canvas.Font.Size             = 8;
                    canvas.Font.FontStyles.Value = 0;
                    canvas.Font.Family           = "Arial";
                    canvas.Font.Color            = Color.Black;
                }
                finally
                {
                    canvas.Font.EndUpdate();
                }

                canvas.Brush.Style = HCBrushStyle.bsClear;
                if (this.FCode != "")
                {
                    canvas.TextOut(rect.Left + (rect.Width - canvas.TextWidth(this.FText)) / 2,
                                   rect.Top + vHeight + 2, this.FText);
                }
                else
                {
                    SIZE vSize = canvas.TextExtent("无效条码" + this.FText);
                    canvas.TextOut(rect.Left + (rect.Width - vSize.cx) / 2,
                                   rect.Top + (rect.Height - vSize.cy) / 2, "无效条码" + this.FText);
                }
            }
        }