public static BorderTextureViewModel GetTextureViewModel(LfDragablePointViewModel myPoint, double angle)
        {
            // Select view model accordingly to angle
            LfStaticPolygonViewModel polygon = (LfStaticPolygonViewModel)myPoint.Parent;

            double degAngle = angle;

            if ((degAngle <= polygon.RightGroundAngle) && (degAngle > polygon.LeftGroundAngle))
            {
                return(polygon.GroundBorder);
            }

            if ((degAngle > polygon.RightGroundAngle) && (degAngle < polygon.RightCeilingAngle))
            {
                return(polygon.RightWallBorder);
            }


            if ((degAngle < polygon.LeftGroundAngle) && (degAngle > polygon.LeftCeilingAngle))
            {
                return(polygon.LeftWallBorder);
            }

            return(polygon.CeilingBorder);
        }
        public static Point GetPreviousPoint(LfDragablePointViewModel myPoint)
        {
            LfStaticPolygonViewModel polygon = (LfStaticPolygonViewModel)myPoint.Parent;

            int i = polygon.PointVms.IndexOf(myPoint);

            if (i == -1)
            {
                return(new Point(0, 0));
            }

            LfDragablePointViewModel previousVertex;

            if (i > 0)
            {
                previousVertex = polygon.PointVms[i - 1];
            }
            else
            {
                previousVertex = polygon.PointVms[polygon.PointVms.Count() - 1];
            }

            Point prevP = new Point(previousVertex.PosX, previousVertex.PosY);

            return(prevP);
        }
        public static double GetAngle(LfDragablePointViewModel myPoint, Point origP, Point prevP)
        {
            LfStaticPolygonViewModel polygon = (LfStaticPolygonViewModel)myPoint.Parent;

            Vector diffV = origP - prevP;

            double angle = Math.Atan2(diffV.Y, diffV.X);

            angle += Math.PI;

            if (angle > Math.PI)
            {
                angle -= Math.PI * 2;
            }

            return(angle / Math.PI * 180);
        }
        private StateShapeCollectionViewModel SetShapes(CompoundObject co, bool enabledChildren = true)
        {
            StateShapeCollectionViewModel shapes = new StateShapeCollectionViewModel(this, this, MainVm, enabledChildren);

            foreach (LfSpriteBox sb in co.SpriteBoxes)
            {
                LfSpriteBoxViewModel shapevm = new LfSpriteBoxViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfSpritePolygon sp in co.SpritePolygons)
            {
                LfSpritePolygonViewModel shapevm = new LfSpritePolygonViewModel(shapes, this, MainVm, sp, enabledChildren);

                foreach (LfDragablePoint dragPoint in sp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticBox sb in co.StaticBoxes)
            {
                LfStaticBoxViewModel shapevm = new LfStaticBoxViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticCircle sb in co.StaticCircles)
            {
                LfStaticCircleViewModel shapevm = new LfStaticCircleViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticPolygon sp in co.StaticPolygons)
            {
                LfStaticPolygonViewModel shapevm = new LfStaticPolygonViewModel(shapes, this, MainVm, sp, enabledChildren);

                foreach (LfDragablePoint dragPoint in sp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicBox db in co.DynamicBoxes)
            {
                LfDynamicBoxViewModel shapevm = new LfDynamicBoxViewModel(shapes, this, MainVm, db, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicCircle db in co.DynamicCircles)
            {
                LfDynamicCircleViewModel shapevm = new LfDynamicCircleViewModel(shapes, this, MainVm, db, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicPolygon dp in co.DynamicPolygons)
            {
                LfDynamicPolygonViewModel shapevm = new LfDynamicPolygonViewModel(shapes, this, MainVm, dp, enabledChildren);

                foreach (LfDragablePoint dragPoint in dp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticBoxedSpritePolygon bsp in co.StaticBoxedSpritePolygons)
            {
                LfStaticBoxedSpritePolygonViewModel shapevm = new LfStaticBoxedSpritePolygonViewModel(shapes, this, MainVm, bsp, enabledChildren);

                foreach (LfDragablePoint dragPoint in bsp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicBoxedSpritePolygon bsp in co.DynamicBoxedSpritePolygons)
            {
                LfDynamicBoxedSpritePolygonViewModel shapevm = new LfDynamicBoxedSpritePolygonViewModel(shapes, this, MainVm, bsp, enabledChildren);

                foreach (LfDragablePoint dragPoint in bsp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            return(shapes);
        }
 public BorderTextureViewModel(LfStaticPolygonViewModel parentVm, BorderTexture modelObject)
 {
     _parentVm    = parentVm;
     _modelObject = modelObject;
 }