From e59bfce1bed8d566175fa6ab3d10be4959cef62e Mon Sep 17 00:00:00 2001 From: Elias Leinenweber <elias.leinenweber@etu.unistra.fr> Date: Mon, 29 Mar 2021 16:12:22 +0200 Subject: [PATCH] =?UTF-8?q?Pass=C3=A9=20la=20map=20en=20propri=C3=A9t?= =?UTF-8?q?=C3=A9=20du=20contr=C3=B4le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/Controls/MapView.cs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/view/Controls/MapView.cs b/view/Controls/MapView.cs index 71fbd8b..a28db89 100644 --- a/view/Controls/MapView.cs +++ b/view/Controls/MapView.cs @@ -1,4 +1,7 @@ -using System.Windows.Forms; +using System.ComponentModel; +using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; namespace Wanderer.view.Controls { @@ -6,19 +9,27 @@ namespace Wanderer.view.Controls { private TileView[,] tileViews; - public MapView(Map map) + [Category("Model")] + [Browsable(true)] + [Description("La map correspondante.")] + [Editor(typeof(WindowsFormsComponentEditor), typeof(UITypeEditor))] + public Map Model { + set { + ColumnCount = value.Tiles.GetLength(0); + RowCount = value.Tiles.GetLength(1); + + for (int i = 0; i < ColumnCount; ++i) + for (int j = 0; j < RowCount; ++j) + { + tileViews[i, j] = new TileView(value.Tiles[i, j]); + Controls.Add(tileViews[i, j], i, j); + } + } + } + + public MapView() { InitializeComponent(); - - ColumnCount = map.Tiles.GetLength(0); - RowCount = map.Tiles.GetLength(1); - - for (int i = 0; i < ColumnCount; ++i) - for (int j = 0; j < RowCount; ++j) - { - tileViews[i, j] = new TileView(map.Tiles[i, j]); - Controls.Add(tileViews[i, j], i, j); - } } } } \ No newline at end of file -- GitLab