Beispiel #1
0
        /// <summary>
        /// Gets distance between two points in pixels
        /// </summary>
        /// <param name="p1">First point</param>
        /// <param name="p2">Second point</param>
        /// <returns>Distance between two points, in pixels</returns>
        public static double DistanceBetweenPoints(this IMapContext map, PointF p1, PointF p2)
        {
            double deltaX = p1.X - p2.X;
            double deltaY = p1.Y - p2.Y;

            return(Math.Sqrt(deltaX * deltaX + deltaY * deltaY));
        }
Beispiel #2
0
        private static PointF[] EdgeCrosspoints(IMapContext map, PointF p1, PointF p2)
        {
            int width  = map.Width;
            int height = map.Height;

            PointF p00 = new PointF(0, 0);
            PointF pW0 = new PointF(width, 0);
            PointF pWH = new PointF(width, height);
            PointF p0H = new PointF(0, height);

            List <PointF?> crossPoints = new List <PointF?>();

            // top edge
            crossPoints.Add(SegmentsIntersection(p1, p2, p00, pW0));

            // right edge
            crossPoints.Add(SegmentsIntersection(p1, p2, pW0, pWH));

            // bottom edge
            crossPoints.Add(SegmentsIntersection(p1, p2, pWH, p0H));

            // left edge
            crossPoints.Add(SegmentsIntersection(p1, p2, p0H, p00));

            return(crossPoints.Where(p => p != null).Cast <PointF>().ToArray());
        }
