コード例 #1
0
        protected virtual void OnResizingStarted(ResizingDirection direction)
        {
            var selectedPoints = ControlPoints.Where(c => c.IsSelected).ToList();

            foreach (IResizingTarget c in selectedPoints)
            {
                c.OnResizingStarted(direction);
            }
        }
コード例 #2
0
        protected virtual void OnResizingDelta(ResizingDirection direction, double horizontalChange, double verticalChange)
        {
            var selectedPoints = ControlPoints.Where(c => c.IsSelected).ToList();

            foreach (IResizingTarget c in selectedPoints)
            {
                c.OnResizingDelta(direction, horizontalChange, verticalChange);
            }
        }
コード例 #3
0
        private void DetermineControlPointDirections()
        {
            var firstRow = ControlPoints.Where(c => c.V == 0).ToArray();

            var firstCol = ControlPoints.Where(c => c.U == 0).ToArray();

            ControlPoints.ToList().ForEach(c => c.AllowAllDirections());
            firstRow.ToList().ForEach(c => c.ControlPointDirections &= ~ControlPointDirections.Up);
            firstCol.ToList().ForEach(c => c.ControlPointDirections &= ~ControlPointDirections.Left);
            ControlPoints.Where(c => c.V == _resolution.Height - 1).ToList().ForEach(c => c.ControlPointDirections &= ~ControlPointDirections.Down);
            ControlPoints.Where(c => c.U == _resolution.Width - 1).ToList().ForEach(c => c.ControlPointDirections  &= ~ControlPointDirections.Right);
        }
コード例 #4
0
        public void SetPatternType(int size, Size count, int[] xList, bool keepCorners)
        {
            _patternSize  = size;
            _patternCount = count;

            var eckenVorher = ControlPoints.Where(c => c.ControlPointType == ControlPointType.IsEcke).ToArray();

            ControlPoints.Clear();
            BoundingControlPoints.Clear();
            Enumerable.Range(0, count.Width * count.Height).ToList().ForEach(p => ControlPoints.Add(new ControlPoint()));

            var dy = _resolution.Height / (count.Height - 1);
            var y  = 0;

            for (var i = 0; i < ControlPoints.Count; i++)
            {
                if (i > 0 && i % count.Width == 0)
                {
                    y += dy;
                    if (y >= _resolution.Height)
                    {
                        y = _resolution.Height - 1;
                    }
                }
                ControlPoints[i].Y = ControlPoints[i].V = y;
            }

            for (var iy = 0; iy < count.Height; iy++)
            {
                for (var ix = 0; ix < count.Width; ix++)
                {
                    var index = iy * count.Width + ix;
                    ControlPoints[index].X = ControlPoints[index].U = xList[ix];
                }
            }

            BoundingControlPoints.AddRange(ControlPoints.Take(count.Width));
            for (var iy = 1; iy < count.Height; iy++)
            {
                BoundingControlPoints.Add(ControlPoints[iy * count.Width + (count.Width - 1)]);
            }
            for (var ix = 1; ix < count.Width - 1; ix++)
            {
                BoundingControlPoints.Add(ControlPoints[count.Height * count.Width - ix - 1]);
            }
            for (var iy = count.Height - 1; iy > 0; iy--)
            {
                BoundingControlPoints.Add(ControlPoints[iy * count.Width]);
            }

            ControlPoints[0].ControlPointType = ControlPointType.IsEcke;
            ControlPoints[count.Width - 1].ControlPointType = ControlPointType.IsEcke;
            ControlPoints[count.Width * (count.Height - 1)].ControlPointType = ControlPointType.IsEcke;
            ControlPoints[count.Width * count.Height - 1].ControlPointType   = ControlPointType.IsEcke;

            foreach (var cp in BlacklevelControlPoints)
            {
                cp.X = cp.U;
                cp.Y = cp.V;
            }

            if (keepCorners && eckenVorher.Any())
            {
                var ecken = ControlPoints.Where(c => c.ControlPointType == ControlPointType.IsEcke).ToArray();
                for (var i = 0; i < eckenVorher.Length; i++)
                {
                    ecken[i].X = eckenVorher[i].X;
                    ecken[i].Y = eckenVorher[i].Y;
                }
            }
            Interpolate(ControlPoints);

            MakeTriangleStrip();
            DetermineControlPointDirections();
        }