Beispiel #1
0
 public SysInfo1dMap()
 {
     XamlReader.Load(this);
     DataContextChanged += SysInfo1dMap_DataContextChanged;
     _cam           = new Camera2dv2(this);
     _cam.ZoomLevel = 1;
 }
Beispiel #2
0
 public EntityIcon(Entity entity, Camera2dv2 camera)
 {
     _entity          = entity;
     _camera          = camera;
     _starSysPosition = entity.GetDataBlob <PositionDB>();
     foreach (var item in entity.DataBlobs)
     {
         if (item is MassVolumeDB)
         {
             SetIconFor((MassVolumeDB)item);
         }
         if (item is PropulsionDB)
         {
             SetIconFor((PropulsionDB)item);
         }
         if (item is PositionDB)
         {
             SetIconFor((PositionDB)item);
         }
         if (item is StarInfoDB)
         {
             SetIconFor((StarInfoDB)item);
         }
         if (item is SystemBodyInfoDB)
         {
             SetIconFor((SystemBodyInfoDB)item);
         }
         if (item is CargoStorageDB)
         {
             SetIconFor((CargoStorageDB)item);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Initializes the IconCollection
        /// Creates Orbitrings, TextIcons and Entityicons and adds them to Collection
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="camera"></param>
        public void Init(IEnumerable <Entity> entities, Camera2dv2 camera)
        {
            IconDict.Clear();
            OrbitList.Clear();
            TextIconList.Clear();
            EntityList.Clear();
            scale = new ScaleIcon(camera);

            foreach (var item in entities)
            {
                if (item.HasDataBlob <OrbitDB>() && item.GetDataBlob <OrbitDB>().Parent != null)
                {
                    OrbitRing ring = new OrbitRing(item, camera);
                    OrbitList.Add(ring);
                }
                if (item.HasDataBlob <NameDB>())
                {
                    TextIconList.Add(new TextIcon(item, camera));
                }


                EntityIcon entIcon = new EntityIcon(item, camera);
                EntityList.Add(entIcon);


                IconDict.Add(item.Guid, entIcon);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructor of the ScaleIcon Class
 /// </summary>
 /// <param name="camera"></param>
 public ScaleIcon(Camera2dv2 camera)
 {
     _camera      = camera;
     color        = new Color(Colors.White);
     font         = new Font(FontFamilies.Fantasy, Scale);
     pen          = new Pen(color, thickness);
     sizeAndLabel = new KeyValuePair <int, string>(ScaleMinLength, _camera.WorldDistance(ScaleMinLength).ToString() + " au");
 }
 public SystemMap_DrawableView()
 {
     XamlReader.Load(this);
     _camera2         = new Camera2dv2(this);
     this.MouseDown  += SystemMap_DrawableView_MouseDown;
     this.MouseUp    += SystemMap_DrawableView_MouseUp;
     this.MouseWheel += SystemMap_DrawableView_MouseWheel;
     this.MouseMove  += SystemMap_DrawableView_MouseMove;
 }
Beispiel #6
0
 /// <summary>
 /// Constructor for a new Texticon
 /// </summary>
 /// <param name="entity">The Entity that stores the textstring and position</param>
 /// <param name="camera">The Cameraobject where the Texticon is drawn</param>
 public TextIcon(Entity entity, Camera2dv2 camera)
 {
     _camera           = camera;
     worldPosition     = entity.GetDataBlob <PositionDB>();
     name              = entity.GetDataBlob <NameDB>().DefaultName;
     font              = new Font(FontFamilies.Fantasy, Scale);
     color             = new Color(Colors.White);
     DefaultViewOffset = new PointF(8, -font.LineHeight / 2);
 }
Beispiel #7
0
        /// <summary>
        /// Initializes the IconCollection
        /// Creates Orbitrings, TextIcons and Entityicons and adds them to Collection
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="camera"></param>
        public void Init(IEnumerable <Entity> entities, Camera2dv2 camera)
        {
            IconDict.Clear();
            OrbitList.Clear();
            TextIconList.Clear();
            EntityList.Clear();
            _camera = camera;
            Scale   = new ScaleIcon(_camera);

            foreach (var item in entities)
            {
                AddNewIcon(item);
            }
        }
Beispiel #8
0
        public OrbitRing(Entity entityWithOrbit, Camera2dv2 camera)
        {
            _camera = camera;

            _orbitDB          = entityWithOrbit.GetDataBlob <OrbitDB>();
            _parentPositionDB = _orbitDB.Parent.GetDataBlob <PositionDB>();
            _bodyPositionDB   = entityWithOrbit.GetDataBlob <PositionDB>();

            _orbitAngle = (float)(_orbitDB.LongitudeOfAscendingNode + _orbitDB.ArgumentOfPeriapsis * 2); //This is the LoP + AoP.

            //Normalize for 0-360
            _orbitAngle = _orbitAngle % 360;
            if (_orbitAngle < 0)
            {
                _orbitAngle += 360;
            }

            _radianAngle = _orbitAngle * Math.PI / 180;

            _orbitElipseWidth  = (float)_orbitDB.SemiMajorAxis * 2;  //Major Axis
            _orbitElipseHeight = (float)Math.Sqrt((_orbitDB.SemiMajorAxis * _orbitDB.SemiMajorAxis) * (1 - _orbitDB.Eccentricity * _orbitDB.Eccentricity)) * 2;
            _focalDistance     = _orbitDB.Eccentricity * _orbitElipseWidth * 0.5f;
            //_focalDistance = Math.Sqrt((_orbitElipseHeight * _orbitElipseHeight * 0.5) - (_orbitElipseWidth * _orbitElipseWidth * 0.5));
            //since the _focalPoint is only an X component we don't bother calculating the Y part of the matrix
            double focalX = (_focalDistance * Math.Cos(_orbitAngle * Math.PI / 180)); //  - (0 * Math.Sin(_orbitAngle * Math.PI / 180));
            double focalY = (_focalDistance * Math.Sin(_orbitAngle * Math.PI / 180)); // + (0 * Math.Cos(_orbitAngle * Math.PI / 180));

            _focalOffsetPoint = new Vector4(focalX, focalY, 0, 0);

            double eccentX = 0 - (_orbitElipseWidth / _orbitElipseHeight * Math.Sin(_orbitAngle * Math.PI / 180));
            double eccentY = 0 + (_orbitElipseWidth / _orbitElipseHeight * Math.Cos(_orbitAngle * Math.PI / 180));

            _ecentricOffsetPoint = new Vector4(eccentX, eccentY, 0, 0);

            myEntity = entityWithOrbit;
            UpdatePens();
        }