appccelerate / statemachine

A .net library that lets you build state machines (hierarchical, async with fluent definition syntax and reporting capabilities).
Apache License 2.0
481 stars 128 forks source link

[Question] How to support chinese #81

Closed BurningTeng closed 2 years ago

BurningTeng commented 2 years ago

I write code like below: `const string start_request_holiday = "填写请假单"; const string project_manager_audit = "项目经理审批"; const string is_over_three = "是否大于3天"; const string depart_project_audit = "部门经理审批"; const string end_request = "流程结束"; const char agree = 'y'; const char disagree = 'n';

// Instantiate a new state machine in the 'off' state var stateSwitch = new StateMachine<string, char>(start_request_holiday);

// Configure state machine with the Configure method, supplying the state to be configured as a parameter stateSwitch.Configure(start_request_holiday).Permit(agree, project_manager_audit); stateSwitch.Configure(project_manager_audit).Permit(agree, is_over_three); stateSwitch.Configure(project_manager_audit).Permit(disagree, end_request); stateSwitch.Configure(is_over_three).Permit(agree, depart_project_audit); stateSwitch.Configure(is_over_three).Permit(disagree, end_request); stateSwitch.Configure(depart_project_audit).Permit(agree, end_request);

//node [fontname="Microsoft YaHei" shape=Mrecord] 才可以显示中文 //dot -T pdf -o phoneCall.pdf test.dot string graph = UmlDotGraph.Format(stateSwitch.GetInfo()); Console.WriteLine(graph);

Console.WriteLine("Press to toggle the switch. Any other key will exit the program.");

while (true) { Console.WriteLine("Switch is in state: " + stateSwitch.State); var pressed = Console.ReadKey(true).KeyChar;

// Check if user wants to exit
if (stateSwitch.State.ToString().Contains("结束")) break;

// Use the Fire method with the trigger as payload to supply the state machine with an event.
// The state machine will react according to its configuration.
stateSwitch.Fire(pressed);

} `

  1. digraph is below digraph { compound=true; node [shape=Mrecord] rankdir="LR" "填写请假单" [label="填写请假单"]; "项目经理审批" [label="项目经理审批"]; "是否大于3天" [label="是否大于3天"]; "部门经理审批" [label="部门经理审批"]; "流程结束" [label="流程结束"];

"填写请假单" -> "项目经理审批" [style="solid", label="y"]; "项目经理审批" -> "是否大于3天" [style="solid", label="y"]; "项目经理审批" -> "流程结束" [style="solid", label="n"]; "是否大于3天" -> "部门经理审批" [style="solid", label="y"]; "是否大于3天" -> "流程结束" [style="solid", label="n"]; "部门经理审批" -> "流程结束" [style="solid", label="y"]; init [label="", shape=point]; init -> "填写请假单"[style = "solid"] }

  1. when I convert to pdf, It can not show properly.
  2. When I add "node [fontname="Microsoft YaHei" shape=Mrecord] ". Then convert, it can work properly.

How can add it by programming.

ursenzler commented 2 years ago

I guess you should ask there: https://github.com/dotnet-state-machine/stateless

BurningTeng commented 2 years ago

Thanks. I have resolve it by add it to output string