Exemple #1
0
        public override void LoadModelData()
        {
            this.DisplayTitle = Model.LayerName;
            this.IsVisable    = Model.IsVisable;

            foreach (var obstacleModel in Model.Obstacles)
            {
                var obstacleVM = new ObstacleViewModel();
                obstacleVM.Model = obstacleModel;
                this.Obstacles.Add(obstacleVM);
            }

            base.LoadModelData();
        }
Exemple #2
0
        public void AddObstacles(Point startingPoint, Point endingPoint, double multiItemDistance)
        {
            var    positionDelta = endingPoint - startingPoint;
            double deltaLength   = positionDelta.Length;

            if (deltaLength < multiItemDistance)
            {
                Obstacles.Add(new ObstacleViewModel()
                {
                    X = startingPoint.X, Y = startingPoint.Y
                });
            }
            else
            {
                double obsRadius = 16;
                int    radCount  = (int)(deltaLength / obsRadius);
                if (radCount % 2 == 1)
                {
                    radCount--;
                }

                int obsCount = (radCount / 2) + 1;

                var multVector     = positionDelta / (obsCount - 1);
                var startingVector = new Vector(startingPoint.X, startingPoint.Y);
                for (int i = 0; i < obsCount; i++)
                {
                    var location         = startingVector + (multVector * i);
                    ObstacleViewModel vm = new ObstacleViewModel()
                    {
                        X = location.X,
                        Y = location.Y
                    };

                    Obstacles.Add(vm);
                }
            }
        }