예제 #1
0
 public PolygonMapAreaMV(SelectionMarker selectionMarker, ICountryQuestion question, GeoPolygon polygon, double gloablLeft, double gloablTop, double gloablScale)
     : base(selectionMarker, question, polygon.Bounds, false)
 {
     Points = polygon.Shell
              .Select(c => Tuple.Create((c.X - gloablLeft) * gloablScale, (c.Y - gloablTop) * gloablScale))
              .ToList();
 }
예제 #2
0
        public CircleMapAreaMV(SelectionMarker selectionMarker, ICountryQuestion question, double gloablLeft, double gloablTop, double gloablScale)
            : base(selectionMarker, question, question.Country.Bounds, true)
        {
            var bounds = question.Country.Bounds;

            var width  = (bounds.Right - bounds.Left) * gloablScale;
            var height = (bounds.Bottom - bounds.Top) * gloablScale;

            Size = Math.Sqrt(Math.Pow(width, 2) + Math.Pow(height, 2)) + 40;

            Left = (bounds.Left - gloablLeft) * gloablScale - (Size - width) / 2;
            Top  = (bounds.Top - gloablTop) * gloablScale - (Size - height) / 2;

            question.OnStateChanged += (s, e) => Visible = e.State == QuestionState.Unanswered;
        }
예제 #3
0
        public MapAreaMV(SelectionMarker selectionMarker, ICountryQuestion question, GeoBounds bounds, bool markerOnly)
        {
            _selectionMarker = selectionMarker;
            _question        = question;

            _question.OnStateChanged           += (s, e) => FillState = e.State;
            _selectionMarker.OnSelectedChanged += (s, e) => Selected = e;


            StartGuessCommand = new RelayCommand(() =>
            {
                if (_question.State == QuestionState.Unanswered && !_selectionMarker.Selected)
                {
                    MessengerInstance.Send(new StartCountryGuessNotification(_question, _selectionMarker));
                }
            });

            Fill = new CountryAreaFill(question.Country.LargeFlag, bounds, question.Country.Bounds, markerOnly);

            ZIndex  = question.Country.ZIndex;
            Visible = true;
        }
예제 #4
0
        protected override void HandleNewGame(bool freshStart)
        {
            Answers = null;
            Marker  = null;

            var scale = Game.Questions
                        .Cast <ICountryQuestion>()
                        .Min(o =>
            {
                var imageSize = _imageDataProvider.GetImageSize(o.Country.LargeFlag);

                if (imageSize == null)
                {
                    return(int.MaxValue);
                }

                return(Math.Min(
                           imageSize.Width / (o.Country.Bounds.Right - o.Country.Bounds.Left),
                           imageSize.Height / (o.Country.Bounds.Bottom - o.Country.Bounds.Top)));
            });

            var bounds = Game.Questions
                         .Cast <ICountryQuestion>()
                         .Select(o => o.Country.Bounds);

            var left = bounds
                       .Select(b => b.Left)
                       .Min();

            var right = bounds
                        .Select(b => b.Right)
                        .Max();

            var top = bounds
                      .Select(b => b.Top)
                      .Min();

            var bottom = bounds
                         .Select(b => b.Bottom)
                         .Max();

            var zMax = Game.Questions
                       .Cast <ICountryQuestion>()
                       .Max(o => o.Country.ZIndex) + 1;

            Areas = Game.Questions
                    .Cast <ICountryQuestion>()
                    .SelectMany(o =>
            {
                var selectionMark = new SelectionMarker();

                var areas = o.Country.GeomentryData
                            .Where(g => !g.Ignored)
                            .Select(g => new PolygonMapAreaMV(selectionMark, o, g, left, top, scale) as MapAreaMV);

                if (o.Country.IsSmall)
                {
                    return(Enumerable
                           .Repeat(new CircleMapAreaMV(selectionMark, o, left, top, scale), 1)
                           .Union(areas)
                           .ToList());
                }

                return(areas
                       .ToList());
            })
                    .OrderBy(a => a.ZIndex + (a.Fill.MarkerOnly ? zMax : 0))
                    .ToList();

            Width  = (right - left) * scale;
            Height = (bottom - top) * scale;
        }