■ ShapeDescription 클래스의 CreateSvgShape 정적 메소드를 SVG 도형을 생성하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
using System.Drawing; using System.IO; using DevExpress.Diagram.Core; using DevExpress.Utils; using DevExpress.XtraDiagram; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); DiagramStencil diagramStencil = new DiagramStencil("SVGShape", "SVGShape"); for(int i = 1; i < 6; i++) { string filePath = $"IMAGE\\chart{i}.svg"; using(FileStream stream = File.OpenRead(filePath)) { ShapeDescription shapeDescription = ShapeDescription.CreateSvgShape($"chart{i}", $"chart{i}", stream); diagramStencil.RegisterShape(shapeDescription); } } for(int i = 0; i < 5; i++) { int x = GetColumnIndex(5, i); int y = GetRowIndex(5, i); DiagramShape shape = new DiagramShape(); shape.Size = new SizeF(100f, 100f); shape.Position = new PointFloat(x * 150f + 100f, y * 150f + 100f); shape.Shape = diagramStencil.GetShape($"chart{i + 1}"); this.diagramControl.Items.Add(shape); } this.diagramControl.FitToDrawing(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 행 인덱스 구하기 - GetRowIndex(columnCount, sequenceIndex) /// <summary> /// 행 인덱스 구하기 /// </summary> /// <param name="columnCount">컬럼 수</param> /// <param name="sequenceIndex">순번 인덱스</param> /// <returns>행 인덱스</returns> private int GetRowIndex(int columnCount, int sequenceIndex) { return sequenceIndex / columnCount; } #endregion #region 컬럼 인덱스 구하기 - GetColumnIndex(columnCount, sequenceIndex) /// <summary> /// 컬럼 인덱스 구하기 /// </summary> /// <param name="columnCount">컬럼 수</param> /// <param name="sequenceIndex">순번 인덱스</param> /// <returns>컬럼 인덱스</returns> private int GetColumnIndex(int columnCount, int sequenceIndex) { return sequenceIndex % columnCount; } #endregion } } |