■ DiagramControl 클래스에서 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 |
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 stencil = new DiagramStencil("SVGStencil", "SVGStencil"); string fileNameWithoutExtension = null; foreach(string filePath in Directory.GetFiles("IMAGE")) { try { fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath); using(FileStream stream = File.Open(filePath, FileMode.Open)) { ShapeDescription shapeDescription = ShapeDescription.CreateSvgShape ( fileNameWithoutExtension, fileNameWithoutExtension, stream ) .Update(getDefaultSize : () => new System.Windows.Size(100, 100)) .Update(getConnectionPoints : (w, h, p) => new[] { new System.Windows.Point(w / 2, h / 2) }); stencil.RegisterShape(shapeDescription); } } catch { } } DiagramToolboxRegistrator.RegisterStencil(stencil); this.diagramControl.SelectedStencils.Add("SVGStencil"); this.diagramControl.Items.Add ( new DiagramShape() { Shape = stencil.GetShape("aid-kit"), Width = 100, Height = 100, Position = new PointFloat(400, 300) } ); } #endregion } } |