Beispiel #1
0
        public void PaintMap(PaintEventArgs e, Graphics g)
        {
            try
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                g.CompositingMode   = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                foreach (var layer in Layers)
                {
                    layer.Draw(g, Transform);
                }

                /*
                 * BaseTree.Draw(g, Transform);
                 *
                 * if (DrawPatchShadows)
                 * {
                 *  if (false)
                 *  {
                 *      foreach (var p in FinishedPatches)
                 *          p.Draw(g, Transform, p.GetShadows(ShadowCaster));
                 *  }
                 *  else
                 *  {
                 *      var window = Bounds;
                 *
                 *      // Matrices are needed for GetShadowsCarefully
                 *      if (FinishedPatches.Count > 0 && FinishedPatches[0].Matrices == null)
                 *          foreach (var p in FinishedPatches)
                 *              p.FillMatrices(TileTreeNode.Terrain);
                 *
                 *      foreach (var p in FinishedPatches)
                 *          if (p.IsVisible(Transform, window))
                 *              p.Draw(g, Transform, p.GetShadowsCarefully(ShadowCaster));
                 *  }
                 * }
                 * else
                 * {
                 *  foreach (var p in FinishedPatches)
                 *  {
                 *      p.Draw(g, Transform, _finishedBrush);
                 *      //p.Draw(g, Transform, _finishedPen);
                 *  }
                 * }
                 *
                 * if (OverlayTree != null)
                 * {
                 *  g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                 *  _colorMatrix.Matrix33 = OverlayTransparency;
                 *  _imageAttributes.SetColorMatrix(_colorMatrix);
                 *
                 *  OverlayTree.Draw(g, Transform, _imageAttributes);
                 *  //var r = new Rectangle((int)destrect.Left, (int)destrect.Top, (int)destrect.Width, (int)destrect.Height);
                 *  //g.DrawImage(bmp, r, 0, 0, Dataset.Description.Width, Dataset.Description.Height, GraphicsUnit.Pixel, _imageAttributes);
                 *
                 *  g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;  // Make sure to return this.  DrawString will fail later if this is left as .SourceCopy
                 *
                 * }
                 *
                 *
                 * foreach (var p in SelectedPatches)
                 * {
                 *  p.Draw(g, Transform, _selectionBrush);
                 *  p.Draw(g, Transform, _selectionPen);
                 * }
                 */

                for (var i = 0; i < ColoredPatches.Count; i++)
                {
                    DrawColoredPatch(g, Transform, ColoredPatches[i]);
                }

                for (var i = 0; i < FarPatches.Count; i++)
                {
                    FarPatches[i].Draw(g, Transform, _redPen);
                }

                for (var i = 0; i < ProcessingPatches.Count; i++)
                {
                    ProcessingPatches[i].Draw(g, Transform, _tileSelectionBrush);
                }

                if (_isHighlightPatchVisible)
                {
                    _highlightPatch.Draw(g, Transform, _highlightBrush);
                }

                if (TraverseSummary != null)
                {
                    DrawTraverseSummary(g, Transform, TraverseSummary);
                }

                // Draw other pickables

                foreach (Pickable p in Pickables())
                {
                    p.Paint(e, this);
                }

                if (MouseMessage != null && MouseMessage.Message != null)
                {
                    g.DrawString(MouseMessage.Message, MouseMessage.Font, MouseMessage.Brush, MouseMessage.X, MouseMessage.Y);
                }

                if (SelectionRectangleIsVisible)
                {
                    DrawSelectionRectangle(g, Transform, SelectionRectangle);
                }

                if (RulerMeasureIsVisible)
                {
                    DrawRulerMeasure(g, Transform, RulerMeasure);
                }

                // Changes clipping region, so do this last, for now
                //DrawLegend(g);
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1);
            }
        }