private List<NodeInfo> CreateNodeInfos() { // 第一段階として各ノードの位置とサイズを決定する List<NodeInfo> nodeInfos = new List<NodeInfo>(); ObservableCollection<ConstructVM> constructs = viewModel.Constructs; double y = MARGIN_Y; double gap = NODE_GAP; for (int i = 0; i < constructs.Count; i++) { ConstructVM construct = constructs[i]; NodeInfo nodeInfo = null; if (construct as QuestionConstructVM != null) { //質問ノード QuestionConstructVM questionConstruct = (QuestionConstructVM)construct; nodeInfo = new NodeInfo(NodeType.NodeTypeQuestion, questionConstruct); nodeInfo.X = MARGIN_X; nodeInfo.Y = y; nodeInfo.Width = NODE_WIDTH; nodeInfo.Height = NODE_HEIGHT; gap = NODE_GAP; } else if (construct as QuestionGroupConstructVM != null) { QuestionGroupConstructVM questionGroupConstruct = (QuestionGroupConstructVM)construct; nodeInfo = new NodeInfo(NodeType.NodeTypeQuestionGroup, questionGroupConstruct); nodeInfo.X = MARGIN_X; nodeInfo.Y = y; nodeInfo.Width = NODE_WIDTH; nodeInfo.Height = NODE_HEIGHT; gap = NODE_GAP; } else if (construct as StatementVM != null) { //説明文ノード StatementVM statement = (StatementVM)construct; nodeInfo = new NodeInfo(NodeType.NodeTypeStatement, statement); nodeInfo.X = MARGIN_X; nodeInfo.Y = y; nodeInfo.Width = NODE_WIDTH; nodeInfo.Height = NODE_HEIGHT; gap = NODE_GAP; } else if (construct as IfThenElseVM != null) { //分岐ノード(分岐ノードの高さは、矢印部分の最後の水平線の位置を含める) IfThenElseVM ifThenElse = (IfThenElseVM)construct; nodeInfo = new NodeInfo(NodeType.NodeTypeBranch, ifThenElse); nodeInfo.X = MARGIN_X; nodeInfo.Y = y; nodeInfo.Width = NODE_WIDTH; nodeInfo.ContainerHeight = NODE_HEIGHT; //ContainerHeight=菱形の高さ //分岐の考慮 List<CondInfo> condInfos = CondInfo.Create(ifThenElse); nodeInfo.CondInfos.AddRange(condInfos); //分岐シェイプの高さは矢印の水平線の高さを含める(条件の数分水平線がでるのでその分拡張する) nodeInfo.Height = nodeInfo.ContainerHeight + LINE_GAP_HEIGHT * condInfos.Count; gap = LINE_GAP_HEIGHT; } nodeInfos.Add(nodeInfo); y += nodeInfo.Height + gap; } return nodeInfos; }
private bool ShouldResizeNodeInfo(NodeInfo nodeInfo) { if (nodeInfo.IsNodeTypeQuestion || nodeInfo.IsNodeTypeStatement) { if (nodeInfo.RightIncomingCount > 1) { return true; } } return false; }