ContinentShape.cs
上传用户:huazai0421
上传日期:2008-05-30
资源大小:405k
文件大小:3k
源码类别:

SilverLight

开发平台:

C#

  1. // Silver.Globe, version 0.11 for Silverlight 1.1 Alpha
  2. // Copyright © Florian Krüsch (xaml-kru.com)
  3. // xaml-kru.com/silverglobe
  4. // This source is subject to the Microsoft Public License (Ms-PL).
  5. // See http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx.
  6. // All other rights reserved.
  7. using System;
  8. using System.Windows;
  9. using System.Windows.Media;
  10. using System.Collections.Generic;
  11. using SilverGlobe.Math3D;
  12. using System.Collections.ObjectModel;
  13. namespace SilverGlobe.Data
  14. {
  15.     /// <summary>
  16.     /// A continent and it's shapes on the globe.
  17.     /// </summary>
  18.     public class ContinentShape
  19.     {
  20.         private String _name;
  21.         private List<Point3D[]> _shapes;        
  22.         public String Name
  23.         {
  24.             get { return _name; }
  25.         }
  26.         public ReadOnlyCollection<Point3D[]> Shapes
  27.         {
  28.             get { return _shapes.AsReadOnly(); } 
  29.         }
  30.         public ContinentShape(String name, IEnumerable<Point3D[]> shapes)
  31.         {
  32.             if (name == null)
  33.                 throw new ArgumentNullException("name");
  34.             if (shapes == null)
  35.                 throw new ArgumentNullException("shapes");
  36.             _name = name;
  37.             _shapes = new List<Point3D[]>(shapes);
  38.         }
  39.     }
  40.     /// <summary>
  41.     /// Static class that contains all shapes of all continents.
  42.     /// </summary>
  43.     public static class ContinentShapes
  44.     {
  45.         public static readonly ContinentShape Africa;
  46.         public static readonly ContinentShape America;
  47.         public static readonly ContinentShape Antarctica;
  48.         public static readonly ContinentShape Australia;
  49.         public static readonly ContinentShape Eurasia;
  50.         static ContinentShapes()
  51.         {
  52.             Africa = new ContinentShape("Africa", new Point3D[][]
  53.             {
  54.                 Coordinates.Africa.ToSphere(),
  55.                 Coordinates.Madagascar.ToSphere(),
  56.             });
  57.             America = new ContinentShape("America", new Point3D[][]
  58.             {
  59.                Coordinates.Northamerica.ToSphere(),
  60.                Coordinates.Middleamerica.ToSphere(),
  61.                Coordinates.Southamerica.ToSphere(),
  62.                Coordinates.Caribean.ToSphere(),
  63.                Coordinates.NorthCanada.ToSphere(),
  64.             });
  65.             Antarctica = new ContinentShape("Antarctica", new Point3D[][]
  66.             {
  67.                 Coordinates.Antarctica.ToSphere(),
  68.             });
  69.             Australia = new ContinentShape("Australia", new Point3D[][]
  70.             {
  71.                 Coordinates.Australia.ToSphere(),
  72.                 Coordinates.Tasmania.ToSphere(),
  73.                 Coordinates.NewZealand.ToSphere(),
  74.                 Coordinates.NewGuinea.ToSphere(),
  75.             });
  76.             Eurasia = new ContinentShape("Eurasia", new Point3D[][]
  77.             {
  78.                 Coordinates.Greenland.ToSphere(),
  79.                 Coordinates.ContinentalEurope.ToSphere(),
  80.                 Coordinates.England.ToSphere(),
  81.                 Coordinates.Ireland.ToSphere(),
  82.                 Coordinates.Mediteranean.ToSphere(),
  83.                 Coordinates.ContinentalAsia.ToSphere(),
  84.                 Coordinates.Indonesia1.ToSphere(),
  85.                 Coordinates.Indonesia2.ToSphere(),
  86.                 Coordinates.Taiwan.ToSphere(),
  87.                 Coordinates.SriLanka.ToSphere(),
  88.             });            
  89.         }
  90.     }
  91. }