private void CreateShapes(List <NodeInfo> nodeInfos) { for (int i = 0; i < nodeInfos.Count; i++) { NodeInfo nodeInfo = nodeInfos[i]; ChartShape shape = null; if (nodeInfo.IsNodeTypeQuestion) { QuestionConstructVM questionConstruct = (QuestionConstructVM)nodeInfo.Construct; QuestionShape questionShape = new QuestionShape(); questionShape.X = nodeInfo.X; questionShape.Y = nodeInfo.Y; questionShape.Width = nodeInfo.Width; questionShape.Height = nodeInfo.Height; questionShape.ToolTip = questionConstruct.Title; questionShape.Text = questionConstruct.No; shape = questionShape; } else if (nodeInfo.IsNodeTypeQuestionGroup) { QuestionGroupConstructVM questionGroupConstruct = (QuestionGroupConstructVM)nodeInfo.Construct; QuestionGroupShape questionGroupShape = new QuestionGroupShape(); questionGroupShape.X = nodeInfo.X; questionGroupShape.Y = nodeInfo.Y; questionGroupShape.Width = nodeInfo.Width; questionGroupShape.Height = nodeInfo.Height; questionGroupShape.ToolTip = questionGroupConstruct.Title; questionGroupShape.Text = questionGroupConstruct.No; shape = questionGroupShape; } else if (nodeInfo.IsNodeTypeStatement) { StatementVM statement = (StatementVM)nodeInfo.Construct; StatementShape statementShape = new StatementShape(); statementShape.X = nodeInfo.X; statementShape.Y = nodeInfo.Y; statementShape.Width = nodeInfo.Width; statementShape.Height = nodeInfo.Height; statementShape.ToolTip = statement.Text; statementShape.Text = statement.No; shape = statementShape; } else if (nodeInfo.IsNodeTypeBranch) { IfThenElseVM ifThenElse = (IfThenElseVM)nodeInfo.Construct; BranchShape branchShape = new BranchShape(ifThenElse, BranchClicked); branchShape.X = nodeInfo.X; branchShape.Y = nodeInfo.Y; branchShape.Width = nodeInfo.Width; branchShape.Height = nodeInfo.ContainerHeight; branchShape.ToolTip = ifThenElse.Title; shape = branchShape; //条件 List <CondInfo> condInfos = nodeInfo.CondInfos; double offsetY = 0; foreach (CondInfo condInfo in condInfos) { NodeInfo thenNodeInfo = NodeInfo.Find(nodeInfos, condInfo.TargetConstructId); int thenNodeIndex = nodeInfos.IndexOf(thenNodeInfo); int slot = NodeInfo.PreserveFreeSlot(nodeInfos, i, thenNodeIndex); double lineWidth = NODE_WIDTH + slot * LINE_GAP_WIDTH; thenNodeInfo.RightIncomingCount = thenNodeInfo.RightIncomingCount + 1; CondShape condShape = new CondShape(); Point point1 = new Point(branchShape.CenterX, branchShape.Y + branchShape.Height + offsetY); Point point2 = new Point(point1.X, point1.Y + LINE_GAP_HEIGHT); Point point3 = new Point(point2.X + lineWidth, point2.Y); //縦線の始まり thenNodeInfo.RightIncomingIndex += 1; double targetY = thenNodeInfo.Y + thenNodeInfo.RightIncomingIndex * (NODE_HEIGHT / 2.0); Point point4 = new Point(point3.X, targetY); //縦線の終了 Point point5 = new Point(thenNodeInfo.X + thenNodeInfo.Width, point4.Y); condShape.Points.Add(point1); condShape.Points.Add(point2); condShape.Points.Add(point3); condShape.Points.Add(point4); condShape.Points.Add(point5); condShape.Text = condInfo.Code; branchShape.CondShapes.Add(condShape); offsetY += LINE_GAP_HEIGHT; } } shape.AppendTo(canvas); if (!nodeInfo.IsNodeTypeBranch && i != nodeInfos.Count - 1) { //ノード間の矢印。ただし一つ前が分岐の場合は分岐自体で描画するので不要。 NodeInfo nextNodeInfo = nodeInfos[i + 1]; ArrowShape arrowShape = new ArrowShape(); arrowShape.X1 = nodeInfo.CenterX; arrowShape.Y1 = nodeInfo.Y + nodeInfo.Height; arrowShape.X2 = nodeInfo.CenterX; arrowShape.Y2 = nextNodeInfo.Y; arrowShape.AppendTo(canvas); } } }
private void CreateShapes(List<NodeInfo> nodeInfos) { for (int i = 0; i < nodeInfos.Count; i++) { NodeInfo nodeInfo = nodeInfos[i]; ChartShape shape = null; if (nodeInfo.IsNodeTypeQuestion) { QuestionConstructVM questionConstruct = (QuestionConstructVM)nodeInfo.Construct; QuestionShape questionShape = new QuestionShape(); questionShape.X = nodeInfo.X; questionShape.Y = nodeInfo.Y; questionShape.Width = nodeInfo.Width; questionShape.Height = nodeInfo.Height; questionShape.ToolTip = questionConstruct.Title; questionShape.Text = questionConstruct.No; shape = questionShape; } else if (nodeInfo.IsNodeTypeQuestionGroup) { QuestionGroupConstructVM questionGroupConstruct = (QuestionGroupConstructVM)nodeInfo.Construct; QuestionGroupShape questionGroupShape = new QuestionGroupShape(); questionGroupShape.X = nodeInfo.X; questionGroupShape.Y = nodeInfo.Y; questionGroupShape.Width = nodeInfo.Width; questionGroupShape.Height = nodeInfo.Height; questionGroupShape.ToolTip = questionGroupConstruct.Title; questionGroupShape.Text = questionGroupConstruct.No; shape = questionGroupShape; } else if (nodeInfo.IsNodeTypeStatement) { StatementVM statement = (StatementVM)nodeInfo.Construct; StatementShape statementShape = new StatementShape(); statementShape.X = nodeInfo.X; statementShape.Y = nodeInfo.Y; statementShape.Width = nodeInfo.Width; statementShape.Height = nodeInfo.Height; statementShape.ToolTip = statement.Text; statementShape.Text = statement.No; shape = statementShape; } else if (nodeInfo.IsNodeTypeBranch) { IfThenElseVM ifThenElse = (IfThenElseVM)nodeInfo.Construct; BranchShape branchShape = new BranchShape(ifThenElse, BranchClicked); branchShape.X = nodeInfo.X; branchShape.Y = nodeInfo.Y; branchShape.Width = nodeInfo.Width; branchShape.Height = nodeInfo.ContainerHeight; branchShape.ToolTip = ifThenElse.Title; shape = branchShape; //条件 List<CondInfo> condInfos = nodeInfo.CondInfos; double offsetY = 0; foreach (CondInfo condInfo in condInfos) { NodeInfo thenNodeInfo = NodeInfo.Find(nodeInfos, condInfo.TargetConstructId); int thenNodeIndex = nodeInfos.IndexOf(thenNodeInfo); int slot = NodeInfo.PreserveFreeSlot(nodeInfos, i, thenNodeIndex); double lineWidth = NODE_WIDTH + slot * LINE_GAP_WIDTH; thenNodeInfo.RightIncomingCount = thenNodeInfo.RightIncomingCount + 1; CondShape condShape = new CondShape(); Point point1 = new Point(branchShape.CenterX, branchShape.Y + branchShape.Height + offsetY); Point point2 = new Point(point1.X, point1.Y + LINE_GAP_HEIGHT); Point point3 = new Point(point2.X + lineWidth, point2.Y); //縦線の始まり thenNodeInfo.RightIncomingIndex += 1; double targetY = thenNodeInfo.Y + thenNodeInfo.RightIncomingIndex * (NODE_HEIGHT / 2.0); Point point4 = new Point(point3.X, targetY); //縦線の終了 Point point5 = new Point(thenNodeInfo.X + thenNodeInfo.Width, point4.Y); condShape.Points.Add(point1); condShape.Points.Add(point2); condShape.Points.Add(point3); condShape.Points.Add(point4); condShape.Points.Add(point5); condShape.Text = condInfo.Code; branchShape.CondShapes.Add(condShape); offsetY += LINE_GAP_HEIGHT; } } shape.AppendTo(canvas); if (!nodeInfo.IsNodeTypeBranch && i != nodeInfos.Count - 1) { //ノード間の矢印。ただし一つ前が分岐の場合は分岐自体で描画するので不要。 NodeInfo nextNodeInfo = nodeInfos[i + 1]; ArrowShape arrowShape = new ArrowShape(); arrowShape.X1 = nodeInfo.CenterX; arrowShape.Y1 = nodeInfo.Y + nodeInfo.Height; arrowShape.X2 = nodeInfo.CenterX; arrowShape.Y2 = nextNodeInfo.Y; arrowShape.AppendTo(canvas); } } }