Ejemplo n.º 1
0
        public NodeMapConstellation(
            Model.Constellation model_,
            Model.ConstellationPreset preset_,
            List <Data.Skill.Skill> filtererSkills_,
            Model.HoveredSkill hovered_)
        {
            Debug.Assert(model_ != null);
            Debug.Assert(preset_ != null);
            Debug.Assert(hovered_ != null);

            model   = model_;
            preset  = preset_;
            hovered = hovered_;

            scaleModel["scale"] = 1.0;
            abilityMaterial     = App.Resource.Material.AbilityMaterial;
            classMaterial       = App.Resource.Material.ClassMaterial;
            kitMaterial         = App.Resource.Material.KitMaterial;

            foreach (var skill in filtererSkills_)
            {
                switch (skill.Category)
                {
                case Data.Skill.Skill.ECategory.Ability:
                    filteredAbilityList.Add(skill);
                    break;

                case Data.Skill.Skill.ECategory.Class:
                    filteredClassList.Add(skill);
                    break;

                case Data.Skill.Skill.ECategory.Kit:
                    filteredKitList.Add(skill);
                    break;

                default:
                    Debug.Log("NodeMapPreset() weird filter given");
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <List <Model.Constellation> > GetConstellationsWithStars(CancellationToken token)
        {
            var starList       = new List <Star>();
            var constellations = new List <Model.Constellation>();

            try {
                using (var context = new NINADbContext(connectionString)) {
                    var starlist = await context.ConstellationStarSet.ToListAsync(token);

                    starList = starlist.Select(x => new Star(x.id, x.name, new Coordinates(x.ra, x.dec, Epoch.J2000, Coordinates.RAType.Degrees), x.mag)).ToList();

                    var rows = await context.ConstellationSet.OrderBy(x => x.constellationid).ToListAsync(token);

                    foreach (var row in rows)
                    {
                        var constId       = row.constellationid;
                        var constellation = constellations.SingleOrDefault(c => c.Id == constId);
                        if (constellation == null)
                        {
                            constellation = new Model.Constellation(constId);
                            constellations.Add(constellation);
                        }
                        Star star1 = starList.First(s => s.Id == row.starid);
                        Star star2 = starList.First(s => s.Id == row.followstarid);

                        constellation.StarConnections.Add(new Tuple <Star, Star>(star1, star2));
                    }

                    // make a list of unique stars
                    foreach (var constellation in constellations)
                    {
                        constellation.Stars = new List <Star>(
                            constellation.StarConnections
                            .Select(t => t.Item1)
                            .Concat(constellation.StarConnections.Select(t => t.Item2))
                            .GroupBy(b => b.Name)
                            .Select(b => b.First())
                            .ToList()
                            );
                        bool goesOver0 = false;
                        foreach (var pair in constellation.StarConnections)
                        {
                            goesOver0 = Math.Max(pair.Item1.Coords.RADegrees, pair.Item2.Coords.RADegrees) -
                                        Math.Min(pair.Item1.Coords.RADegrees, pair.Item2.Coords.RADegrees) > 180;
                            if (goesOver0)
                            {
                                break;
                            }
                        }

                        constellation.GoesOverRaZero = goesOver0;
                    }
                }
            } catch (OperationCanceledException) {
            } catch (Exception ex) {
                if (!ex.Message.Contains("Execution was aborted by the user"))
                {
                    Logger.Error(ex);
                    Notification.ShowError(ex.Message);
                }
            }

            return(constellations);
        }