첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ 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
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker

댓글을 달아 주세요