첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ DiagramControl 클래스 : 도형 생성하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

using System.Drawing;

 

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();

 

            this.diagramControl.OptionsView.ShowGrid       = false;

            this.diagramControl.OptionsView.ShowRulers     = false;

            this.diagramControl.OptionsView.ShowPageBreaks = false;

 

            DiagramShape shape1 = new DiagramShape();

 

            shape1.Size                   = new SizeF(100f, 100f);

            shape1.Position               = new PointFloat(450f, 200f);

            shape1.Shape                  = BasicShapes.Ellipse;

            shape1.Appearance.BorderSize  = 4;

            shape1.Appearance.BorderColor = Color.FromArgb(128, 0, 0, 0);

            shape1.Appearance.BackColor   = Color.White;

            shape1.Appearance.Font        = new Font("나눔고딕코딩", 12f, FontStyle.Bold);

            shape1.Appearance.ForeColor   = Color.FromArgb(128, 0, 0, 0);

            shape1.Content                = "도형1";

 

            this.diagramControl.Items.Add(shape1);

 

            DiagramShape shape2 = new DiagramShape();

 

            shape2.Size                   = new SizeF(100F, 100F);

            shape2.Position               = new PointFloat(300f, 400f);

            shape2.Shape                  = BasicShapes.Ellipse;

            shape2.Appearance.BorderSize  = 4;

            shape2.Appearance.BorderColor = Color.FromArgb(128, 0, 0, 0);

            shape2.Appearance.BackColor   = Color.White;

            shape2.Appearance.Font        = new Font("나눔고딕코딩", 12f, FontStyle.Bold);

            shape2.Appearance.ForeColor   = Color.FromArgb(128, 0, 0, 0);

            shape2.Content                = "도형2";

 

            this.diagramControl.Items.Add(shape2);

 

            DiagramConnector connector1 = new DiagramConnector();

 

            connector1.BeginItem                    = shape1;

            connector1.EndItem                      = shape2;

            connector1.Type                         = ConnectorType.Straight;

            connector1.Appearance.BorderSize        = 4;

            connector1.Appearance.BorderColor       = Color.FromArgb(128, 0, 0, 0);

            connector1.Appearance.ContentBackground = Color.Transparent;

            connector1.Appearance.Font              = new Font("나눔고딕코딩", 12f, FontStyle.Bold);

            connector1.Appearance.ForeColor         = Color.FromArgb(128, 255, 0, 0);

            connector1.Content                      = "연결 1";

 

            this.diagramControl.Items.Add(connector1);

 

            DiagramShape shape3 = new DiagramShape();

 

            shape3.Size                   = new SizeF(100f, 100f);

            shape3.Position               = new PointFloat(600f, 400f);

            shape3.Shape                  = BasicShapes.Ellipse;

            shape3.Appearance.BorderSize  = 4;

            shape3.Appearance.BorderColor = Color.FromArgb(128, 0, 0, 0);

            shape3.Appearance.BackColor   = Color.White;

            shape3.Appearance.Font        = new Font("나눔고딕코딩", 12f, FontStyle.Bold);

            shape3.Appearance.ForeColor   = Color.FromArgb(128, 0, 0, 0);

            shape3.Content                = "도형3";

 

            this.diagramControl.Items.Add(shape3);

 

            DiagramConnector connector2 = new DiagramConnector();

 

            connector2.BeginItem                    = shape1;

            connector2.EndItem                      = shape3;

            connector2.Type                         = ConnectorType.Straight;

            connector2.Appearance.BorderSize        = 4;

            connector2.Appearance.BorderColor       = Color.FromArgb(128, 0, 0, 0);

            connector2.Appearance.ContentBackground = Color.Transparent;

            connector2.Appearance.Font              = new Font("나눔고딕코딩", 12f, FontStyle.Bold);

            connector2.Appearance.ForeColor         = Color.FromArgb(128, 255, 0, 0);

            connector2.Content                      = "연결 2";

 

            this.diagramControl.Items.Add(connector2);

 

            this.diagramControl.FitToDrawing();

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요