Beispiel #1
0
 public static void SetCanvasObjectCollectionLayout(string key, ObjectCollectionLayout objectCollectionLayout)
 {
     lock (ObjectCollectionLayoutLock)
     {
         _objectCollectionLayout = objectCollectionLayout;
     }
 }
Beispiel #2
0
        public static void Draw(
            this SKCanvas canvas,
            SKImageInfo info,
            ICollection <CelestialDrawModel> shapes,
            ObjectCollectionLayout objectCollectionLayout)
        {
            if (!shapes.Any())
            {
                return;
            }

            if (shapes.Count == 2)
            {
                var shapeList = shapes.ToList();
                var origin    = shapeList.First();
                var compare   = shapeList.Last();
                canvas.DrawCompare(info, origin, compare);
            }
            else
            {
                var orbits = shapes.Where(x => x.BorderColor.HasValue);

                var drawParameters = GetDrawParameters(info, orbits, objectCollectionLayout);
                canvas.DrawOrbits(shapes.Where(x => x.BorderColor.HasValue), drawParameters);
                canvas.DrawBodies(shapes.Where(x => !x.BorderColor.HasValue), drawParameters);
            }
        }
 public DrawParameterModel(ObjectCollectionLayout objectCollectionLayout, DrawOrientation orientation, int centreX, int centreY, int orbitFactor)
 {
     ObjectCollectionLayout = objectCollectionLayout;
     Orientation            = orientation;
     CentreX     = centreX;
     CentreY     = centreY;
     OrbitFactor = orbitFactor;
 }
Beispiel #4
0
 protected void SetShapes(ICollection <CelestialDrawModel> shapes, ObjectCollectionLayout objectCollectionLayout)
 {
     CanvasSessionHelper.SetCanvasShapes(CanvasViewKey, shapes.ToList());
     CanvasSessionHelper.SetCanvasObjectCollectionLayout(CanvasViewKey, objectCollectionLayout);
     Shapes.SetOnApplicationThread(shapes, _shapesCollectionLock, RaisePropertyChanged, nameof(Shapes), null);
 }
Beispiel #5
0
        private static DrawParameterModel GetDrawParameters(SKImageInfo info, IEnumerable <CelestialDrawModel> orbits, ObjectCollectionLayout objectCollectionLayout)
        {
            var maxCanvasWidth  = info.Width;
            var maxCanvasHeight = info.Height;
            int maxCanvas;
            var maximumOrbitRadius = orbits.Max(x => x.Radius);

            int centreX;
            int centreY;

            var orientation = DrawOrientation.Horizontal;

            if (objectCollectionLayout == ObjectCollectionLayout.Position)
            {
                centreX = (int)Math.Floor(maxCanvasWidth / (double)2);
                centreY = (int)Math.Floor(maxCanvasHeight / (double)2);

                maxCanvas = IntHelper.GetMin(centreX, centreY);
            }
            else
            {
                if (maxCanvasHeight > maxCanvasWidth)
                {
                    orientation = DrawOrientation.Vertical;
                }

                centreX = orientation == DrawOrientation.Horizontal ? 0 : (int)Math.Floor((double)maxCanvasWidth / 2);
                centreY = orientation == DrawOrientation.Vertical ? maxCanvasHeight : (int)Math.Floor((double)maxCanvasHeight / 2);

                maxCanvas = IntHelper.GetMax(maxCanvasWidth, maxCanvasHeight);
            }

            var orbitFactor = (int)Math.Floor((maxCanvas - SunRadius) / maximumOrbitRadius);

            return(new DrawParameterModel(objectCollectionLayout, orientation, centreX, centreY, orbitFactor));
        }