private void DistributeTemplateParameters() { AriadneSettingsData data = new AriadneSettingsData(); TemplateMazeUserControl.FillParametersInto(data); data.AutoSeed = false; data.AutoGridWidth = data.AutoPathWidth = false; data.AutoMazeHeight = data.AutoMazeWidth = true; data.AutoColors = false; // The other MazePainters should not have a local ImageLoader. data.LeaveCurrentBackgroundImageLoader = true; data.IsArena = true; for (int i = 0; i < Items.Count; i++) { // The last item may use the shared list of recently used images. if (i == Items.Count - 1) { data.IsArena = false; } ArenaItem item = Items[i]; if (item != TemplateItem) { item.MazeUserControl.MazePainter.BackgroundImageLoader = TemplateItem.MazeUserControl.MazePainter; item.MazeUserControl.TakeParametersFrom(data); item.Setup(false); } } }
/// <summary> /// Create and arrange the desired number of ArenaItems. /// </summary> private void OnLayout() { List <ArenaItem> items = Items; #region Adjust the number of ArenaItems and SolverControllers while (items.Count < nX * nY) { ArenaItem item = new ArenaItem(); this.Controls.Add(item); items.Add(item); ((MultiSolverController)SolverController).Add(item.SolverController); } while (items.Count > nX * nY) { ArenaItem item = items[items.Count - 1]; this.Controls.Remove(item); items.RemoveAt(items.Count - 1); ((MultiSolverController)SolverController).Remove(item.SolverController); } #endregion #region Place the ArenaItems into a regular grid const int dx = 6, dy = 6; for (int x = 0; x < nX; x++) { for (int y = 0; y < nY; y++) { int cw = (this.ClientSize.Width - dx) / nX - dx; int cx = dx + x * (cw + dx); int ch = (this.statusStrip.Location.Y - dx) / nX - dx; int cy = dy + y * (ch + dy); ArenaItem item = items[y * nX + x]; item.Location = new Point(cx, cy); item.Size = new Size(cw, ch); } } #endregion #if false // Note: The maze parameters are still incomplete, so we should not try to update anything. this.UpdateCaption(); this.UpdateStatusLine(); #endif }