Example #1
0
        /// <summary>
        /// Returns a new copy of the specified map placement entry, with properties updated
        /// to reflect values that will be inherited from the underlying map.
        /// </summary>
        public TrackerMapMetrics GetEffectiveMetrics(TrackerMapPlacement actualPlacement)
        {
            TrackerMap map;

            if (!this.maps.TryGetValue(actualPlacement.name, out map))
            {
                throw new ArgumentException("The specified placement refers to a map that is not defined.");
            }

            var result = new TrackerMapMetrics();

            result.name       = actualPlacement.name;
            result.stateName  = actualPlacement.stateName ?? map.stateName;
            result.x          = actualPlacement.x ?? map.x;
            result.y          = actualPlacement.y ?? map.y;
            result.cellWidth  = actualPlacement.cellWidth ?? map.cellWidth;
            result.cellHeight = actualPlacement.cellHeight ?? map.cellHeight;
            result.gridWidth  = map.gridWidth;
            result.gridHeight = map.gridHeight;

            List <TrackerMarkerSetReference> markers = new List <TrackerMarkerSetReference>();

            markers.AddRange(map.markerSets);
            markers.AddRange(actualPlacement.markerSets);
            result.markerSets = markers.ToArray();

            result.backgrounds = new string[Math.Max(actualPlacement.backgrounds.Length, map.backgrounds.Length)];
            for (var i = 0; i < result.backgrounds.Length; i++)
            {
                result.backgrounds[i] = (i < actualPlacement.backgrounds.Length) ? actualPlacement.backgrounds[i] : map.backgrounds[i];
            }

            return(result);
        }
Example #2
0
            public MapRenderer(LayoutRenderer owner, TrackerMapPlacement mapPlacement)
            {
                this.owner     = owner;
                this.placement = mapPlacement;
                this.map       = owner.trackerDefinition.maps[mapPlacement.name];
                var metrics = owner.trackerDefinition.GetEffectiveMetrics(mapPlacement);

                markerSets.AddRange(map.markerSets);
                markerSets.AddRange(mapPlacement.markerSets);

                x          = placement.x ?? 0;
                y          = placement.y ?? 0;
                cellWidth  = placement.cellWidth ?? 1;
                cellHeight = placement.cellHeight ?? 1;
                gridWidth  = map.gridWidth;
                gridHeight = map.gridHeight;
                StateName  = placement.stateName ?? map.stateName;

                var placementBackgrounds = placement.backgrounds ?? metrics.backgrounds ?? new string[0];

                backgrounds = new Bitmap[placementBackgrounds.Length];
                for (var i = 0; i < placementBackgrounds.Length; i++)
                {
                    backgrounds[i] = owner.trackerDefinition.Meta.GetImage(map.backgrounds[i]);
                }
            }
Example #3
0
 internal void ClearLayout()
 {
     SelectedIndex       = 0;
     _scale              = 1;
     _layoutFile         = null;
     _layoutName         = null;
     _markerSetPlacement = null;
     _mapPlacement       = null;
 }
Example #4
0
        private TrackerPickerPlacement FindPicker(out TrackerMapPlacement mapPlacement, out TrackerMarkerSetReference markerSet)
        {
            markerSet    = null;
            mapPlacement = null;

            foreach (var map in _layout.maps)
            {
                foreach (var marker in map.markerSets)
                {
                    markerSet    = marker;
                    mapPlacement = map;
                    if (marker.picker != null)
                    {
                        return(marker.picker);
                    }
                }
            }

            return(null);
        }