private static void AddCountryGeographyToPlot(
            PlotModel newPlot,
            Dictionary <string, int> countryToReadLookUp,
            List <OxyColor> colors,
            Models.Geography.CountryGeography country)
        {
            OxyColor color     = OxyColors.LightGray;
            string   tagString = "";

            if (countryToReadLookUp.ContainsKey(country.Name))
            {
                color     = colors[countryToReadLookUp[country.Name]];
                tagString = "\nBooks Read = " + countryToReadLookUp[country.Name].ToString();
            }

            string trackerFormat = "{0}\nLat/Long ( {4:0.###} ,{2:0.###} )" + tagString;

            OxyPlotUtilities.AddCountryGeographyAreaSeriesToPlot(newPlot, country, color, country.Name, tagString, trackerFormat);
        }
        private PlotModel SetupWorldCountriesMapPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "Countries of the World"
            };

            SetupLatitudeAndLongitudeAxes(newPlot);

            int flagCount = 0;

            foreach (Models.Database.Nation nation in _mainModel.Nations)
            {
                Models.Geography.CountryGeography country = nation.Geography;
                if (country != null)
                {
                    OxyColor colour        = OxyColors.LightGreen;
                    string   title         = country.Name;
                    string   tag           = "";
                    string   trackerFormat = "{0}";
                    OxyPlotUtilities.AddCountryGeographyAreaSeriesToPlot(newPlot, country, colour, title, tag, trackerFormat);
                }

                if (!string.IsNullOrEmpty(nation.ImageUri) && flagCount < 10)
                {
                    Models.Geography.PolygonPoint capitalCity =
                        new Models.Geography.PolygonPoint(nation.Longitude, nation.Latitude);
                    double x, y;
                    capitalCity.GetCoordinates(out x, out y);

                    try
                    {
                        WebRequest req    = WebRequest.Create(nation.ImageUri);
                        Stream     stream = req.GetResponse().GetResponseStream();
                        var        bitmap = new System.Drawing.Bitmap(stream);

                        MemoryStream memoryStream = new MemoryStream();
                        bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp);
                        var asBytes = memoryStream.ToArray();

                        var typeOfImage = GetImageFormat(asBytes);

                        if (typeOfImage == ImageFormat.Unknown)
                        {
                            continue;
                        }

                        OxyImage image = new OxyImage(asBytes);
                        newPlot.Annotations.Add(
                            new ImageAnnotation
                        {
                            ImageSource = image,
                            Opacity     = 0.5,

                            X      = new PlotLength(x, PlotLengthUnit.Data),
                            Y      = new PlotLength(y, PlotLengthUnit.Data),
                            Width  = new PlotLength(30, PlotLengthUnit.ScreenUnits),
                            Height = new PlotLength(20, PlotLengthUnit.ScreenUnits),
                            HorizontalAlignment = HorizontalAlignment.Center,
                            VerticalAlignment   = VerticalAlignment.Middle
                        });


                        //newPlot.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(x, y), Text = nation.Capital });

                        flagCount++;
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }

            // finally update the model with the new plot
            return(newPlot);
        }