예제 #1
0
        public void InsertPoint(double x, double y, ControlPointType pointType = ControlPointType.Spline)
        {
            var point = new PanoBeamLib.Blend.ControlPoint(x / 200d, y / 200d, Mapper.ConvertControlPointType(pointType));

            _curve.InsertPoint(point);
            AddPointControl(point);
        }
예제 #2
0
 private ControlPoint ConvertPoint(PanoBeamLib.Blend.ControlPoint point, ControlPointFix fix)
 {
     return(new ControlPoint(point.X * _width, point.Y * _height, point, fix)
     {
         PointType = Mapper.ConvertControlPointType(point.PointType)
     });
 }
예제 #3
0
        //private void SetPoints(PointForSave[] points)
        //{
        //    if (points == null) return;
        //    if (points.Length < 2) return;
        //    if (_curveData == null) return;
        //    _curveData.Points.Clear();
        //    for (var i = Canvas1.Children.Count - 1; i >= 0; i--)
        //    {
        //        if (Canvas1.Children[i] is ControlPoint)
        //        {
        //            Canvas1.Children.Remove(Canvas1.Children[i]);
        //        }
        //    }
        //    var point = ConvertPoint(points[0], ControlPointFix.None);
        //    point.Color = Brushes.Orange;
        //    point.PointType = ControlPointType.Line;
        //    point.ValueChanged += PointOnValueChanged;
        //    Canvas1.Children.Add(point);
        //    _curveData.Points.Add(point);
        //    point = ConvertPoint(points[points.Length - 1], ControlPointFix.None);
        //    point.Color = Brushes.Orange;
        //    point.PointType = ControlPointType.Line;
        //    point.ValueChanged += PointOnValueChanged;
        //    Canvas1.Children.Add(point);
        //    _curveData.Points.Add(point);

        //    for (int i = 1; i < points.Length - 1; i++)
        //    {
        //        InsertPoint(points[i].X, points[i].Y, points[i].PointType);
        //    }

        //    RefreshGraph();
        //}

        //public double GetY(double x)
        //{
        //    double y;
        //    var knownSamples = new List<KeyValuePair<double, ControlPoint>>();
        //    foreach (var p in _curveData.Points)
        //    {
        //        if (p.PointType == ControlPointType.Line)
        //        {
        //            if (x <= p.X)
        //            {
        //                knownSamples.Add(new KeyValuePair<double, ControlPoint>(p.X, p));
        //                y = SpLine(knownSamples, x);
        //                if (double.IsInfinity(y))
        //                {
        //                    return 199d;
        //                }
        //                return y;
        //            }
        //            else
        //            {
        //                knownSamples.Clear();
        //                knownSamples.Add(new KeyValuePair<double, ControlPoint>(p.X, p));
        //            }
        //        }
        //        else
        //        {
        //            knownSamples.Add(new KeyValuePair<double, ControlPoint>(p.X, p));
        //        }
        //    }
        //    y = SpLine(knownSamples, x);
        //    if (double.IsInfinity(y))
        //    {
        //        return 199d;
        //    }
        //    return y;
        //}

        private void AddPointControl(PanoBeamLib.Blend.ControlPoint controlPoint)
        {
            var point = new ControlPoint(controlPoint.X * _width, controlPoint.Y * _height, controlPoint)
            {
                PointType = Mapper.ConvertControlPointType(controlPoint.PointType)
            };

            point.ValueChanged += PointOnValueChanged;
            Canvas1.Children.Add(point);
            point.PointTypeChanged         += RefreshGraph;
            point.Remove                   += PointOnRemove;
            point.PreviewMouseLeftButtonUp += PointOnMouseUp;
            RefreshGraph();
        }
예제 #4
0
 public void RemovePoint(ControlPoint point)
 {
     _points.Remove(point);
     UpdateNeighbors();
 }