Пример #1
0
        internal CubicBezierCurve(Point[] points,
                                  int intervals,
                                  IPointCalculator pointCalculator,
                                  IPolygonAnalyser polygonAnalyser,
                                  IInputAnalyser inputAnalyser)
        {
            _pointCalculator = pointCalculator;
            _polygonAnalyser = polygonAnalyser;
            _inputAnalyser   = inputAnalyser;
            _points          = new List <Point>();

            if (!_inputAnalyser.IsValidInput(points, intervals))
            {
                throw new ArgumentException("Invalid input");
            }

            if (!_polygonAnalyser.IsControlPolygon(points))
            {
                throw new ArgumentException("Points entered do not form a control polygon", nameof(points));
            }

            for (var ndx = 0; ndx < intervals + 1; ndx++)
            {
                var t          = (float)ndx / (float)intervals;
                var curvePoint = _pointCalculator.Calculate(points, t);
                _points.Add(curvePoint);
                Points = _points.ToArray();
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            foreach (var portName in SerialPort.GetPortNames())
            {
                ComPort.Items.Add(portName);
            }

            MenuFileSave.IsEnabled = false;

            if (SerialPort.GetPortNames().Any())
            {
                ComPort.SelectedItem = SerialPort.GetPortNames()[0];
            }
            else
            {
                ComPort.IsEnabled   = false;
                StartStop.IsEnabled = false;
                O****m.IsEnabled    = false;
            }

            // ToDo: Make this selectable
            _analyser = new NogasmMotorDirectAnalyser();
            _analyser.OutputChange += AnalyserOnOutputChange;
            OnOrgasmDataPoint      += _analyser.HandleOrgasmData;
            var nogasmAnalyser = (INogasmInputAnalyser)_analyser;

            if (nogasmAnalyser != null)
            {
                OnNogasmDataPoint += nogasmAnalyser.HandleNogasmData;
            }
        }