[DEVEXPRESS/WINFORM] DiagramControl 클래스 : 연결 포인트를 갖는 커스텀 도형 생성하기
DevExpress/WinForm 2020. 6. 7. 06:50728x90
반응형
728x170
▶ CustomShape.xml
<?xml version="1.0"?>
<Shapes xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ShapeTemplate Id="Shape1" DefaultSize="50,100" Rows="*" Columns="*">
<Start X="0" Y="0" />
<Line X="1" Y="0" />
<Line X="0.8" Y="0.8" />
<Line X="0" Y="1" />
<ConnectionPoints>
<ShapePoint X="0" Y="0" />
<ShapePoint X="0.5" Y="0" />
<ShapePoint X="1" Y="0" />
<ShapePoint X="0.8" Y="0.8" />
<ShapePoint X="0" Y="1" />
<ShapePoint X="0" Y="0.5" />
</ConnectionPoints>
<Parameters />
</ShapeTemplate>
<ShapeTemplate Id="Shape2" DefaultSize="60,120" Rows="*" Columns="*">
<Start X="0" Y="0" FillColor="Brown" />
<Arc X="1" Y="0" Size="CreateSize([W] / 2 , [H] / 10)" />
<Arc X="1" Y="1" Size="CreateSize([W] / 10, [H] / 2 )" />
<Arc X="0" Y="1" Size="CreateSize([W] / 2 , [H] / 10)" />
<Arc X="0" Y="0" Size="CreateSize([W] / 10, [H] / 2 )" />
<ConnectionPoints>
<ShapePoint X="0" Y="0" />
<ShapePoint X="1" Y="0" />
<ShapePoint X="0" Y="1" />
</ConnectionPoints>
<Parameters />
</ShapeTemplate>
<ShapeTemplate Id="Shape3" DefaultSize="60,120" Rows="*" Columns="*">
<Start X="0" Y="0" FillColor="Brown" />
<Arc X="1" Y="0" Size="CreateSize([W] / 2, [P0] * [H])" />
<Line X="1" Y="1" />
<Line X="0" Y="1" />
<Line X="0" Y="0" />
<ConnectionPoints>
<ShapePoint X="0" Y="0" />
<ShapePoint X="1" Y="0" />
<ShapePoint X="0" Y="1" />
</ConnectionPoints>
<Parameters>
<Parameter DefaultValue="0.1" Value="[P.Y] / [H]" Point="CreatePoint([W] / 2, [P] * [H])" Min="0" Max="1" />
</Parameters>
</ShapeTemplate>
<ShapeTemplate Id="Shape4" DefaultSize="60,120" IsQuick="true" Rows="[H] * [P0];[H] * (1 - [P0])" Columns="*">
<Start X="0" Y="0" FillColor="Green" />
<Line X="1" Y="0" />
<Line X="1" Y="1" />
<Line X="0" Y="1" />
<Start X="0" Y="1" FillColor="Red" />
<Line X="1" Y="1" />
<Line X="1" Y="2" />
<Line X="0" Y="2" />
<ConnectionPoints>
<ShapePoint X="0.5" Y="0" />
<ShapePoint X="1" Y="1" />
<ShapePoint X="0.5" Y="2" />
<ShapePoint X="0" Y="1" />
</ConnectionPoints>
<Parameters>
<Parameter DefaultValue="0.5" Value="[P.Y] / [H]" Point="CreatePoint([W], [P] * [H])" Min="0" Max="1" />
</Parameters>
</ShapeTemplate>
</Shapes>
728x90
▶ MainForm.cs
using System;
using System.IO;
using DevExpress.Diagram.Core;
using DevExpress.XtraBars.Ribbon;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : RibbonForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
using(FileStream stream = new FileStream("CustomShape.xml", FileMode.Open))
{
DiagramStencil stencil = DiagramStencil.Create("CustomShapes", "Custom Shapes", stream, shapeName => shapeName);
DiagramToolboxRegistrator.RegisterStencil(stencil);
}
this.diagramControl.SelectedStencils = new StencilCollection(new string[] { "CustomShapes" });
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Protected
#region 폼 로드시 처리하기 - OnLoad(e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="e">이벤트 인자</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.diagramControl.InitializeRibbon(this.ribbonControl);
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요