示例#1
0
        protected void AddGeographiesForCountriesWithoutBooksRead(Model3DGroup modelGroup)
        {
            // If no country geographies stop.
            if (GeographyProvider.CountryGeographies == null || GeographyProvider.CountryGeographies.Count <= 0)
            {
                return;
            }

            List <string> authorCountries = BooksReadProvider.AuthorCountries.Select(x => x.Country).ToList();

            foreach (CountryGeography geography in GeographyProvider.CountryGeographies)
            {
                if (geography == null)
                {
                    continue;
                }

                if (!authorCountries.Contains(geography.Name))
                {
                    GeometryModel3D geographyGeometry =
                        DiagramUtilities.GetGeographyPlaneGeometry(geography, Colors.LightGray);
                    modelGroup.Children.Add(geographyGeometry);
                }
            }
        }
        private void AddCountryPagesSpiral(Model3DGroup modelGroup, List <Color> colors, AuthorCountry authorCountry,
                                           string name, WorldCountry country)
        {
            int pagesCount = (int)authorCountry.TotalPagesReadFromCountry;

            int    pagesLookup = (int)_countryToLogPagesLookUp[authorCountry.Country];
            uint   maxPages    = _countryToLogPagesLookUp.Values.OrderByDescending(x => x).FirstOrDefault();
            double height      = (12.0 * pagesLookup) / maxPages;

            if (height < 1.0)
            {
                height = 1.0;
            }

            GeometryModel3D countryGeometry =
                DiagramUtilities.GetCountryHelixArrowGeometry(country.Latitude, country.Longitude, height, colors[pagesLookup]);

            modelGroup.Children.Add(countryGeometry);

            string label =
                $"{name}\nLat/Long ( {country.Latitude:0.###} ,{country.Longitude:0.###} ) \nTotal Pages {pagesCount}";

            TextVisual3D countryText =
                DiagramUtilities.GetCountryText(country.Latitude, country.Longitude, pagesCount, label, height);

            modelGroup.Children.Add(countryText.Content);
        }
        private int AddNationsCountryGeographyPlane(Model3DGroup modelGroup, List <Color> stdColors, int geographyIndex, string name)
        {
            var nation = GeographyProvider.Nations.FirstOrDefault(g => g.Name == name);
            CountryGeography geography = nation?.Geography;

            if (geography != null)
            {
                var             colour            = stdColors[(geographyIndex % stdColors.Count)];
                GeometryModel3D geographyGeometry =
                    DiagramUtilities.GetGeographyPlaneGeometry(geography, colour, 0.4);
                modelGroup.Children.Add(geographyGeometry);
                geographyIndex++;
            }

            return(geographyIndex);
        }
 private void AddGeographiesForNationsWithoutBooksRead(Model3DGroup modelGroup)
 {
     if (GeographyProvider.Nations != null && GeographyProvider.Nations.Count > 0)
     {
         List <string> authorCountries = BooksReadProvider.AuthorCountries.Select(x => x.Country).ToList();
         foreach (Nation nation in GeographyProvider.Nations)
         {
             CountryGeography geography = nation.Geography;
             if (geography != null && !authorCountries.Contains(geography.Name))
             {
                 GeometryModel3D geographyGeometry =
                     DiagramUtilities.GetGeographyPlaneGeometry(geography, Colors.LightGray);
                 modelGroup.Children.Add(geographyGeometry);
             }
         }
     }
 }
        public override void SetupModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries

            // set up lookups of the countries with numbers read
            int maxBooksPages;
            int maxBooksLogPages;
            Dictionary <string, long> countryToReadLookUp;
            Dictionary <string, uint> countryToPagesLookUp;
            Dictionary <string, uint> countryToLogPagesLookUp;

            SetupCountyPagesLookups(out maxBooksPages, out maxBooksLogPages,
                                    out countryToReadLookUp, out countryToPagesLookUp, out countryToLogPagesLookUp);
            _countryToLogPagesLookUp = countryToLogPagesLookUp;

            // set up a palette based on this
            uint         numColours = 1 + countryToLogPagesLookUp.Values.OrderByDescending(x => x).FirstOrDefault();
            List <Color> colors;

            ColorUtilities.SetupFaintPaletteForRange((int)numColours, out colors, 128);
            List <Color> stdColors = ColorUtilities.SetupStandardColourSet();

            int geographyIndex = 0;

            foreach (AuthorCountry authorCountry in BooksReadProvider.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                var name    = authorCountry.Country;
                var country = GeographyProvider.Nations.FirstOrDefault(w => w.Name == name);
                if (country != null)
                {
                    DiagramUtilities.AddNationPagesPins(modelGroup, colors, authorCountry, name, country, _countryToLogPagesLookUp);
                }

                if (GeographyProvider.Nations != null && GeographyProvider.Nations.Count > 0)
                {
                    geographyIndex = AddNationsCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForNationsWithoutBooksRead(modelGroup);

            PagesReadByCountryModel = modelGroup;
        }
        public override void SetupModel()
        {
            Model3DGroup modelGroup = new Model3DGroup();

            // get the range of colours for the for the countries
            int range = BooksReadProvider.AuthorCountries.Count > 0 ?
                        BooksReadProvider.AuthorCountries.Select(s => s.TotalBooksReadFromCountry).Max() : 5;
            List <Color> colors;

            ColorUtilities.SetupFaintPaletteForRange(range, out colors, 128);
            List <Color> stdColors = ColorUtilities.SetupStandardColourSet();

            int geographyIndex = 0;

            foreach (AuthorCountry authorCountry in BooksReadProvider.AuthorCountries.OrderByDescending(x => x.TotalBooksReadFromCountry))
            {
                string       name    = authorCountry.Country;
                WorldCountry country = GeographyProvider.WorldCountries.FirstOrDefault(w => w.Country == name);
                if (country != null)
                {
                    DiagramUtilities.AddCountryBooksEllipsoid(modelGroup, colors, authorCountry, name, country);
                }

                if (GeographyProvider.CountryGeographies != null && GeographyProvider.CountryGeographies.Count > 0)
                {
                    geographyIndex = AddCountryGeographyPlane(modelGroup, stdColors, geographyIndex, name);
                }
            }

            AddGeographiesForCountriesWithoutBooksRead(modelGroup);

            double       maxHeight = Math.Log(range);
            TubeVisual3D path      = GetPathForMeanReadingLocation(maxHeight);

            modelGroup.Children.Add(path.Content);

            BooksReadByCountryModel = modelGroup;
        }
示例#7
0
        protected int AddCountryGeographyPlane(Model3DGroup modelGroup, List <Color> stdColors, int geographyIndex, string name)
        {
            CountryGeography geography = null;

            foreach (CountryGeography countryGeography in GeographyProvider.CountryGeographies)
            {
                if (countryGeography != null && countryGeography.Name == name)
                {
                    geography = countryGeography;
                    break;
                }
            }

            if (geography != null)
            {
                Color           colour            = stdColors[(geographyIndex % stdColors.Count)];
                GeometryModel3D geographyGeometry =
                    DiagramUtilities.GetGeographyPlaneGeometry(geography, colour, 0.4);
                modelGroup.Children.Add(geographyGeometry);
                geographyIndex++;
            }

            return(geographyIndex);
        }