/// <summary> /// Update or Bind to the UI /// </summary> private void UpdateStatus() { // Clear existing report text richTextBoxSolverReport.Clear(); if (controller != null && controller.Strategy != null && controller.StaticAnalysis != null) { // Draw the graphs PlotGraphs(); // Show debug text richTextBoxSolverReport.Text = controller.DebugReport.ToString(new DebugReportFormatter()); // Static bitmaps if (!bitmapViewerStatic.HasLayers) { SokobanMap build = BuildCurrentMap(controller.Strategy.EvaluationTree.Root.Data); BitmapViewer.Layer mapLayer = new BitmapViewer.Layer(); mapLayer.Order = 0; mapLayer.Map = build; mapLayer.Name = "Puzzle"; bitmapViewerStatic.SetLayer(mapLayer); mapLayer.IsVisible = true; bitmapViewerStatic.SetLayer(controller.StaticAnalysis.WallMap, new SolidBrush(Color.FromArgb(120, Color.Gray))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.FloorMap, new SolidBrush(Color.FromArgb(120, Color.Green))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.InitialCrateMap, new SolidBrush(Color.FromArgb(120, Color.Blue))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.DeadMap, new SolidBrush(Color.FromArgb(120, Color.Brown))).IsVisible = true; bitmapViewerStatic.SetLayer(controller.StaticAnalysis.BoundryMap, new SolidBrush(Color.FromArgb(120, Color.LightGray))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.GoalMap, new SolidBrush(Color.FromArgb(120, Color.Yellow))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.CornerMap, new SolidBrush(Color.FromArgb(120, Color.Pink))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.RecessMap, new SolidBrush(Color.FromArgb(120, Color.Cyan))); bitmapViewerStatic.SetLayer(controller.StaticAnalysis.RoomAnalysis.DoorBitmap, new SolidBrush(Color.FromArgb(120, Color.Khaki))); foreach (Room room in controller.StaticAnalysis.RoomAnalysis.Rooms) { bitmapViewerStatic.SetLayer(room, new SolidBrush(Color.FromArgb(120, Color.LightCyan))); } BitmapViewer.Layer weightLayer = new BitmapViewer.Layer(); weightLayer.Order = 10; weightLayer.Matrix = controller.StaticAnalysis.StaticForwardCrateWeighting; weightLayer.Name = "Weightings"; weightLayer.Brush = new SolidBrush(Color.FromArgb(200, Color.Pink)); weightLayer.BrushAlt = new SolidBrush(Color.FromArgb(200, Color.Red)); weightLayer.Font = new Font("Arial Narrow", 7f); bitmapViewerStatic.SetLayer(weightLayer); bitmapViewerStatic.Render(); } // Forward Tree if (controller.Strategy.EvaluationTree != null) { treeViewer.Init(controller); treeViewer.Controller = controller; treeViewer.Render(); } // Reverse Tree if (controller.ReverseStrategy != null && controller.ReverseStrategy.EvaluationTree != null) { TreeVisualisation tresVisRev = new TreeVisualisation(controller.ReverseStrategy.EvaluationTree, new RectangleInt(0, 0, 1800, 1800), new SizeInt(8, 8)); tresVisRev.Controller = controller; visualisationContainerReverseTree.Visualisation = tresVisRev; visualisationContainerReverseTree.Render(); } // Stats SolverLabelList txt = controller.Stats.GetDisplayData(); if (txt != null) { ReportXHTML reportCurrent = new ReportXHTML("Node Details"); reportCurrent.SetCSSInline(FileManager.GetContent("$html\\style.css")); reportCurrent.Add(txt.ToHTML()); htmlViewStats.SetHTML(reportCurrent.ToString()); } UpdateEvalList(); } }
/// <summary> /// Select a SPECIFIC node and display its details /// </summary> /// <param name="solverNode"></param> private void BindNode(SolverNode solverNode) { if (solverNode == null) return; SokobanMap build = BuildCurrentMap(solverNode); if (build != null) { BitmapViewer.Layer puzzleLayer = new BitmapViewer.Layer(); puzzleLayer.Name = "Puzzle"; puzzleLayer.Map = build; puzzleLayer.Order = 0; puzzleLayer.IsVisible = true; bitmapViewerNodeMaps.SetLayer(puzzleLayer).IsVisible = true; } if (solverNode.MoveMap != null) { SolverBitmap move = new SolverBitmap("MoveMap", solverNode.MoveMap); bitmapViewerNodeMaps.SetLayer(move, new SolidBrush(Color.FromArgb(120, Color.Green))).IsVisible = true; } if (solverNode.DeadMap != null) { bitmapViewerNodeMaps.SetLayer(solverNode.DeadMap, new SolidBrush(Color.FromArgb(120, Color.Black))).IsVisible = true; } // Build details SolverLabelList txt = solverNode.GetDisplayData(); ReportXHTML reportCurrent = new ReportXHTML("Node Details"); reportCurrent.SetCSSInline(FileManager.GetContent("$html\\style.css")); reportCurrent.Add(txt.ToHTML()); if (build != null) { reportCurrent.Add(string.Format("<code><pre>{0}</pre></code>", build.ToString())); } webBrowserNodeCurrent.DocumentText = reportCurrent.ToString(); bitmapViewerNodeMaps.Render(); RootPathVisualisation localVis = new RootPathVisualisation(new SizeInt(16, 16), controller); localVis.RenderCanvas = new RectangleInt(0, 0, visualisationContainerLocalNodes.Width - 30, visualisationContainerLocalNodes.Height - 30); localVis.Init(solverNode); visualisationContainerLocalNodes.ClearImage(); visualisationContainerLocalNodes.Visualisation = localVis; visualisationContainerLocalNodes.Render(); }