public void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { for (int i = 0; i < this.Count; i++) { this[i].PaintTo(aCanvas, aRect, aPaintInfo); } }
public virtual void SaveToBitmap(ref Bitmap aBitmap) { 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; Graphics vGraphic = Graphics.FromImage(aBitmap); IntPtr vDC = vGraphic.GetHdc(); try { HCCanvas vCanvas = new HCCanvas(vDC); try { this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height), 0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo); } finally { vCanvas.Dispose(); } } finally { vGraphic.ReleaseHdc(); } }
public override void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Color = Color; aCanvas.Pen.Width = FWidth; aCanvas.Pen.Style = FLineStyle; } finally { aCanvas.Pen.EndUpdate(); } aCanvas.MoveTo(FPoints[0].X + aRect.Left, FPoints[0].Y + aRect.Top); for (int i = 1; i < FPoints.Count; i++) { aCanvas.LineTo(FPoints[i].X + aRect.Left, FPoints[i].Y + aRect.Top); } if (FPoints.Count > 1) // 首尾相连 { aCanvas.LineTo(FPoints[0].X + aRect.Left, FPoints[0].Y + aRect.Top); } if ((!aPaintInfo.Print) && this.Active) { PaintAnchor(aCanvas, aRect); } }
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 DoDrawItemPaintAfter(HCCustomData aData, int aItemNo, int aDrawItemNo, RECT aDrawRect, RECT aClearRect, int aDataDrawLeft, int aDataDrawRight, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoDrawItemPaintAfter(aData, aItemNo, aDrawItemNo, aDrawRect, aClearRect, aDataDrawLeft, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, ACanvas, APaintInfo); }
public override void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Color = Color; aCanvas.Pen.Width = Width; aCanvas.Pen.Style = LineStyle; } finally { aCanvas.Pen.EndUpdate(); } if (BackColor == HC.HCTransparentColor) { aCanvas.Brush.Style = HCBrushStyle.bsClear; } aCanvas.Ellipse(StartPt.X + aRect.Left, StartPt.Y + aRect.Top, EndPt.X + aRect.Left, EndPt.Y + aRect.Top); if (!aPaintInfo.Print && this.Active) { PaintAnchor(aCanvas, aRect); } }
protected override void DoDrawItemPaintAfter(HCCustomData AData, int ADrawItemNo, RECT ADrawRect, int ADataDrawLeft, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoDrawItemPaintAfter(AData, ADrawItemNo, ADrawRect, ADataDrawLeft, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, ACanvas, APaintInfo); }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Color = Color.Black; ACanvas.Pen.Style = HCPenStyle.psSolid; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(FStartPt.X + this.DrawRect.Left, FStartPt.Y + this.DrawRect.Top); ACanvas.LineTo(FEndPt.X + this.DrawRect.Left, FEndPt.Y + this.DrawRect.Top); if ((this.Active) && (!APaintInfo.Print)) // 激活 { ACanvas.Rectangle(FStartPt.X + this.DrawRect.Left - PointSize, FStartPt.Y + this.DrawRect.Top - PointSize, FStartPt.X + this.DrawRect.Left + PointSize, FStartPt.Y + this.DrawRect.Top + PointSize); ACanvas.Rectangle(FEndPt.X + this.DrawRect.Left - PointSize, FEndPt.Y + this.DrawRect.Top - PointSize, FEndPt.X + this.DrawRect.Left + PointSize, FEndPt.Y + this.DrawRect.Top + PointSize); } }
/// <summary> 绘制数据 </summary> /// <param name="ADataDrawLeft">绘制目标区域Left</param> /// <param name="ADataDrawTop">绘制目标区域的Top</param> /// <param name="ADataDrawBottom">绘制目标区域的Bottom</param> /// <param name="ADataScreenTop">屏幕区域Top</param> /// <param name="ADataScreenBottom">屏幕区域Bottom</param> /// <param name="AVOffset">指定从哪个位置开始的数据绘制到目标区域的起始位置</param> /// <param name="ACanvas">画布</param> public void PaintData(int ADataDrawLeft, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, int AVOffset, HCCanvas ACanvas, PaintInfo APaintInfo) { if (FCellData != null) { int vTop = 0; switch (FAlignVert) { case View.AlignVert.cavTop: vTop = ADataDrawTop; break; case View.AlignVert.cavBottom: vTop = ADataDrawTop + FHeight - FCellData.Height; break; case View.AlignVert.cavCenter: vTop = ADataDrawTop + (FHeight - FCellData.Height) / 2; break; } FCellData.PaintData(ADataDrawLeft, vTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, AVOffset, ACanvas, APaintInfo); } }
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); }
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); } }
public override void PaintData(int aDataDrawLeft, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, int aVOffset, int aFirstDItemNo, int aLastDItemNo, HCCanvas aCanvas, PaintInfo aPaintInfo) { CheckAnnotateRange(aFirstDItemNo, aLastDItemNo); // 指定DrawItem范围内的批注获取各自的DrawItem范围 base.PaintData(aDataDrawLeft, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aVOffset, aFirstDItemNo, aLastDItemNo, aCanvas, aPaintInfo); FDrawItemAnnotates.Clear(); }
public override void PaintData(int aDataDrawLeft, int aDataDrawTop, int aDataDrawRight, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, int aVOffset, int aFristDItemNo, int aLastDItemNo, HCCanvas aCanvas, PaintInfo aPaintInfo) { if (!aPaintInfo.Print) { if (this.Style.DrawHotDomainRegion) { FHotDomainRGN = (IntPtr)GDI.CreateRectRgn(0, 0, 0, 0); } if (this.Style.DrawActiveDomainRegion) { FActiveDomainRGN = (IntPtr)GDI.CreateRectRgn(0, 0, 0, 0); } } base.PaintData(aDataDrawLeft, aDataDrawTop, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aVOffset, aFristDItemNo, aLastDItemNo, aCanvas, aPaintInfo); if (!aPaintInfo.Print) { Color vOldColor = aCanvas.Brush.Color; // 因为使用Brush绘制边框所以需要缓存原颜色 try { if (Style.DrawHotDomainRegion) { if (DoPaintDomainRegion(FHotDomain.BeginNo)) { aCanvas.Brush.Color = HC.clActiveBorder; //FieldInfo vField = typeof(Brush).GetField("nativeBrush", BindingFlags.NonPublic | BindingFlags.Instance); //IntPtr hbrush = (IntPtr)vField.GetValue(ACanvas.Brush); GDI.FrameRgn(aCanvas.Handle, FHotDomainRGN, aCanvas.Brush.Handle, 1, 1); } GDI.DeleteObject(FHotDomainRGN); } if (Style.DrawActiveDomainRegion) { if (DoPaintDomainRegion(FActiveDomain.BeginNo)) { aCanvas.Brush.Color = Color.Blue; //FieldInfo vField = typeof(Brush).GetField("nativeBrush", BindingFlags.NonPublic | BindingFlags.Instance); //IntPtr hbrush = (IntPtr)vField.GetValue(ACanvas.Brush); GDI.FrameRgn(aCanvas.Handle, FActiveDomainRGN, aCanvas.Brush.Handle, 1, 1); } GDI.DeleteObject(FActiveDomainRGN); } } finally { aCanvas.Brush.Color = vOldColor; } } }
protected override void DoPaintViewAfter(HCCanvas aCanvas, PaintInfo aPaintInfo) { base.DoPaintViewAfter(aCanvas, aPaintInfo); if ((FActiveItem != null) && (!this.ReadOnly) && this.Focused) { if (FTableToolBar.Visible) { if (aPaintInfo.ScaleX != 1) { SIZE vPt = new SIZE(); GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.WindowWidth, aPaintInfo.WindowHeight, ref vPt); try { FTableToolBar.PaintTo(aCanvas, aPaintInfo.GetScaleX(FActiveItemRect.Left - FTableToolBar.Width + FToolOffset), aPaintInfo.GetScaleY(FActiveItemRect.Top));// + FToolOffset - FTableToolBar.Height); } finally { GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.GetScaleX(aPaintInfo.WindowWidth), aPaintInfo.GetScaleY(aPaintInfo.WindowHeight), ref vPt); } } else { FTableToolBar.PaintTo(aCanvas, FActiveItemRect.Left - FTableToolBar.Width + FToolOffset, FActiveItemRect.Top);// - Style.LineSpaceMin / 2 + FToolOffset - FTableToolBar.Height); } } else if (FImageToolBar.Visible) { if (aPaintInfo.ScaleX != 1) { SIZE vPt = new SIZE(); GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.WindowWidth, aPaintInfo.WindowHeight, ref vPt); try { FImageToolBar.PaintTo(aCanvas, aPaintInfo.GetScaleX(FActiveItemRect.Left), aPaintInfo.GetScaleY(FActiveItemRect.Top) + FToolOffset - FImageToolBar.Height); } finally { GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.GetScaleX(aPaintInfo.WindowWidth), aPaintInfo.GetScaleY(aPaintInfo.WindowHeight), ref vPt); } } else { FImageToolBar.PaintTo(aCanvas, FActiveItemRect.Left, FActiveItemRect.Top + FToolOffset - FImageToolBar.Height); } } } }
private void DrawLineLastMrak(HCCanvas aCanvas, RECT aDrawRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Width = 1; aCanvas.Pen.Style = HCPenStyle.psSolid; aCanvas.Pen.Color = HC.clActiveBorder; } finally { aCanvas.Pen.EndUpdate(); } if (aPaintInfo.ScaleX != 1) { SIZE vPt = new SIZE(); GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.WindowWidth, aPaintInfo.WindowHeight, ref vPt); try { aCanvas.MoveTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 4, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 8); aCanvas.LineTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 6, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 8); aCanvas.LineTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 6, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 3); aCanvas.MoveTo(aPaintInfo.GetScaleX(aDrawRect.Right), aPaintInfo.GetScaleY(aDrawRect.Bottom) - 3); aCanvas.LineTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 6, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 3); aCanvas.MoveTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 1, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 4); aCanvas.LineTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 1, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 1); aCanvas.MoveTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 2, aPaintInfo.GetScaleY(aDrawRect.Bottom) - 5); aCanvas.LineTo(aPaintInfo.GetScaleX(aDrawRect.Right) + 2, aPaintInfo.GetScaleY(aDrawRect.Bottom)); } finally { GDI.SetViewportExtEx(aCanvas.Handle, aPaintInfo.GetScaleX(aPaintInfo.WindowWidth), aPaintInfo.GetScaleY(aPaintInfo.WindowHeight), ref vPt); } } else { aCanvas.MoveTo(aDrawRect.Right + 4, aDrawRect.Bottom - 8); aCanvas.LineTo(aDrawRect.Right + 6, aDrawRect.Bottom - 8); aCanvas.LineTo(aDrawRect.Right + 6, aDrawRect.Bottom - 3); aCanvas.MoveTo(aDrawRect.Right, aDrawRect.Bottom - 3); aCanvas.LineTo(aDrawRect.Right + 6, aDrawRect.Bottom - 3); aCanvas.MoveTo(aDrawRect.Right + 1, aDrawRect.Bottom - 4); aCanvas.LineTo(aDrawRect.Right + 1, aDrawRect.Bottom - 1); aCanvas.MoveTo(aDrawRect.Right + 2, aDrawRect.Bottom - 5); aCanvas.LineTo(aDrawRect.Right + 2, aDrawRect.Bottom); } }
/// <summary> 绘制数据 </summary> /// <param name="aDataDrawLeft">绘制目标区域Left</param> /// <param name="aDataDrawTop">绘制目标区域的Top</param> /// <param name="aDataDrawBottom">绘制目标区域的Bottom</param> /// <param name="aDataScreenTop">屏幕区域Top</param> /// <param name="aDataScreenBottom">屏幕区域Bottom</param> /// <param name="aVOffset">指定从哪个位置开始的数据绘制到目标区域的起始位置</param> /// <param name="ACanvas">画布</param> public void PaintTo(int aDrawLeft, int aDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, int aVOffset, byte aCellHPadding, byte aCellVPadding, HCCanvas ACanvas, PaintInfo APaintInfo) { if (FCellData != null) { int vTop = aDrawTop + GetCellDataTop(aCellVPadding); FCellData.PaintData(aDrawLeft + aCellHPadding, vTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aVOffset, ACanvas, APaintInfo); } }
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; } } if (vDrawAnnotate.First()) // 是批注头 { aCanvas.Pen.Color = Color.Red; 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.Color = Color.Red; 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); }
public virtual void PaintFloatItems(int APageIndex, int ADataDrawLeft, int ADataDrawTop, int AVOffset, HCCanvas ACanvas, PaintInfo APaintInfo) { HCFloatItem vFloatItem = null; for (int i = 0; i <= FFloatItems.Count - 1; i++) { vFloatItem = FFloatItems[i]; vFloatItem.DrawRect = HC.Bounds(vFloatItem.Left, vFloatItem.Top, vFloatItem.Width, vFloatItem.Height); vFloatItem.DrawRect.Offset(ADataDrawLeft, ADataDrawTop - AVOffset); // 将数据起始位置映射到绘制位置 vFloatItem.PaintTo(this.Style, vFloatItem.DrawRect, ADataDrawTop, 0, 0, 0, ACanvas, APaintInfo); } }
/// <summary> /// 绘制Item的事件 /// </summary> /// <param name="ACanvas"></param> /// <param name="ADrawRect">当前DrawItem的区域</param> /// <param name="ADataDrawBottom">Item所在的Data本次绘制底部位置</param> /// <param name="ADataScreenTop"></param> /// <param name="ADataScreenBottom"></param> public void PaintTo(HCStyle AStyle, RECT ADrawRect, int APageDataDrawTop, int APageDataDrawBottom, int APageDataScreenTop, int APageDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) // 不可继承 { int vDCState = ACanvas.Save(); try { DoPaint(AStyle, ADrawRect, APageDataDrawTop, APageDataDrawBottom, APageDataScreenTop, APageDataScreenBottom, ACanvas, APaintInfo); } finally { ACanvas.Restore(vDCState); } }
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 ((!aPaintInfo.Print) && (FOnDrawItemAnnotate != null)) // 当前DrawItem是某批注中的一部分 { if (aData.Items[aItemNo].StyleNo == HCStyle.Annotate && ((aData.Items[aItemNo] as HCAnnotateItem).MarkType == MarkType.cmtEnd)) { FOnDrawItemAnnotate(aData, aDrawItemNo, aDrawRect, aData.Items[aItemNo] as HCAnnotateItem); } } base.DoDrawItemPaintContent(aData, aItemNo, aDrawItemNo, aDrawRect, aClearRect, aDrawText, aDataDrawLeft, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); }
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)); } } }
/// <summary> /// 绘制Item的事件 /// </summary> /// <param name="ACanvas"></param> /// <param name="aDrawRect">当前DrawItem的区域</param> /// <param name="ADataDrawBottom">Item所在的Data本次绘制底部位置</param> /// <param name="ADataScreenTop"></param> /// <param name="ADataScreenBottom"></param> public void PaintTo(HCStyle aStyle, RECT aDrawRect, int APageDataDrawTop, int APageDataDrawBottom, int APageDataScreenTop, int APageDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) // 不可继承 { int vDCState = ACanvas.Save(); try { DoPaint(aStyle, aDrawRect, APageDataDrawTop, APageDataDrawBottom, APageDataScreenTop, APageDataScreenBottom, ACanvas, APaintInfo); } finally { ACanvas.Restore(vDCState); ACanvas.Refresh(); // 处理下一个使用Pen时修改Pen的属性值和当前属性值一样时,不会触发Canvas重新SelectPen导致Pen的绘制失效的问题 } }
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 (FMarkType == View.MarkType.cmtBeg) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Style = HCPenStyle.psSolid; ACanvas.Pen.Color = HC.clActiveBorder; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(ADrawRect.Left + 2, ADrawRect.Top - 1); ACanvas.LineTo(ADrawRect.Left, ADrawRect.Top - 1); ACanvas.LineTo(ADrawRect.Left, ADrawRect.Bottom + 1); ACanvas.LineTo(ADrawRect.Left + 2, ADrawRect.Bottom + 1); } else { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Style = HCPenStyle.psSolid; ACanvas.Pen.Color = HC.clActiveBorder; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(ADrawRect.Right - 2, ADrawRect.Top - 1); ACanvas.LineTo(ADrawRect.Right, ADrawRect.Top - 1); ACanvas.LineTo(ADrawRect.Right, ADrawRect.Bottom + 1); ACanvas.LineTo(ADrawRect.Right - 2, ADrawRect.Bottom + 1); } } }
protected override void DoDrawItemPaintAfter(HCCustomData aData, int aItemNo, int aDrawItemNo, RECT aDrawRect, RECT aClearRect, int aDataDrawLeft, int aDataDrawRight, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoDrawItemPaintAfter(aData, aItemNo, aDrawItemNo, aDrawRect, aClearRect, aDataDrawLeft, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, ACanvas, APaintInfo); if (FShowUnderLine) { if (DrawItems[aDrawItemNo].LineFirst) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Color = Color.Black; ACanvas.Pen.Style = HCPenStyle.psSolid; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(aDataDrawLeft, aDrawRect.Top - 1); ACanvas.LineTo(aDataDrawLeft + this.Width, aDrawRect.Top - 1); } if (aDrawItemNo == DrawItems.Count - 1) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Color = Color.Black; ACanvas.Pen.Style = HCPenStyle.psSolid; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(aDataDrawLeft, aDrawRect.Bottom); ACanvas.LineTo(aDataDrawLeft + this.Width, aDrawRect.Bottom); } } }
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)); } }
public virtual void PaintFloatItems(int aPageIndex, int aDataDrawLeft, int aDataDrawTop, int aVOffset, HCCanvas aCanvas, PaintInfo aPaintInfo) { HCCustomFloatItem vFloatItem = null; for (int i = 0; i <= FFloatItems.Count - 1; i++) { vFloatItem = FFloatItems[i]; // 代替下面不生效的代码 RECT vRect = HC.Bounds(vFloatItem.Left, vFloatItem.Top, vFloatItem.Width, vFloatItem.Height); vRect.Offset(aDataDrawLeft, aDataDrawTop - aVOffset); // 将数据起始位置映射到绘制位置 vFloatItem.DrawRect = vRect; // 下面的操作vFloatItemDraw.DrawRect.Offset并不生效 //vFloatItem.DrawRect = HC.Bounds(vFloatItem.Left, vFloatItem.Top, vFloatItem.Width, vFloatItem.Height); //vFloatItem.DrawRect.Offset(aDataDrawLeft, aDataDrawTop - aVOffset); // 将数据起始位置映射到绘制位置 vFloatItem.PaintTo(this.Style, vFloatItem.DrawRect, aDataDrawTop, 0, 0, 0, aCanvas, aPaintInfo); } }
public override void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Color = Color; aCanvas.Pen.Width = FWidth; aCanvas.Pen.Style = FLineStyle; } finally { aCanvas.Pen.EndUpdate(); } aCanvas.MoveTo(FStartPt.X + aRect.Left, FStartPt.Y + aRect.Top); aCanvas.LineTo(FEndPt.X + aRect.Left, FEndPt.Y + aRect.Top); if ((!aPaintInfo.Print) && (this.Active)) { PaintAnchor(aCanvas, aRect); } }
private void DrawLineLastMrak(HCCanvas ACanvas, RECT ADrawRect, PaintInfo APaintInfo) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Width = 1; ACanvas.Pen.Style = HCPenStyle.psSolid; ACanvas.Pen.Color = HC.clActiveBorder; } finally { ACanvas.Pen.EndUpdate(); } SIZE vPt = new SIZE(); GDI.SetViewportExtEx(ACanvas.Handle, APaintInfo.WindowWidth, APaintInfo.WindowHeight, ref vPt); try { ACanvas.MoveTo(APaintInfo.GetScaleX(ADrawRect.Right) + 4, APaintInfo.GetScaleY(ADrawRect.Bottom) - 8); ACanvas.LineTo(APaintInfo.GetScaleX(ADrawRect.Right) + 6, APaintInfo.GetScaleY(ADrawRect.Bottom) - 8); ACanvas.LineTo(APaintInfo.GetScaleX(ADrawRect.Right) + 6, APaintInfo.GetScaleY(ADrawRect.Bottom) - 3); ACanvas.MoveTo(APaintInfo.GetScaleX(ADrawRect.Right), APaintInfo.GetScaleY(ADrawRect.Bottom) - 3); ACanvas.LineTo(APaintInfo.GetScaleX(ADrawRect.Right) + 6, APaintInfo.GetScaleY(ADrawRect.Bottom) - 3); ACanvas.MoveTo(APaintInfo.GetScaleX(ADrawRect.Right) + 1, APaintInfo.GetScaleY(ADrawRect.Bottom) - 4); ACanvas.LineTo(APaintInfo.GetScaleX(ADrawRect.Right) + 1, APaintInfo.GetScaleY(ADrawRect.Bottom) - 1); ACanvas.MoveTo(APaintInfo.GetScaleX(ADrawRect.Right) + 2, APaintInfo.GetScaleY(ADrawRect.Bottom) - 5); ACanvas.LineTo(APaintInfo.GetScaleX(ADrawRect.Right) + 2, APaintInfo.GetScaleY(ADrawRect.Bottom)); } finally { GDI.SetViewportExtEx(ACanvas.Handle, APaintInfo.GetScaleX(APaintInfo.WindowWidth), APaintInfo.GetScaleY(APaintInfo.WindowHeight), ref vPt); } }
public virtual void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { }
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); } }