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

728x90
반응형

■ DiagramConnector 클래스 : BeginArrow/EndArrow 속성을 사용해 화살표 스타일 설정하기

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


TestProject.zip


MainForm.cs

 

 

using System.Collections.Generic;

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;

 

            List<ArrowDescription> list = new List<ArrowDescription>();

 

            list.Add(ArrowDescriptions.Open90              );

            list.Add(ArrowDescriptions.FilledFletch        );

            list.Add(ArrowDescriptions.OutdentedFilledArrow);

            list.Add(ArrowDescriptions.Filled90            );

            list.Add(ArrowDescriptions.Diamond             );

            list.Add(ArrowDescriptions.FilledSquare        );

            list.Add(ArrowDescriptions.ClosedDot           );

            list.Add(ArrowDescriptions.FilledDiamond       );

            list.Add(ArrowDescriptions.ClosedASMEArrow     );

            list.Add(ArrowDescriptions.FilledDot           );

            list.Add(ArrowDescriptions.ClosedDiamond       );

            list.Add(ArrowDescriptions.FilledDoubleArrow   );

            list.Add(ArrowDescriptions.OpenFletch          );

            list.Add(ArrowDescriptions.IndentedFilledArrow );

            list.Add(ArrowDescriptions.ClosedDoubleArrow   );

 

            for(int i = 0; i < list.Count; i++)

            {

                int x = GetColumnIndex(3, i);

                int y = GetRowIndex(3, i);

 

                DiagramConnector connector = new DiagramConnector();

 

                connector.BeginPoint                   = new PointFloat(x * 200f + 100f, y * 150f + 100f);

                connector.EndPoint                     = new PointFloat(x * 200f + 200f, y * 150f + 100f);

                connector.BeginArrow                   = null;

                connector.EndArrow                     = list[i];

                connector.Type                         = ConnectorType.Straight;

                connector.Appearance.BorderSize        = 4;

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

                connector.Appearance.ContentBackground = Color.Transparent;

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

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

                connector.Content                      = "\n\n" + list[i].ToString();

 

                this.diagramControl.Items.Add(connector);

            }

 

            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

    }

}

 

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

728x90
반응형
Posted by 사용자 icodebroker

댓글을 달아 주세요