Beispiel #3
0
        public static float Rotate(this IMapContext map, PointF p, CrdsEquatorial eq, double PA)
        {
            // Point directed to North celestial pole
            PointF pNorth = map.Project((eq + new CrdsEquatorial(0, 1)).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Clockwise rotation
            float inc = LineInclinationY(p, pNorth);

            if (map.IsInverted)
            {
                inc = -90 - inc;
            }

            float rotation = (float)(inc - (map.IsMirrored ? -1 : 1) * PA);

            if (map.IsInverted)
            {
                rotation = 90 - rotation;
            }

            map.Graphics.TranslateTransform(p.X, p.Y);
            map.Graphics.RotateTransform(rotation);

            return(rotation);
        }
 // Ctor : provides Map and mode (combat or not)
 public SubMapProcessor(IMapContext map, bool inFightMap)
 {
     _isInFight = inFightMap;
     _map = map;
     _cells = map.Cells.Select(cell => new CellInfo(cell)).ToArray();
     SubMapsCount = SubMapFiller(inFightMap);
 }
Beispiel #5
0
        public override void Render(IMapContext map)
        {
            brushLabel = new SolidBrush(map.GetColor("ColorSolarSystemLabel"));

            var bodies = planetsCalc.Planets
                         .Where(p => p.Number != Planet.EARTH)
                         .Cast <SolarSystemObject>()
                         .Concat(new[] { sun })
                         .OrderByDescending(body => body.Ecliptical.Distance)
                         .ToArray();

            foreach (var body in bodies)
            {
                if (body is Planet planet)
                {
                    RenderPlanet(map, planet);
                }
                else
                {
                    RenderSun(map);
                }
            }

            RenderMoon(map);

            if (map.Schema == ColorSchema.Day)
            {
                DrawHalo(map);
            }

            RenderEarthShadow(map);
        }
Beispiel #6
0
        /// <summary>
        /// Renders constellation borders on the map
        /// </summary>
        private void RenderBorders(IMapContext map)
        {
            PointF         p1, p2;
            CrdsHorizontal h1, h2;
            var            borders   = constellationsCalc.ConstBorders;
            bool           isGround  = settings.Get <bool>("Ground");
            double         coeff     = map.DiagonalCoefficient();
            Pen            penBorder = new Pen(map.GetColor("ColorConstBorders"));

            foreach (var block in borders)
            {
                for (int i = 0; i < block.Count - 1; i++)
                {
                    h1 = block.ElementAt(i).Horizontal;
                    h2 = block.ElementAt(i + 1).Horizontal;

                    if ((!isGround || h1.Altitude >= 0 || h2.Altitude >= 0) &&
                        Angle.Separation(map.Center, h1) < 90 * coeff &&
                        Angle.Separation(map.Center, h2) < 90 * coeff)
                    {
                        p1 = map.Project(h1);
                        p2 = map.Project(h2);

                        var points = map.SegmentScreenIntersection(p1, p2);
                        if (points.Length == 2)
                        {
                            map.Graphics.DrawLine(penBorder, points[0], points[1]);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        private void DrawFovCircle(IMapContext map, float frameSize, FovFrame frame, bool isOuter)
        {
            float radius = frameSize * 3600 / 2;
            float size   = map.GetDiskSize(radius);

            // do not draw frame if its size exceeds screen bounds
            if (size < Math.Sqrt(map.Width * map.Width + map.Height * map.Height))
            {
                if (isOuter && frame.Shading > 0 && frameSize >= map.ViewAngle / 2)
                {
                    var circle = new GraphicsPath();
                    circle.AddEllipse(map.Width / 2 - size / 2, map.Height / 2 - size / 2, size, size);

                    var shading = new Region(new RectangleF(0, 0, map.Width, map.Height));
                    shading.Exclude(circle);

                    int transparency = (int)(frame.Shading / 100f * 255);
                    var solidBrush   = new SolidBrush(Color.FromArgb(transparency, map.GetSkyColor()));
                    map.Graphics.FillRegion(solidBrush, shading);
                }
                map.Graphics.DrawEllipse(new Pen(frame.Color.GetColor(map.Schema, map.DayLightFactor)), map.Width / 2 - size / 2, map.Height / 2 - size / 2, size, size);

                if (isOuter)
                {
                    float labelWidth = map.Graphics.MeasureString(frame.Label, font).Width;
                    if (labelWidth <= size * 2)
                    {
                        map.Graphics.DrawString(frame.Label, font, new SolidBrush(frame.Color.GetColor(map.Schema, map.DayLightFactor)), new PointF(map.Width / 2, map.Height / 2 + size / 2), format);
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Gets size of a point (small filled circle) representing a star or a planet
        /// or any other celestial object on sky map, depending of its magnitude.
        /// </summary>
        /// <param name="mag">Magnitude of a celestial body</param>
        /// <param name="maxDrawingSize">Maximal allowed drawing diameter, in pixels</param>
        /// <returns>Size (diameter) of a point in screen pixels</returns>
        public static float GetPointSize(this IMapContext map, float mag, float maxDrawingSize = 0)
        {
            // current magnitude limit
            float mag0 = map.MagLimit;

            float size;

            if (mag > mag0)
            {
                size = 0;
            }
            else if (maxDrawingSize != 0)
            {
                size = Math.Min(maxDrawingSize, mag0 - mag);
            }
            else
            {
                size = mag0 - mag;
            }

            if (map.Schema == ColorSchema.Day)
            {
                size *= 1 - map.DayLightFactor;
            }
            else if (map.Schema == ColorSchema.White)
            {
                size *= 2;
            }

            return(size);
        }
Beispiel #9
0
        /// <summary>
        /// Does the rendering logic
        /// </summary>
        /// <param name="map">Map instance</param>
        public override void Render(IMapContext map)
        {
            if (IsMeasureToolOn && map.MousePosition != null)
            {
                double coeff = map.DiagonalCoefficient();

                List <PointF> points = new List <PointF>();
                for (int f = 0; f <= 10; f++)
                {
                    CrdsHorizontal h = Angle.Intermediate(map.MousePosition, MeasureOrigin, f / 10.0);
                    points.Add(map.Project(h));
                    if (Angle.Separation(h, map.Center) > map.ViewAngle * coeff)
                    {
                        break;
                    }
                }

                if (points.Count > 1)
                {
                    map.Graphics.DrawCurve(new Pen(map.GetColor(Color.White)), points.ToArray());
                    double angle = Angle.Separation(map.MousePosition, MeasureOrigin);
                    PointF p     = map.Project(map.MousePosition);
                    map.Graphics.DrawString(Formatters.MeasuredAngle.Format(angle), fontAngleValue, new SolidBrush(map.GetColor(Color.White)), p.X + 5, p.Y + 5);
                }
            }
        }
Beispiel #10
0
 public override void Draw(IMapContext map, ISettings settings, DeepSky ds)
 {
     if (map.ViewAngle <= Renderer.minZoom)
     {
         base.Draw(map, settings, ds);
     }
 }
Beispiel #11
0
        private void DrawLabels(IMapContext map, Track track)
        {
            var    brushLabel = new SolidBrush(track.Color);
            double trackStep  = track.Step;
            double stepLabels = track.LabelsStep.TotalDays;
            double coeff      = map.DiagonalCoefficient();

            int each = (int)(stepLabels / trackStep);

            double jd = track.From;

            for (int i = 0; i < track.Points.Count; i++)
            {
                if (i % each == 0 || i == track.Points.Count - 1)
                {
                    var    tp = track.Points[i];
                    double ad = Angle.Separation(tp.Horizontal, map.Center);
                    if (ad < map.ViewAngle * coeff)
                    {
                        PointF p = map.Project(tp.Horizontal);
                        if (!map.IsOutOfScreen(p))
                        {
                            map.Graphics.FillEllipse(brushLabel, p.X - 2, p.Y - 2, 4, 4);
                            map.DrawObjectCaption(fontLabel, brushLabel, Formatters.DateTime.Format(new Date(jd, map.GeoLocation.UtcOffset)), p, 4);
                        }
                    }
                }

                jd += trackStep;
            }
        }
 // Ctor : provides Map and mode (combat or not)
 public SubMapProcessor(IMapContext map, bool inFightMap)
 {
     _isInFight   = inFightMap;
     _map         = map;
     _cells       = map.Cells.Select(cell => new CellInfo(cell)).ToArray();
     SubMapsCount = SubMapFiller(inFightMap);
 }
Beispiel #13
0
        public override void Render(IMapContext map)
        {
            if (!settings.Get <bool>("DeepSky"))
            {
                return;
            }

            var  allDeepSkies = deepSkyCalc.DeepSkies;
            bool isGround     = settings.Get <bool>("Ground");

            brushCaption = new SolidBrush(map.GetColor("ColorDeepSkyLabel"));

            int alpha = Math.Max(0, Math.Min((int)(k * map.ViewAngle + b), 255));

            Color colorOutline = map.GetColor("ColorDeepSkyOutline");

            penOutlineSolid            = new Pen(Color.FromArgb(alpha, colorOutline));
            penOutlineDashed           = new Pen(Color.FromArgb(alpha, colorOutline));
            penOutlineDashed.DashStyle = DashStyle.Dash;

            var deepSkies = allDeepSkies.Where(ds => !ds.Status.IsEmpty() && Angle.Separation(map.Center, ds.Horizontal) < map.ViewAngle);

            if (isGround)
            {
                deepSkies = deepSkies.Where(ds => ds.Horizontal.Altitude + ds.Semidiameter / 3600 > 0);
            }

            foreach (var ds in deepSkies)
            {
                drawingHandlers[ds.Status].Draw(map, settings, ds);
            }
        }
Beispiel #14
0
        public override void Render(IMapContext map)
        {
            Graphics g         = map.Graphics;
            bool     isGround  = settings.Get <bool>("Ground");
            bool     showNovae = settings.Get("Stars") && settings.Get <bool>("Novae");

            if (!showNovae)
            {
                return;
            }

            var novae = calc.Novae.Where(m => Angle.Separation(map.Center, m.Horizontal) < map.ViewAngle);

            if (isGround)
            {
                novae = novae.Where(m => m.Horizontal.Altitude >= 0);
            }

            var font  = SystemFonts.DefaultFont;
            var brush = new SolidBrush(map.Schema == ColorSchema.White ? Color.Black : Color.White);

            foreach (var star in novae)
            {
                float diam = map.GetPointSize(star.Mag);
                if ((int)diam > 0)
                {
                    PointF p = map.Project(star.Horizontal);
                    if (!map.IsOutOfScreen(p))
                    {
                        if (map.Schema == ColorSchema.White)
                        {
                            g.FillEllipse(Brushes.White, p.X - diam / 2 - 1, p.Y - diam / 2 - 1, diam + 2, diam + 2);
                        }

                        g.FillEllipse(brush, p.X - diam / 2, p.Y - diam / 2, diam, diam);

                        map.AddDrawnObject(star);
                    }
                }
            }

            if (settings.Get <bool>("StarsLabels") && settings.Get <bool>("NovaeLabels") && map.ViewAngle <= limitAllNames)
            {
                brushStarNames = new SolidBrush(map.GetColor("ColorStarsLabels"));

                foreach (var nova in novae)
                {
                    float diam = map.GetPointSize(nova.Mag);
                    if ((int)diam > 0)
                    {
                        PointF p = map.Project(nova.Horizontal);
                        if (!map.IsOutOfScreen(p))
                        {
                            DrawStarName(map, p, nova, diam);
                        }
                    }
                }
            }
        }
Beispiel #15
0
        private void TestBook(IMapContext context, int n)
        {
            var large    = Book.Factory <Book, Genre, Page, Headnote, Footnote>(n, x => (Genre)x);
            var json     = context.ToJson(large);
            var newLarge = context.To <Book>(json);

            AssertBook(large, newLarge);
        }
Beispiel #16
0
        private bool IsSegmentContainsBody(IMapContext map, ICollection <CelestialPoint> segment, Track track)
        {
            int    firstIndex = track.Points.IndexOf(segment.First());
            int    lastIndex  = track.Points.IndexOf(segment.Last());
            double from       = (double)firstIndex / (track.Points.Count - 1) * track.Duration + track.From;
            double to         = (double)lastIndex / (track.Points.Count - 1) * track.Duration + track.From;

            return(map.JulianDay > from && map.JulianDay < to);
        }
Beispiel #17
0
 // Ctor : provides specific cells and mode (combat or not)
 public PathFinder(IMapContext map, IEnumerable<Cell> cells, bool fight)
 {
     _map = map;
     _isInFight = fight;
     _cells = new CellInfo[_map.Cells.Count];
     foreach (Cell cell in cells)
         _cells[cell.Id] = new CellInfo(cell);
     PathPacker = new MapMovement(_cells);
 }
Beispiel #18
0
 public Pathfinder(Map map, IMapContext context, bool throughEntities = true, bool useLogNodeSearch = false)
 {
     m_map             = map;
     m_context         = context;
     m_throughEntities = throughEntities;
     // the dofus client use a bad linear algorithm to find the closest node.
     // if we use an other sort method the result may be different
     m_useLogNodeSearch = useLogNodeSearch;
 }
Beispiel #19
0
        /// <summary>
        /// Build a Path instance from the keys sent by the client
        /// </summary>
        /// <param name="map"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static Path BuildFromClientCompressedPath(IMapContext map, IEnumerable <short> keys)
        {
            IEnumerable <PathElement> path = (from key in keys
                                              let cellId = key& 4095
                                                           let direction = (DirectionsEnum)((key >> 12) & 7)
                                                                           select new PathElement(map.Cells[cellId], direction));

            return(new Path(map, path));
        }
 public MapRepository(IMapContext context)
 {
     this.context = context;
     using (var mysqlContext = new MapMSSQLContext())
     {
         // Creates the database if not exists
         mysqlContext.Database.EnsureCreated();
         mysqlContext.SaveChanges();
     }
 }
Beispiel #21
0
 // Ctor : provides Map and mode (combat or not). Beware, use a Fight context un fight, and a Map out of fights
 public PathFinder(IMapContext map, bool fight)
 {
     Debug.Assert(fight && map is Fight || !fight && map is IMap);
     _isInFight = fight;
     _map = map;
     _cells = new CellInfo[map.Cells.Count];
     for (int i = 0; i < map.Cells.Count; i++)
         _cells[i] = new CellInfo(map.Cells[i]);
     PathPacker = new MapMovement(_cells);
 }
Beispiel #22
0
        /// <summary>
        /// Gets drawing rotation of image, measured clockwise from
        /// a point oriented to top of the screen towards North ecliptic pole point
        /// </summary>
        /// <param name="ecl">Ecliptical coordinates of a central point of a body.</param>
        /// <returns></returns>
        public static float GetRotationTowardsEclipticPole(this IMapContext map, CrdsEcliptical ecl)
        {
            // Coordinates of center of a body (image) to be rotated
            PointF p = map.Project(ecl.ToEquatorial(map.Epsilon).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Point directed to North ecliptic pole
            PointF pNorth = map.Project((ecl + new CrdsEcliptical(0, 1)).ToEquatorial(map.Epsilon).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Clockwise rotation
            return(LineInclinationY(p, pNorth));
        }
Beispiel #23
0
        /// <summary>
        /// Draws nova name
        /// </summary>
        private void DrawStarName(IMapContext map, PointF point, Nova nova, float diam)
        {
            var fontStarNames = settings.Get <Font>("StarsLabelsFont");

            // Star has proper name
            if (map.ViewAngle < limitAllNames && settings.Get <bool>("StarsProperNames") && nova.ProperName != null)
            {
                map.DrawObjectCaption(fontStarNames, brushStarNames, nova.ProperName, point, diam);
                return;
            }
        }
Beispiel #24
0
 // Ctor : provides specific cells and mode (combat or not)
 public PathFinder(IMapContext map, IEnumerable <Cell> cells, bool fight)
 {
     _map       = map;
     _isInFight = fight;
     _cells     = new CellInfo[_map.Cells.Count];
     foreach (Cell cell in cells)
     {
         _cells[cell.Id] = new CellInfo(cell);
     }
     PathPacker = new MapMovement(_cells);
 }
Beispiel #25
0
 public override void Render(IMapContext map)
 {
     if (settings.Get <bool>("ConstBorders"))
     {
         RenderBorders(map);
     }
     if (settings.Get <bool>("ConstLabels"))
     {
         RenderConstLabels(map);
     }
 }
Beispiel #26
0
        /// <summary>
        /// Gets drawing rotation of image, measured clockwise from
        /// a point oriented to top of the screen towards North celestial pole point
        /// </summary>
        /// <param name="eq">Equatorial coordinates of a central point of a body.</param>
        /// <returns></returns>
        public static float GetRotationTowardsNorth(this IMapContext map, CrdsEquatorial eq)
        {
            // Coordinates of center of a body (image) to be rotated
            PointF p = map.Project(eq.ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Point directed to North celestial pole
            PointF pNorth = map.Project((eq + new CrdsEquatorial(0, 1)).ToHorizontal(map.GeoLocation, map.SiderealTime));

            // Clockwise rotation
            return(LineInclinationY(p, pNorth));
        }
Beispiel #27
0
 // Ctor : provides Map and mode (combat or not). Beware, use a Fight context un fight, and a Map out of fights
 public PathFinder(IMapContext map, bool fight)
 {
     Debug.Assert(fight && map is Fight || !fight && map is IMap);
     _isInFight = fight;
     _map       = map;
     _cells     = new CellInfo[map.Cells.Count];
     for (int i = 0; i < map.Cells.Count; i++)
     {
         _cells[i] = new CellInfo(map.Cells[i]);
     }
     PathPacker = new MapMovement(_cells);
 }
Beispiel #28
0
        private Color GetColor(IMapContext map, char spClass)
        {
            if (map.Schema == ColorSchema.White)
            {
                return(Color.Black);
            }

            if (settings.Get("StarsColors"))
            {
                switch (spClass)
                {
                case 'O':
                case 'W':
                    starColor = Color.LightBlue;
                    break;

                case 'B':
                    starColor = Color.LightCyan;
                    break;

                case 'A':
                    starColor = Color.White;
                    break;

                case 'F':
                    starColor = Color.LightYellow;
                    break;

                case 'G':
                    starColor = Color.Yellow;
                    break;

                case 'K':
                    starColor = Color.Orange;
                    break;

                case 'M':
                    starColor = Color.OrangeRed;
                    break;

                default:
                    starColor = Color.White;
                    break;
                }
            }
            else
            {
                starColor = Color.White;
            }

            return(map.GetColor(starColor, Color.Transparent));
        }
Beispiel #29
0
 public static void Rotate(this IMapContext map, PointF p, double angle)
 {
     map.Graphics.TranslateTransform(p.X, p.Y);
     if (map.IsInverted)
     {
         angle = -angle;
     }
     if (map.IsMirrored)
     {
         angle = -angle;
     }
     map.Graphics.RotateTransform((float)angle);
 }
Beispiel #30
0
        private bool MagFilter(IMapContext map, float mag)
        {
            if (mag > map.MagLimit)
            {
                return(false);
            }

            if ((int)map.GetPointSize(mag) == 0)
            {
                return(false);
            }

            return(true);
        }
Beispiel #31
0
        public static void Flip(this IMapContext map)
        {
            var transformMatrix = map.Graphics.Transform;

            if (map.IsMirrored)
            {
                transformMatrix.Multiply(new Matrix(-1, 0, 0, 1, 0, 0));
            }
            if (map.IsInverted)
            {
                transformMatrix.Multiply(new Matrix(1, 0, 0, -1, 0, 0));
            }
            map.Graphics.Transform = transformMatrix;
        }
Beispiel #32
0
        public override void Render(IMapContext map)
        {
            Graphics g          = map.Graphics;
            bool     isGround   = settings.Get <bool>("Ground");
            bool     isLabels   = settings.Get <bool>("StarsLabels");
            Brush    brushNames = new SolidBrush(map.GetColor("ColorStarsLabels"));

            if (map.MagLimit > 8 && settings.Get <bool>("Stars") && settings.Get <bool>("Tycho2"))
            {
                Brush brushStar = GetColor(map);

                PrecessionalElements pe = Precession.ElementsFK5(map.JulianDay, Date.EPOCH_J2000);

                var eq0 = map.Center.ToEquatorial(map.GeoLocation, map.SiderealTime);

                CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, pe);

                SkyContext context = new SkyContext(map.JulianDay, map.GeoLocation);

                tycho2.LockedStar   = map.LockedObject as Tycho2Star;
                tycho2.SelectedStar = map.SelectedObject as Tycho2Star;

                var stars = tycho2.GetStars(context, eq, map.ViewAngle, m => MagFilter(map, m));

                foreach (var star in stars)
                {
                    if (!isGround || star.Horizontal.Altitude > 0)
                    {
                        PointF p = map.Project(star.Horizontal);
                        if (!map.IsOutOfScreen(p))
                        {
                            float size = map.GetPointSize(star.Magnitude);

                            if (map.Schema == ColorSchema.White)
                            {
                                g.FillEllipse(Brushes.White, p.X - size / 2 - 1, p.Y - size / 2 - 1, size + 2, size + 2);
                            }
                            g.FillEllipse(brushStar, p.X - size / 2, p.Y - size / 2, size, size);

                            if (isLabels && map.ViewAngle < 1 && size > 3)
                            {
                                map.DrawObjectCaption(fontNames, brushNames, star.ToString(), p, size);
                            }
                            map.AddDrawnObject(star);
                        }
                    }
                }
            }
        }
Beispiel #33
0
        /// <summary>
        /// Draws star name
        /// </summary>
        private void DrawStarName(IMapContext map, PointF point, Star s, float diam)
        {
            var fontStarNames = settings.Get <Font>("StarsLabelsFont");

            // Star has proper name
            if (map.ViewAngle < limitProperNames && settings.Get <bool>("StarsProperNames") && s.ProperName != null)
            {
                map.DrawObjectCaption(fontStarNames, brushStarNames, s.ProperName, point, diam);
                return;
            }

            // Star has Bayer name (greek letter)
            if (map.ViewAngle < limitBayerNames)
            {
                string bayerName = s.BayerName;
                if (bayerName != null)
                {
                    map.DrawObjectCaption(fontStarNames, brushStarNames, bayerName, point, diam);
                    return;
                }
            }
            // Star has Flamsteed number
            if (map.ViewAngle < limitFlamsteedNames)
            {
                string flamsteedNumber = s.FlamsteedNumber;
                if (flamsteedNumber != null)
                {
                    map.DrawObjectCaption(fontStarNames, brushStarNames, flamsteedNumber, point, diam);
                    return;
                }
            }

            // Star has variable id
            if (map.ViewAngle < limitVarNames && s.VariableName != null)
            {
                string varName = s.VariableName.Split(' ')[0];
                if (!varName.All(char.IsDigit))
                {
                    map.DrawObjectCaption(fontStarNames, brushStarNames, varName, point, diam);
                    return;
                }
            }

            // Star doesn't have any names
            if (map.ViewAngle < 2)
            {
                map.DrawObjectCaption(fontStarNames, brushStarNames, $"HR {s.Number}", point, diam);
            }
        }
Beispiel #34
0
 /// <summary>
 /// Constructs the Path instance from the complete path as a list of cell
 /// </summary>
 /// <param name="map">Current map</param>
 /// <param name="path">Complete path</param>
 public Path(IMapContext map, IEnumerable<Cell> path)
 {
     Map = map;
     m_cellsPath = path.ToArray();
 }
Beispiel #35
0
 /// <summary>
 /// Get an empty path with the current cell
 /// </summary>
 /// <param name="map"></param>
 /// <param name="startCell"></param>
 /// <returns></returns>
 public static Path GetEmptyPath(IMapContext map, Cell startCell)
 {
     return new Path(map, new[] { startCell });
 }
 public ContextActor TryGetSender(IMapContext context)
 {
     return context.Actors.FirstOrDefault(entry => ( entry is INamed && ( entry as INamed ).Name == SenderName ) || entry.Id == SenderId);
 }
Beispiel #37
0
 /// <summary>
 /// Constructs the Path instance from the compressed path as a list of PathElement
 /// </summary>
 /// <param name="map">Current map</param>
 /// <param name="compressedPath">Compressed Path</param>
 private Path(IMapContext map, IEnumerable<PathElement> compressedPath)
 {
     Map = map;
     m_compressedPath = compressedPath.ToArray();
     m_cellsPath = BuildCompletePath();
 }
Beispiel #38
0
        /// <summary>
        /// Build a Path instance from the keys sent by the client
        /// </summary>
        /// <param name="map"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static Path BuildFromClientCompressedPath(IMapContext map, IEnumerable<short> keys)
        {
            IEnumerable<PathElement> path = (from key in keys
                                             let cellId = key & 4095
                                             let direction = (DirectionsEnum)((key >> 12) & 7)
                                             select new PathElement(map.Cells[cellId], direction));

            return new Path(map, path);
        }