public static BoundingRectangle GetBoundsFromPath(List<PathInfo> list)
        {
            // Only support simple paths
            if (list.First().segmentType != SegmentType.Move)
            {
                return null;
            }
            if (list.Last().segmentType != SegmentType.Close)
            {
                return null;
            }
            if (list.Skip(1).Take(list.Count - 2).Any(p => p.segmentType != SegmentType.Line))
            {
                return null;
            }

            BoundingRectangle ret = new BoundingRectangle();
            foreach (var i in list.Take(list.Count - 1))
            {
                ret.UpdateBounds(i.point);
            }

            return ret;
        }
Example #2
0
        public void SetViewForMap(BoundingRectangle buildingBounds, double overlayActualWidth, double overlayActualHeight)
        {
            // NOTE: Do *not* reorder the transformation calls.
            // Transforms are non-abelian.
            ViewTransform.CenterX = overlayActualWidth / 2;
            ViewTransform.CenterY = overlayActualHeight / 2;
            SetBaseRotation();
            this.SetTranslation(overlayActualWidth / 2, overlayActualHeight / 2);

            // After centering, then can do the scaling.
            double sizeOfMapOnScreen = Math.Sqrt(
                buildingBounds.Width * buildingBounds.Width +
                buildingBounds.Height * buildingBounds.Height)
                * ViewChildrenTransform.Scale;
            double minViewSize = Math.Min(overlayActualHeight, overlayActualWidth);
            if (minViewSize != 0)
            {
                AddScale(minViewSize / sizeOfMapOnScreen);
            }

            Canvas.SetLeft(this.viewBackground, -mapSize / 2);
            Canvas.SetTop(this.viewBackground, -mapSize / 2);
        }