private void RedrawMap(IEnumerable <SaveFileEntry> Entries)
        {
            Log.Write("{0}: Redrawing the map. Points: {1}", GetType().Name, Points.Count);
            var I = MapRender.RenderEntries(Entries);

            using (var G = Graphics.FromImage(I))
            {
                //Render points
                if (Points.Count > 2)
                {
                    using (var B = new SolidBrush(Color.FromArgb(100, Color.Lime)))
                    {
                        G.FillPolygon(B, Points
                                      .Select(m => new Point((int)(m.X * I.Width), (int)(m.Y * I.Height)))
                                      .ToArray());
                    }
                }
                using (var F = new Font("Arial", 16))
                {
                    G.DrawString($"Number of points: {Points.Count}", F, Brushes.Red, new PointF(0, 0));
                }
            }
            if (pbMap.Image != null)
            {
                pbMap.Image.Dispose();
            }
            pbMap.Image = I;
            Log.Write("{0}: Redrawing complete", GetType().Name);
        }
Example #2
0
        private void RedrawMap(IEnumerable <SaveFileEntry> Entries)
        {
            Log.Write("{0}: Redrawing the map. Points: {1}", GetType().Name, Points.Count);
            Image I = null;

            try
            {
                I = MapRender.RenderEntries(Entries);
            }
            catch (Exception ex)
            {
                Log.Write("{0}: Unable to render image in RedrawMap()", GetType().Name);
                Log.Write(ex);
                Tools.E(@"Unable to render the map image. This is usually the result of memory constraints or a corrupted executable.
It is highly recommended that you verify the application integrity (check if it has a valid signature in the file properties).
You can try to continue using this application but you might see reduced functionality whenever map drawing is involved.", "Item rendering error");
                return;
            }
            using (var G = Graphics.FromImage(I))
            {
                //Render points
                if (Points.Count > 2)
                {
                    using (var B = new SolidBrush(Color.FromArgb(100, Color.Lime)))
                    {
                        G.FillPolygon(B, Points
                                      .Select(m => new Point((int)(m.X * I.Width), (int)(m.Y * I.Height)))
                                      .ToArray());
                    }
                }
                using (var F = new Font("Arial", 16))
                {
                    G.DrawString($"Number of points: {Points.Count}", F, Brushes.Red, new PointF(0, 0));
                }
            }
            if (pbMap.Image != null)
            {
                pbMap.Image.Dispose();
            }
            pbMap.Image = I;
            Log.Write("{0}: Redrawing complete", GetType().Name);
        }