// 홀그리기 private void DrawHole(ImageGraphics ig, Hole hole, bool holeDrawCircle, Pen linePen, HoleInfoItemType infoItemType, Font infoFont, Brush infoBrush) { if (holeDrawCircle) { DrawHoleCircle(ig, hole, linePen); } else { DrawHolePoint(ig, hole, linePen); } if (infoItemType == HoleInfoItemType.None || skipDrawHoleInfo) { return; } string infoText; if (infoItemType == HoleInfoItemType.IndexX) { infoText = hole.idxX.ToString(); } else if (infoItemType == HoleInfoItemType.IndexY) { infoText = hole.idxY.ToString(); } else { infoText = hole.fwd.ToString(); } DrawHoleInfo(ig, hole, infoText, infoFont, infoBrush); }
/// <summary> /// The implementation details for the <see cref="HoverLeave"/> method. /// </summary> protected override void HoverLeaveDetail() { if (this.hoverImageGraphics != null) // This isn't necessary, just convention { this.imageGraphics = this.defaultImageGraphics; } }
/// <summary> /// The implementation details for the <see cref="Hover"/> method. /// </summary> protected override void HoverDetail() { if (this.hoverImageGraphics != null) { this.imageGraphics = this.hoverImageGraphics; } }
private void pbx_Paint(object sender, PaintEventArgs e) { ImageGraphics ig = new ImageGraphics(sender as ImageBox, e.Graphics); if ((sender as ImageBox).Tag is Action <ImageGraphics> drawing) { drawing(ig); } }
// 개별 홀 써클 드로우 private void DrawHoleCircle(ImageGraphics ig, Hole hole, Pen pen) { float x1 = hole.x - hole.w * 0.5f; float y1 = hole.y - hole.h * 0.5f; float x2 = hole.x + hole.w * 0.5f; float y2 = hole.y + hole.h * 0.5f; ig.DrawEllipse(pen, x1, y1, x2 - x1, y2 - y1); }
private void imageBox_Paint(object sender, PaintEventArgs e) { ImageGraphics ig = imgBox.GetImageGraphics(e.Graphics); if (lbxDrawTest.SelectedIndex == 2) { ImageGraphicsShape(ig); } else if (lbxDrawTest.SelectedIndex == 4) { ImageGraphicsRepeat(ig); } }
private void ImageGraphicsShape(ImageGraphics ig) { var font = dlgFont.Font; ig.DrawLine(Pens.Red, 0, 0, 8, 8); ig.DrawRectangle(Pens.Red, 8, 8, 4, 4); ig.DrawRectangle(Pens.Red, 16.5f, 16.5f, 4f, 4f); var text = tbxExample.Text; ig.DrawString(text, font, Brushes.Blue, 50, 50); ig.DrawString(text, font, Brushes.Blue, 200, 200, Brushes.Yellow); }
/// <summary> /// Builds the components. /// </summary> private void BuildComponents() { this.defaultImageGraphics = new ImageGraphics(this.Texture, PositionFactory.Center()); this.defaultImageGraphics.Initialise(this.GetBounds()); if (this.HoverTexture != null) { this.hoverImageGraphics = new ImageGraphics(this.HoverTexture, PositionFactory.Center()); this.hoverImageGraphics.Initialise(this.GetBounds()); } this.imageGraphics = this.defaultImageGraphics; }
private void DrawHoles(ImageGraphics ig) { if (holes == null) { return; } var ptDisp1 = new Point(0, 0); var ptDisp2 = (Point)pbxDraw.ClientSize; var ptImg1 = pbxDraw.DispToImg(ptDisp1); var ptImg2 = pbxDraw.DispToImg(ptDisp2); float imgX1 = (float)Math.Floor(ptImg1.X); float imgY1 = (float)Math.Floor(ptImg1.Y); float imgX2 = (float)Math.Floor(ptImg2.X); float imgY2 = (float)Math.Floor(ptImg2.Y); double zoomFactor = pbxDraw.GetZoomFactor(); skipDrawHoleInfo = zoomFactor < 0.5; Pen linePen = Pens.Red; Brush infoBrush = Brushes.Yellow; Font infoFont = SystemFonts.DefaultFont; float holePitch = 32.0f; bool holeDrawCircle = zoomFactor > (4.0 / holePitch); HoleInfoItemType infoItemType = HoleInfoItemType.None; if (rdoHoleInfoIndexX.Checked) { infoItemType = HoleInfoItemType.IndexX; } else if (rdoHoleInfoIndexY.Checked) { infoItemType = HoleInfoItemType.IndexY; } else if (rdoHoleInfoFWD.Checked) { infoItemType = HoleInfoItemType.Fwd; } // 쿼드트리 사용하여 비저블 역역에 포함되는 노드만 그림 DrawNodeHole(tree.root, imgX1, imgY1, imgX2, imgY2, ig, zoomFactor, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); if (chkDrawCursorHole.Checked && cursorHole != null) { DrawHole(ig, cursorHole, holeDrawCircle, Pens.Lime, infoItemType, infoFont, infoBrush); } }
private void ImageGraphicsRepeat(ImageGraphics ig) { for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { ig.DrawCircle(Pens.Lime, j, i, 1, false); ig.DrawSquare(Pens.Lime, j, i, 1, false); ig.DrawCross(Pens.Lime, j, i, 1, false); ig.DrawPlus(Pens.Lime, j, i, 1, false); ig.DrawCircle(Pens.Lime, j, i, 8, true); ig.DrawSquare(Pens.Lime, j, i, 8, true); ig.DrawCross(Pens.Lime, j, i, 8, true); ig.DrawPlus(Pens.Lime, j, i, 8, true); } } }
private void pbxDraw_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; var ig = new ImageGraphics(pbxDraw, g); if (chkDrawHoles.Checked) { DrawHoles(ig); } if (chkDrawFrame.Checked) { DrawFrame(ig); } if (chkDrawCursorHole.Checked) { DrawCursorHoleInfo(g); } }
// 프레임 표시 private void DrawFrame(ImageGraphics ig) { var clientSize = pbxDraw.ClientSize; for (int ifwd = 0; ifwd < fwdNum; ifwd++) { int x1 = (frmW - fwdOvlp) * ifwd; PointF ptLTi = new PointF(x1, 0); PointF ptRBi = new PointF(x1 + frmW, imgBH); PointF ptLTd = pbxDraw.ImgToDisp(ptLTi); PointF ptRBd = pbxDraw.ImgToDisp(ptRBi); if (ptRBd.Y < 0 || ptLTd.Y >= clientSize.Height || ptRBd.X < 0 || ptLTd.X >= clientSize.Width) { continue; } ig.DrawRectangle(Pens.PowderBlue, ptLTi.X, ptLTi.Y, ptRBi.X - ptLTi.X, ptRBi.Y - ptLTi.Y); for (int ifrm = 0; ifrm < frmNum; ifrm++) { var ptImg1 = new PointF(x1, frmH * ifrm); var ptImg2 = new PointF(x1 + frmW, frmH * ifrm); var ptDisp1 = pbxDraw.ImgToDisp(ptImg1); var ptDisp2 = pbxDraw.ImgToDisp(ptImg2); if (ptDisp1.Y < 0 || ptDisp1.Y >= clientSize.Height || ptDisp1.X >= clientSize.Width || ptDisp2.X < 0) { continue; } ig.DrawLine(Pens.PowderBlue, ptImg1, ptImg2); if (frmH * pbxDraw.GetZoomFactor() < 20) { continue; } ig.DrawString($"fwd={ifwd}/frm={ifrm}", Font, Brushes.LightBlue, ptImg1); } } }
private void pbx0_Paint(object sender, PaintEventArgs e) { var ig = new ImageGraphics(e.Graphics, pbx0.GetZoomFactor(), pbx0.SzPan); dispInfo.graphics?.Invoke(ig); }
private void BuildComponents() { this.image = new ImageGraphics(this.Texture, PositionProfileFactory.BuildCenteredRelative()); this.image.Initialise(this.GetBounds()); }
// 홀 정보 표시 private void DrawHoleInfo(ImageGraphics ig, Hole hole, string infoText, Font font, Brush brush) { ig.DrawString(infoText, Font, brush, new PointF(hole.x, hole.y)); }
// 개별 홀 포인트 드로우 private void DrawHolePoint(ImageGraphics ig, Hole hole, Pen linePen) { ig.DrawSquare(linePen, hole.x, hole.y, 1); }
// 노드 홀 그리기 private void DrawNodeHole(QuadTreeNode node, float imgX1, float imgY1, float imgX2, float imgY2, ImageGraphics ig, double zoomFactor, bool holeDrawCircle, Pen linePen, HoleInfoItemType infoItemType, Font infoFont, Brush infoBrush) { // 뷰 영역에 벗어난 노드는 리턴 if (node.x1 > imgX2 || node.y1 > imgY2 || node.x2 < imgX1 || node.y2 < imgY1) { return; } // 현재 레벨에서 드로우 if ((node.x2 - node.x1) * zoomFactor <= 8.0) { DrawHole(ig, node.holeFront, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); return; } // 노드가 리프 노드 이면 노드에 포함된 홀 그리고 리턴 if (node.holes != null) { foreach (Hole hole in node.holes) { DrawHole(ig, hole, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); } return; } // 하위 노드로 내려감 if (node.childLT != null) { DrawNodeHole(node.childLT, imgX1, imgY1, imgX2, imgY2, ig, zoomFactor, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); } if (node.childRT != null) { DrawNodeHole(node.childRT, imgX1, imgY1, imgX2, imgY2, ig, zoomFactor, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); } if (node.childLB != null) { DrawNodeHole(node.childLB, imgX1, imgY1, imgX2, imgY2, ig, zoomFactor, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); } if (node.childRB != null) { DrawNodeHole(node.childRB, imgX1, imgY1, imgX2, imgY2, ig, zoomFactor, holeDrawCircle, linePen, infoItemType, infoFont, infoBrush); } }