public void UnInitializeControl() { if (this.DesignMode) { return; } chartPane1.Remove(_chartSeries); _chartSeries.ClearValues(); _chartSeries = null; _account.UpdatedEvent -= new Account.AccountUpdateDelegate(_account_UpdateEvent); }
private void buttonPut_Click(object sender, EventArgs e) { float[] values = new float[(int)numericUpDownEnd.Value - (int)numericUpDownStart.Value]; float price = (float)numericUpDownPrice.Value; float strike = (float)numericUpDownStrike.Value; for (int i = 0; i < values.Length; i++) { float difference = price + strike - i; if (difference > 0) { values[i] = difference / (float)numericUpDownPrice.Value; } } LinesChartSeries series = new LinesChartSeries(); series.Name = "call " + price.ToString("#.00") + ";" + strike.ToString("#.00"); series.AddValueSet(values); chartControl1.MasterPane.Add(series); }
/// <summary> /// /// </summary> public void SetResultSetChartType(string setName, LinesChartSeries.ChartTypeEnum chartType) { _resultSetsChartTypes[setName] = chartType; }
/// <summary> /// /// </summary> protected void DrawItemSet(LinesChartSeries.ChartTypeEnum type, GraphicsWrapper g, Pen pen, Brush fill, int unitsUnification, RectangleF clippingRectangle, float itemWidth, float itemMargin, object tag) { PointF drawingPoint = new PointF(); int startIndex, endIndex; GetDrawingRangeIndecesFromClippingRectange(clippingRectangle, drawingPoint, unitsUnification, out startIndex, out endIndex, itemWidth, itemMargin); // Need to go up to (ItemsCount + unitsUnification) since the size of the step is (unitsUnification). for (int i = startIndex + unitsUnification - 1; i < endIndex && i < ItemsCount + unitsUnification; i += unitsUnification) { int actualIndex = i; int actualPreviousIndex = Math.Max(0, i - unitsUnification); if (actualIndex < 0 || actualIndex >= ItemsCount) {// Cycle conditions are loose and this is possible. continue; } switch (type) { case LinesChartSeries.ChartTypeEnum.ColoredArea: DrawColorAreaItem(g, ref drawingPoint, pen, fill, actualIndex, actualPreviousIndex, itemWidth, itemMargin, tag); break; case LinesChartSeries.ChartTypeEnum.Histogram: DrawHistogramBar(g, ref drawingPoint, pen, fill, actualIndex, actualPreviousIndex, itemWidth, itemMargin, unitsUnification, tag); break; case LinesChartSeries.ChartTypeEnum.Line: { float previousValue = GetDrawingValueAt(actualPreviousIndex, tag); float value = GetDrawingValueAt(actualIndex, tag); if (float.IsNaN(previousValue) == false && float.IsNaN(value) == false && float.IsInfinity(previousValue) == false && float.IsInfinity(value) == false) { g.DrawLine(pen, drawingPoint.X, drawingPoint.Y + previousValue, drawingPoint.X + itemMargin + itemWidth, drawingPoint.Y + value); } break; } default: break; } drawingPoint.X = (i + 1) * (itemMargin + itemWidth); } }
private void buttonCalculate_Click(object sender, EventArgs e) { List<double> positiveResults = new List<double>(); List<double> negativeResults = new List<double>(); for (int i = 0; i < (int)numericUpDownIterations.Value; i++) { int positives, negatives; PerformConsecutivesIteration(out positives, out negatives); if (positiveResults.Count < positives + 1) { positiveResults.AddRange(new double[positives - positiveResults.Count + 1]); negativeResults.AddRange(new double[positives - negativeResults.Count + 1]); } if (negativeResults.Count < negatives + 1) { positiveResults.AddRange(new double[negatives - positiveResults.Count + 1]); negativeResults.AddRange(new double[negatives - negativeResults.Count + 1]); } positiveResults[positives] = positiveResults[positives] + 1; negativeResults[negatives] = negativeResults[negatives] + 1; } graphControl.Clear(); LinesChartSeries series1 = new LinesChartSeries("+", LinesChartSeries.ChartTypeEnum.Histogram, GeneralHelper.DoublesToFloats(positiveResults.ToArray())); series1.DefaultPen = Pens.Green; graphControl.MasterPane.Add(series1); LinesChartSeries series2 = new LinesChartSeries("-", LinesChartSeries.ChartTypeEnum.Histogram, GeneralHelper.DoublesToFloats(negativeResults.ToArray())); series2.DefaultPen = Pens.Red; graphControl.MasterPane.Add(series2); graphControl.MasterPane.FitDrawingSpaceToScreen(true, true); }