public void ResetControlPoints(ControlPoint[] controlPoints, bool controlPointsVisible)
        {
            _controlPointControls.Clear();
            Canvas0.Children.Clear();

            foreach (var cp in controlPoints)
            {
                var control = new ControlPointControl
                {
                    ControlPointType = cp.ControlPointType,
                    Color            = GetColor()
                };
                control.Initialize(cp, ActivateControlPoint);
                control.ControlPointTypeChanged += controlPoint =>
                {
                    if (controlPoint.ControlPointType == ControlPointType.Default)
                    {
                    }
                    ControlPointTypeChanged?.Invoke(ConvertControlPointData(controlPoint));
                };
                Canvas0.Children.Add(control);
                _controlPointControls.Add(control);
            }

            foreach (var cp in _controlPointControls)
            {
                cp.Visibility = controlPointsVisible ? Visibility.Visible : Visibility.Collapsed;
            }
            RefreshControlPoints();
            AddWireframe();
        }
 private ControlPoint ConvertControlPointData(ControlPointControl control)
 {
     return(new ControlPoint(
                control.ControlPoint.X,
                control.ControlPoint.Y,
                control.ControlPoint.U,
                control.ControlPoint.V,
                control.ControlPoint.ControlPointType,
                control.ControlPoint.ControlPointDirections
                ));
 }
 public void SetVisibility(bool controlPointsVisible, bool wireframeVisible)
 {
     foreach (var cp in _controlPointControls)
     {
         cp.Visibility = controlPointsVisible ? Visibility.Visible : Visibility.Collapsed;
     }
     if (!controlPointsVisible)
     {
         if (_activeControlPointControl != null)
         {
             _activeControlPointControl.Color = GetColor();
             _activeControlPointControl       = null;
         }
     }
     LineCanvas.Visibility = wireframeVisible ? Visibility.Visible : Visibility.Collapsed;
 }
 private void ActivateControlPoint(ControlPointControl cp)
 {
     if (!_isActive)
     {
         return;
     }
     if (_activeControlPointControl != null)
     {
         _activeControlPointControl.Color = GetColor();
     }
     _activeControlPointControl = cp;
     if (_activeControlPointControl != null)
     {
         _activeControlPointControl.Color = _brushActive;
         ControlPointActivated?.Invoke(ConvertControlPointData(_activeControlPointControl));
     }
 }