void SetRanges(CalcRange xRange, CalcRange yRange, string zRangeText) { // Refreshes display as side effect var newRanges = string.Format(CultureInfo.InvariantCulture, "{0:G8}..{1:G8}; {2:G8}..{3:G8}; {4}", xRange.Lo, xRange.Hi, yRange.Lo, yRange.Hi, zRangeText); Trace.WriteLine(newRanges); cbRanges.Text = newRanges; }
private void Zoom(double ratio) { if (_outState != null) { string zRange = _outState.ZRange.RangeExpr?.Range.SourceText.ToString() ?? ""; CalcRange newX = _outState.XRange.ZoomedBy(ratio); CalcRange newY = _outState.YRange.ZoomedBy(ratio); SetRanges(newX, newY, zRange); } }
private void picPanel_MouseDown(object sender, MouseEventArgs e) { if (_outState != null) { _dragging = graphPanel.Capture = (e.Button == MouseButtons.Left); _dragStartPoint = e.Location; _originalRanges = cbRanges.Text; _originalXRange = _outState.XRange; _originalYRange = _outState.YRange; _originalZRange = _outState.ZRange.RangeExpr?.Range.SourceText.ToString() ?? ""; } }
private void picPanel_MouseMove(object sender, MouseEventArgs e) { if (_dragging) { lblMouseOver.Visible = false; CalcRange newX = _originalXRange.DraggedBy(e.Location.X - _dragStartPoint.X); CalcRange newY = _originalYRange.DraggedBy(-(e.Location.Y - _dragStartPoint.Y)); SetRanges(newX, newY, _originalZRange); } else { lblMouseOver.Text = _outState?.GetMouseOverText(e.Location) ?? ""; lblMouseOver.Visible = lblMouseOver.Text.Length != 0; } }
public abstract CalculatorCore WithXRange(CalcRange newValue);
public static CalculatorCore New(LNode expr, Dictionary <Symbol, LNode> vars, CalcRange xRange, CalcRange yRange) { // Find out if the expression uses the variable "y" (or is an equation with '=' or '==') // As an (unnecessary) side effect, this throws if an unreferenced var is used bool isEquation = expr.Calls(CodeSymbols.Assign, 2) || expr.Calls(CodeSymbols.Eq, 2), usesY = false; if (!isEquation) { LNode zero = LNode.Literal((double)0); Func <Symbol, double> lookup = null; lookup = name => name == sy_x || (usesY |= name == sy_y) ? 0 : Eval(vars[name], lookup); Eval(expr, lookup); } if (isEquation || usesY) { return(new Calculator3D(expr, vars, xRange, yRange)); } else { return(new Calculator2D(expr, vars, xRange)); } }
public Calculator3D WithYRange(CalcRange newValue) { return(new Calculator3D(Expr, Vars, XRange, newValue)); }
public override CalculatorCore WithXRange(CalcRange newValue) { return(new Calculator3D(Expr, Vars, newValue, YRange)); }
// Base class constructor and fields public CalculatorCore(LNode Expr, Dictionary <Symbol, LNode> Vars, CalcRange XRange) { this.Expr = Expr; this.Vars = Vars; this.XRange = XRange; }
public Calculator3D(LNode Expr, Dictionary <Symbol, LNode> Vars, CalcRange XRange, CalcRange YRange) : base(Expr, Vars, XRange) { this.YRange = YRange; }
public Calculator2D(LNode Expr, Dictionary <Symbol, LNode> Vars, CalcRange XRange) : base(Expr, Vars, XRange) { }