protected override void OnTimerTick(object sender, EventArgs e) { base.OnTimerTick(sender, e); NChart chart = nChartControl1.Charts[0]; NAxis axisX = chart.Axis(StandardAxis.PrimaryX); if (m_Counter == 0) { NPointSeries point = new NPointSeries(); point.Size = new NLength(2); point.EnableDepthSort = false; point.DataLabelStyle.Visible = false; point.UseXValues = true; point.UseZValues = true; // turn off point border to improve performance point.BorderStyle.Width = new NLength(0); point.PointShape = PointShape.Bar; point.Tag = new NSphereInfo(DataPointsPerSphereComboBox.SelectedIndex); chart.Series.Add(point); m_Counter = 10; } m_Counter--; int count = chart.Series.Count; for (int i = count - 1; i >= 0; i--) { NPointSeries point = (NPointSeries)chart.Series[i]; NSphereInfo info = (NSphereInfo)point.Tag; if (info.m_Counter == 100) { chart.Series.RemoveAt(i); } else { info.AddSphere(point); } } nChartControl1.Refresh(); }
protected override void OnTimerTick(object sender, EventArgs e) { base.OnTimerTick(sender, e); // clear the list for (int i = 0; i < m_Matrix.Length; i++) { double[] arr = m_Matrix[i]; Array.Clear(arr, 0, arr.Length); } for (int i = m_SphereList.Count - 1; i >= 0; i--) { NSphereInfo sphere = m_SphereList[i]; sphere.ApplyToGrid(m_Matrix); sphere.m_X--; if (sphere.m_X + sphere.m_Radius < 0) { m_SphereList.RemoveAt(i); } } // fill grid to bars NChart chart = nChartControl1.Charts[0]; for (int i = 0; i < m_Matrix.Length; i++) { NBarSeries bar = chart.Series[i] as NBarSeries; double[] barValues = m_Matrix[i]; int barValueCount = barValues.Length; if (bar.Values.Count == 0) { bar.Values.AddRange(barValues); for (int j = 0; j < barValueCount; j++) { bar.FillStyles[j] = new NColorFillStyle(m_ColorTable[(int)barValues[j]]); } } else { bar.Values.SetRange(0, barValues); for (int j = 0; j < barValueCount; j++) { ((NColorFillStyle)bar.FillStyles[j]).Color = m_ColorTable[(int)barValues[j]]; } } } if (m_SphereCreationCounter == 0) { m_SphereCreationCounter = 5; int radius = (int)Math.Max(1, m_Random.NextDouble() * 50); int y = (int)(m_Random.NextDouble() * GetGridSizeY()); int x = GetGridSizeX() + radius; NSphereInfo sphere = new NSphereInfo(x, y, radius); m_SphereList.Add(sphere); } m_SphereCreationCounter--; nChartControl1.Refresh(); }