■ DiagramControl 클래스 : SVG 도형 사용하기
------------------------------------------------------------------------------------------------------------------------
▶ MainForm.cs
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 } }
|
------------------------------------------------------------------------------------------------------------------------
댓글을 달아 주세요