Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Specify complex expressions and use custom functions in shape templates

License

NotificationsYou must be signed in to change notification settings

DevExpress-Examples/wpf-diagram-use-custom-functions-in-shape-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF DiagramControl - Complex Expressions and Custom Functions in Shape Templates

This example uses complex expressions and custom functions to calculate theShapeTemplate'sParameter value. You can use custom expressions or functions to implement complex logic forParameters (for example, a circular motion).

In this example, the customSector shape allows users to specify its angle:

image

Implementation Details

ShapeTemplates accept functions that implement theICustomFunctionOperator interface.Criteria Language Syntax allows you to calculate shapeParameters.

To create a custom calculation function, you must:

  1. Create a function class that implements theICustomFunctionOperator interface.
  2. Use theCriteriaOperator.RegisterCustomFunction method to register this function.
publicclassCreateArcPoint:ICustomFunctionOperator{privatestaticreadonlyCreateArcPointinstance=newCreateArcPoint();publicstaticvoidRegister(){CriteriaOperator.RegisterCustomFunction(instance);}publicstaticvoidUnregister(){CriteriaOperator.UnregisterCustomFunction(instance);}publicstringName=>nameof(CreateArcPoint);publicTypeResultType(paramsType[]operands){returntypeof(double);}publicobjectEvaluate(paramsobject[]operands){if(operands.Length==3&&operands[0]isdoubleX&&operands[1]isdoubleY&&operands[2]isstringaxe){if(axeis"X")returnX>0.5?X:0.5;returnX>0.5?Y:1;}elsereturnnull;}}
<ShapeTemplatex:Key="{ShapeKey Sector}"DefaultSize="120, 120"><StartX="0.5"Y="0" /><LineX="0.5"Y="0.5"/><LineX="(COS(P0) + 1)/2"Y="(SIN(P0) + 1)/2" /><ArcX="CreateArcPoint((COS(P0) + 1)/2, (SIN(P0) + 1)/2, 'X')"Y="CreateArcPoint((COS(P0) + 1)/2, (SIN(P0) + 1)/2, 'Y')"Direction="Counterclockwise"Size="CreateSize(W/2, H/2)"/><ArcX="0.5"Y="0"Direction="Counterclockwise"Size="CreateSize(W/2, H/2)" /><ShapeTemplate.ConnectionPoints><ShapePointX="0.5"Y="1" /><ShapePointX="1"Y="0.5" /><ShapePointX="0.5"Y="0" /><ShapePointX="0"Y="0.5" /></ShapeTemplate.ConnectionPoints><ShapeTemplate.Parameters><ParameterDefaultValue="0"Point="CreatePoint((COS(P) + 1)/2*W, (SIN(P) + 1)/2*H)"Value="atn2(P.Y/H*2-1, P.X/W*2-1)"Min="-3.14"Max="3.14" /></ShapeTemplate.Parameters></ShapeTemplate>

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Specify complex expressions and use custom functions in shape templates

Topics

Resources

License

Stars

Watchers

Forks

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp