private void DrawRoadWayDelimiterLinesFirstHalf(Pen pen, int linesNumber, int lineWidth) { var width = DrawContext.Width; for (int line = 0; line < linesNumber / 2; line++) { var yKoordinate = lineWidth * (line + 1); DrawContext.DrawLine(pen, 0, yKoordinate, width, yKoordinate); } }
public void InitializeContext() { var halfHeight = DrawContext.Height / 2; var width = DrawContext.Width; DrawContext.SetBackgroundColor(Configuration.BackgroundColor); var pen = new Pen(Configuration.RoadBorderColor, Configuration.RoadBorderWidth); DrawContext.DrawLine(pen, 0, halfHeight, width, halfHeight); DrawRoadWayDelimiterLines(); DrawSmokeCovers(); }
private void DrawSmokeCovers() { var deltaX = DrawContext.Width / Configuration.SmokeCoversNumber; var pen = new Pen(Configuration.SmokeCoverColor, Configuration.RoadwayDelimiterWidth * 4); for (int i = 0; i < Configuration.SmokeCoversNumber; i++) { var x = deltaX * (i + 1) - Configuration.SmokeCoverWidth / 2 - deltaX / 2; DrawContext.DrawLine(pen, x, 0, x + Configuration.SmokeCoverWidth, 0); DrawContext.DrawLine(pen, x, DrawContext.Height, x + Configuration.SmokeCoverWidth, DrawContext.Height); SmokeCoversKoordinates.Add(new Vector(x + Configuration.SmokeCoverWidth / 2, 0)); SmokeCoversKoordinates.Add(new Vector(x + Configuration.SmokeCoverWidth / 2, DrawContext.Height)); } }
/// <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); }