/// <summary> /// レイアウトを描画する関数 /// </summary> /// <param name="layout">レイアウトの情報</param> public void DrawLayout() { double radius = 5; Bitmap = new RenderTargetBitmap( station_.Width, station_.Height, 96, 96, PixelFormats.Default); //これをしないと画像が更新されない image_.Source = Bitmap; DrawContext = DrawVisual.RenderOpen(); //描画するオブジェクトの作成 DrawContext.DrawRectangle(Brushes.White, null, new Rect(0, 0, station_.Width, station_.Height)); //改札の描画 foreach (var kaisatu in station_.Kaisatus) { DrawContext.DrawRectangle( Brushes.Yellow, new Pen(Brushes.Black, 1), new Rect(kaisatu.PositionX, kaisatu.PositionY, kaisatu.Width, kaisatu.Height)); } //駅員室の描画 foreach (var room in station_.Rooms) { DrawContext.DrawRectangle( Brushes.Black, new Pen(Brushes.Black, 1), new Rect(room.PositionX, room.PositionY, room.Width, room.Height)); } //上に線がある階段の描画 foreach (var stairsUp in station_.StairsUp) { ///<summary> ///左の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsUp.PositionX, stairsUp.PositionY), new Point(stairsUp.PositionX, stairsUp.PositionY + stairsUp.Height)); ///<summary> ///右の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsUp.PositionX + stairsUp.Width, stairsUp.PositionY), new Point(stairsUp.PositionX + stairsUp.Width, stairsUp.PositionY + stairsUp.Height)); ///<summary> ///上の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsUp.PositionX, stairsUp.PositionY), new Point(stairsUp.PositionX + stairsUp.Width, stairsUp.PositionY)); } //下に線がある階段の描画 foreach (var stairsDown in station_.StairsDown) { ///<summary> ///左の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsDown.PositionX, stairsDown.PositionY), new Point(stairsDown.PositionX, stairsDown.PositionY + stairsDown.Height)); ///<summary> ///右の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsDown.PositionX + stairsDown.Width, stairsDown.PositionY), new Point(stairsDown.PositionX + stairsDown.Width, stairsDown.PositionY + stairsDown.Height)); ///<summary> ///下の線 /// </summary> DrawContext.DrawLine( new Pen(Brushes.Black, 1), new Point(stairsDown.PositionX, stairsDown.PositionY + stairsDown.Height), new Point(stairsDown.PositionX + stairsDown.Width, stairsDown.PositionY + stairsDown.Height)); } //出口の描画 foreach (var goal in station_.Goals) { DrawContext.DrawRectangle( Brushes.Red, null, new Rect(goal.PositionX, goal.PositionY, goal.Width, goal.Height)); } //ベンチの描画 foreach (var bench in station_.Benchs) { DrawContext.DrawRectangle( Brushes.Red, null, new Rect(bench.PositionX, bench.PositionY, bench.Width, bench.Height)); } //ノードの描画 foreach (var node in nodes_) { DrawContext.DrawEllipse( Brushes.Blue, null, new Point(node.X, node.Y), radius, radius); } //エージェントの描画 foreach (var agent in agents_) { DrawContext.DrawEllipse( null, new Pen(Brushes.Green, 1), new Point(agent.Node.X, agent.Node.Y), agent.Radius, agent.Radius); //経路の線 foreach (var node in agent.RouteNode) { DrawContext.DrawLine( new Pen(Brushes.Red, 10), new Point(node.PreviousNode.X, node.PreviousNode.Y), new Point(node.X, node.Y)); } } //駅員の描画 foreach (var ekiin in ekiin_) { DrawContext.DrawEllipse( null, new Pen(Brushes.Purple, 1), new Point(ekiin.Node.X, ekiin.Node.Y), ekiin.Radius, ekiin.Radius); DrawContext.DrawEllipse( null, new Pen(Brushes.Orange, 1), new Point(ekiin.Node.X, ekiin.Node.Y), 200, 200); } DrawContext.Close(); //表示する画像を更新 Bitmap.Render(DrawVisual); }