public static FlowcharStruct getFlowcharStruct(string xaml) { char[] sp = { ',' }; char[] sl = { ' ' }; //(1) FlowcharStruct flowcharStruct = new FlowcharStruct(); //(2) DynamicActivity dynamicActivity = XamlTool.getDynamicActivityByString(xaml); Activity activity = XamlTool.getRuntimeActivityByDynamicActivity(dynamicActivity); Flowchart flowchar = activity as Flowchart; if (flowchar == null) { return null; } //(3)===================================== //(3.1)---------------------------------------------------------------------------------- flowcharStruct.beginNode.DisplayName = "开始"; flowcharStruct.beginNode.id = "begin"; //(3.1.1) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"].ToString(); flowcharStruct.beginNode.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.1.2) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"].ToString(); flowcharStruct.beginNode.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.1.3) if (WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"] != null) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine oneline = new WFLine(); oneline.beginNodeID = flowchar.Id; oneline.text = flowchar.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); oneline.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(oneline); } //(3.2)-------------------------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowStep flowStep = flowNode as FlowStep; if (flowStep != null) { WFNode node = new WFNode(); node.DisplayName = flowStep.Action.DisplayName; node.id = flowStep.Action.Id; //(3.2.1) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.2.2) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.2.3) if (WorkflowViewStateService.GetViewState(flowStep).Count(p => p.Key == "ConnectorLocation") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowStep)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowStep.Action.Id; line.text = flowStep.Action.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } flowcharStruct.nodeList.Add(node); } } //(3.3)------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowSwitch<string> flowSwitch = flowNode as FlowSwitch<string>; if (flowSwitch != null) { WFNode node = new WFNode(); node.DisplayName = flowSwitch.Expression.DisplayName; node.id = flowSwitch.Expression.Id; //(3.3.1) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.3.2) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.3.3) if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == "Default") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)["Default"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } //(3.3.4) foreach (var v in flowSwitch.Cases) { FlowNode next = v.Value; Console.WriteLine(v.Key); string caseValue = v.Key + "Connector"; if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == caseValue) == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)[caseValue].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } } flowcharStruct.nodeList.Add(node); } } return flowcharStruct; }
public NodeControl(WFNode node) { InitializeComponent(); showFlowchar(node); }
public FlowcharStruct() { nodeList = new List <WFNode>(); lineList = new List <WFLine>(); beginNode = new WFNode(); endNode = new WFNode(); }
public FlowcharStruct() { nodeList = new List<WFNode>(); lineList = new List<WFLine>(); beginNode = new WFNode(); endNode = new WFNode(); }
void showFlowchar(WFNode node) { this.Background = System.Windows.Media.Brushes.Red; Canvas.SetLeft(this, node.ShapeSize.x); Canvas.SetTop(this, node.ShapeSize.y); this.Width =node.ShapeSize.width; this.Height = node.ShapeSize.height; this.displayName.Text = node.DisplayName; }
public static FlowcharStruct getFlowcharStruct(string xaml) { char[] sp = { ',' }; char[] sl = { ' ' }; //(1) FlowcharStruct flowcharStruct = new FlowcharStruct(); //(2) DynamicActivity dynamicActivity = XamlTool.getDynamicActivityByString(xaml); Activity activity = XamlTool.getRuntimeActivityByDynamicActivity(dynamicActivity); Flowchart flowchar = activity as Flowchart; if (flowchar == null) { return(null); } //(3)===================================== //(3.1)---------------------------------------------------------------------------------- flowcharStruct.beginNode.DisplayName = "开始"; flowcharStruct.beginNode.id = "begin"; //(3.1.1) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"].ToString(); flowcharStruct.beginNode.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.1.2) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"].ToString(); flowcharStruct.beginNode.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.1.3) if (WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"] != null) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine oneline = new WFLine(); oneline.beginNodeID = flowchar.Id; oneline.text = flowchar.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); oneline.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(oneline); } //(3.2)-------------------------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowStep flowStep = flowNode as FlowStep; if (flowStep != null) { WFNode node = new WFNode(); node.DisplayName = flowStep.Action.DisplayName; node.id = flowStep.Action.Id; //(3.2.1) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.2.2) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.2.3) if (WorkflowViewStateService.GetViewState(flowStep).Count(p => p.Key == "ConnectorLocation") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowStep)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowStep.Action.Id; line.text = flowStep.Action.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } flowcharStruct.nodeList.Add(node); } } //(3.3)------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowSwitch <string> flowSwitch = flowNode as FlowSwitch <string>; if (flowSwitch != null) { WFNode node = new WFNode(); node.DisplayName = flowSwitch.Expression.DisplayName; node.id = flowSwitch.Expression.Id; //(3.3.1) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.3.2) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.3.3) if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == "Default") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)["Default"].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } //(3.3.4) foreach (var v in flowSwitch.Cases) { FlowNode next = v.Value; Console.WriteLine(v.Key); string caseValue = v.Key + "Connector"; if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == caseValue) == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)[caseValue].ToString(); string[] points = ConnectorLocation.Split(sl); WFLine line = new WFLine(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WFPoint() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } } flowcharStruct.nodeList.Add(node); } } return(flowcharStruct); }//end