public LineBuilder(Expression expr, Window window, double xScale, double yScale, double increment) { Expression = expr; Window = window; XScale = xScale; YScale = yScale; Increment = increment; _workingPointList = new List<PointD>(); _workingSegmentList = new List<IList<PointD>>(); }
private CalculatedLine CalculateLine(Expression expr) { CalculatedLine line; try { switch (expr.Type) { case ExpressionType.Linear: line = LinearLineCalculator.Calculate( (StandardExpression)expr, Calculator, _window, DisplayRectangle.Width, XScale, YScale, _resolution); break; case ExpressionType.Polar: line = _polarCalc.Calculate( (StandardExpression)expr, Calculator, _window, XScale, YScale); break; case ExpressionType.Parametric: line = _paraCalc.Calculate( (ParametricExpression)expr, Calculator, _window, XScale, YScale); break; default: throw new NotSupportedException("Type not implemented."); } } catch (Exception ex) { MessageBox.Show(ex.Message); var calculatedLine = new LineBuilder(expr, Window, XScale, YScale, 0); return calculatedLine.SealLine(); } return line; }
private void OnSelectClick(object sender, EventArgs e) { var selected = _checkables. Where(b => b.Checked). Select(b => (Expression)b.Tag). SingleOrDefault(); if (selected == null) { // Shouldn't happen, since we set the first expression to checked in the // constructor and a radio button can't be unchecked, but might as well include this MessageBox.Show( "You must select an expression to continue.", "Expression Not Selected", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (radioManualBounds.Checked) { if (string.IsNullOrEmpty(textboxLeftBound.Text)) { MessageBox.Show("You must provide a value for the left bound before continuing.", "Left Bound Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textboxRightBound.Text)) { MessageBox.Show("You must provide a value for the right bound before continuing.", "Right Bound Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } double? leftBound, rightBound; if ((leftBound = ParseBound("left", textboxLeftBound.Text)) == null || (rightBound = ParseBound("right", textboxRightBound.Text)) == null) { return; } if (rightBound < leftBound) { MessageBox.Show("The left bound must be less than the right bound.", "Right Bound Greater than Left", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } LeftBound = leftBound; RightBound = rightBound; ManualBoundSpecified = true; } SelectedExpression = selected; DialogResult = DialogResult.OK; Close(); }