/// <summary> /// 階層ボタンを初期化する処理。 /// </summary> /// <param name="hierarchyButton"></param> private void SetButons(HierarchyButtonLayout.RootHierarchyButton hierarchyButton) { foreach (var line in firstLines) { var firstButton = new HierarchyButtonLayout.HierarchyTextButton() { Text = line.GetName(), ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; firstButton.AddChildren(LineDataReader.GetStations(line).Select(std => { var stationButton = new HierarchyButtonLayout.HierarchyTextButton() { Text = std.Name, ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; stationButton.Click += StationButton_Click; return(stationButton); })); hierarchyButton.AddChild(firstButton); } var otherButton = new HierarchyButtonLayout.HierarchyTextButton() { Text = "その他の路線", ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; foreach (var othline in otherLines) { var othLineButton = new HierarchyButtonLayout.HierarchyTextButton() { Text = othline.GetName(), ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; othLineButton.AddChildren(LineDataReader.GetStations(othline).Select(std => { var stationButton = new HierarchyButtonLayout.HierarchyTextButton() { Text = std.Name, ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; stationButton.Click += StationButton_Click; return(stationButton); })); otherButton.AddChild(othLineButton); } hierarchyButton.AddChild(otherButton); }
private void CreateButtons(HierarchyButtonLayout.RootHierarchyButton rootHierarchyButton) { var buttons = firstButtons.Select(line => { var button = new HierarchyButtonLayout.HierarchyTextButton() { Text = line.GetName(), ArrowSignDirection = HierarchyButtonLayout.HierarchyTextButton.ArrowSignDirections.Right, }; button.Click += LineButton_Click; return(button); }); rootHierarchyButton.AddChildren(buttons); }