/// <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();
        }
Пример #2
0
        /// <summary>
        /// Select a node in the tree browser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnVisualisationClick_TreeViewer(object sender, VisEventArgs e)
        {
            if (e.Element == null) return;

            SolverNode solverNode = null;

            TreeVisualisationElement element = e.Element as TreeVisualisationElement;
            if (element != null) solverNode = element.Data;

            RootPathElement rele = e.Element as RootPathElement;
            if (rele != null) solverNode = rele.Node;

            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);
            }

            if (solverNode.MoveMap != null)
            {
                SolverBitmap move = new SolverBitmap("MoveMap", solverNode.MoveMap);
                bitmapViewerNodeMaps.SetLayer(move, new SolidBrush(Color.FromArgb(120, Color.Green)));
            }

            if (solverNode.DeadMap != null)
            {
                bitmapViewerNodeMaps.SetLayer(solverNode.DeadMap, new SolidBrush(Color.FromArgb(120, Color.Black)));
            }

            // Build details
            SolverLabelList txt = solverNode.GetDisplayData();

            webBrowserNodeCurrent.DocumentText = txt.ToHTMLDocument();

            bitmapViewerNodeMaps.Render();

            if (sender != visualisationContainerLocalNodes)
            {
                RootPathVisualisation localVis = new RootPathVisualisation(new SizeInt(10, 10), solver);
                localVis.RenderCanvas =
                    new RectangleInt(0, 0, visualisationContainerLocalNodes.Width - 30,
                                     visualisationContainerLocalNodes.Height - 30);
                localVis.Init(solverNode);
                visualisationContainerLocalNodes.ClearImage();
                visualisationContainerLocalNodes.Visualisation = localVis;
                visualisationContainerLocalNodes.Render();
            }
        }