첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

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<ShapeDescription> list = new List<ShapeDescription>();

            list.Add(BasicShapes.Can                              );
            list.Add(BasicShapes.Chevron                          );
            list.Add(BasicShapes.Cross                            );
            list.Add(BasicShapes.Cube                             );
            list.Add(BasicShapes.Decagon                          );
            list.Add(BasicShapes.DiagonalStripe                   );
            list.Add(BasicShapes.Diamond                          );
            list.Add(BasicShapes.Donut                            );
            list.Add(BasicShapes.Ellipse                          );
            list.Add(BasicShapes.Frame                            );
            list.Add(BasicShapes.FrameCorner                      );
            list.Add(BasicShapes.Heptagon                         );
            list.Add(BasicShapes.Hexagon                          );
            list.Add(BasicShapes.LShape                           );
            list.Add(BasicShapes.LeftBrace                        );
            list.Add(BasicShapes.LeftParenthesis                  );
            list.Add(BasicShapes.NoSymbol                         );
            list.Add(BasicShapes.Octagon                          );
            list.Add(BasicShapes.Parallelogram                    );
            list.Add(BasicShapes.Pentagon                         );
            list.Add(BasicShapes.Plaque                           );
            list.Add(BasicShapes.Rectangle                        );
            list.Add(BasicShapes.RightBrace                       );
            list.Add(BasicShapes.RightParenthesis                 );
            list.Add(BasicShapes.RightTriangle                    );
            list.Add(BasicShapes.RoundCornerRectangle             );
            list.Add(BasicShapes.RoundDiagonalCornerRectangle     );
            list.Add(BasicShapes.RoundSameSideCornerRectangle     );
            list.Add(BasicShapes.RoundedRectangle                 );
            list.Add(BasicShapes.SingleRoundCornerRectangle       );
            list.Add(BasicShapes.SingleSnipCornerRectangle        );
            list.Add(BasicShapes.SnipAndRoundCornerRectangle      );
            list.Add(BasicShapes.SnipAndRoundSingleCornerRectangle);
            list.Add(BasicShapes.SnipCornerRectangle              );
            list.Add(BasicShapes.SnipDiagonalCornerRectangle      );
            list.Add(BasicShapes.SnipSameSideCornerRectangle      );
            list.Add(BasicShapes.Star16                           );
            list.Add(BasicShapes.Star24                           );
            list.Add(BasicShapes.Star32                           );
            list.Add(BasicShapes.Star4                            );
            list.Add(BasicShapes.Star5                            );
            list.Add(BasicShapes.Star6                            );
            list.Add(BasicShapes.Star7                            );
            list.Add(BasicShapes.Trapezoid                        );
            list.Add(BasicShapes.Triangle                         );

            list.Add(BasicFlowchartShapes.Custom1                 );
            list.Add(BasicFlowchartShapes.Custom2                 );
            list.Add(BasicFlowchartShapes.Custom3                 );
            list.Add(BasicFlowchartShapes.Custom4                 );
            list.Add(BasicFlowchartShapes.Data                    );
            list.Add(BasicFlowchartShapes.Database                );
            list.Add(BasicFlowchartShapes.Decision                );
            list.Add(BasicFlowchartShapes.Document                );
            list.Add(BasicFlowchartShapes.ExternalData            );
            list.Add(BasicFlowchartShapes.OffPageReference        );
            list.Add(BasicFlowchartShapes.OnPageReference         );
            list.Add(BasicFlowchartShapes.Process                 );
            list.Add(BasicFlowchartShapes.StartEnd                );
            list.Add(BasicFlowchartShapes.Subprocess              );

            list.Add(SDLDiagramShapes.Alternative                 );
            list.Add(SDLDiagramShapes.CreateRequest               );
            list.Add(SDLDiagramShapes.Decision1                   );
            list.Add(SDLDiagramShapes.Decision2                   );
            list.Add(SDLDiagramShapes.DiskStorage                 );
            list.Add(SDLDiagramShapes.DividedEvent                );
            list.Add(SDLDiagramShapes.DividedProcess              );
            list.Add(SDLDiagramShapes.Document                    );
            list.Add(SDLDiagramShapes.MessageFromUser             );
            list.Add(SDLDiagramShapes.MessageToUser               );
            list.Add(SDLDiagramShapes.OffPageReference            );
            list.Add(SDLDiagramShapes.OnPageReference             );
            list.Add(SDLDiagramShapes.PrimitiveFromCallControl    );
            list.Add(SDLDiagramShapes.PrimitiveToCallControl      );
            list.Add(SDLDiagramShapes.Procedure                   );
            list.Add(SDLDiagramShapes.Return                      );
            list.Add(SDLDiagramShapes.Save                        );
            list.Add(SDLDiagramShapes.Start                       );
            list.Add(SDLDiagramShapes.Terminator                  );
            list.Add(SDLDiagramShapes.VariableProcedure           );
            list.Add(SDLDiagramShapes.VariableStart               );

            list.Add(ArrowShapes.BentArrow                        );
            list.Add(ArrowShapes.BlockArrow                       );
            list.Add(ArrowShapes.CircularArrow                    );
            list.Add(ArrowShapes.CurvedLeftArrow                  );
            list.Add(ArrowShapes.CurvedRightArrow                 );
            list.Add(ArrowShapes.FlexibleArrow                    );
            list.Add(ArrowShapes.LeftRightArrowBlock              );
            list.Add(ArrowShapes.LeftRightUpArrow                 );
            list.Add(ArrowShapes.ModernArrow                      );
            list.Add(ArrowShapes.NotchedArrow                     );
            list.Add(ArrowShapes.QuadArrow                        );
            list.Add(ArrowShapes.QuadArrowBlock                   );
            list.Add(ArrowShapes.SharpBentArrow                   );
            list.Add(ArrowShapes.SimpleArrow                      );
            list.Add(ArrowShapes.SimpleDoubleArrow                );
            list.Add(ArrowShapes.StripedArrow                     );
            list.Add(ArrowShapes.UTurnArrow                       );

            list.Add(SoftwareIcons.Add                            );
            list.Add(SoftwareIcons.Back                           );
            list.Add(SoftwareIcons.Calendar                       );
            list.Add(SoftwareIcons.Collapse                       );
            list.Add(SoftwareIcons.Database                       );
            list.Add(SoftwareIcons.Document                       );
            list.Add(SoftwareIcons.Expand                         );
            list.Add(SoftwareIcons.Filter                         );
            list.Add(SoftwareIcons.Forward                        );
            list.Add(SoftwareIcons.HardDrive                      );
            list.Add(SoftwareIcons.Lock                           );
            list.Add(SoftwareIcons.Network                        );
            list.Add(SoftwareIcons.Permission                     );
            list.Add(SoftwareIcons.Properties                     );
            list.Add(SoftwareIcons.Remove                         );
            list.Add(SoftwareIcons.Sort                           );
            list.Add(SoftwareIcons.Tools                          );
            list.Add(SoftwareIcons.ZoomIn                         );
            list.Add(SoftwareIcons.ZoomOut                        );

            list.Add(DecorativeShapes.Cloud                       );
            list.Add(DecorativeShapes.DoubleWave                  );
            list.Add(DecorativeShapes.DownRibbon                  );
            list.Add(DecorativeShapes.Heart                       );
            list.Add(DecorativeShapes.HorizontalScroll            );
            list.Add(DecorativeShapes.LightningBolt               );
            list.Add(DecorativeShapes.Moon                        );
            list.Add(DecorativeShapes.UpRibbon                    );
            list.Add(DecorativeShapes.VerticalScroll              );
            list.Add(DecorativeShapes.Wave                        );

            for(int i = 0; i < list.Count; i++)
            {
                int x = GetColumnIndex(10, i);
                int y = GetRowIndex(10, i);

                DiagramShape shape = new DiagramShape();

                shape.Size                   = new SizeF(100f, 100f);
                shape.Position               = new PointFloat(x * 150f + 100f, y * 150f + 100f);
                shape.Shape                  = list[i];
                shape.Appearance.BorderSize  = 4;
                shape.Appearance.BorderColor = Color.FromArgb(128, 0, 0, 0);
                shape.Appearance.BackColor   = Color.White;

                this.diagramControl.Items.Add(shape);
            }

            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

댓글을 달아 주세요