Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. public ref class Form1 : public System::Windows::Forms::Form
  2. {
  3. cli::array<float, 1>^ m_dataArray;
  4.  
  5. Form1(void):
  6. m_dataArray(gcnew cli::array<float, 1>(256))
  7. {
  8. InitializeComponent();
  9. ConfigureGraph(m_spectraGraph1);
  10. }
  11.  
  12. // Windows forms generated code (cut down for brevity)
  13. void InitializeComponent(void)
  14. {
  15. chartArea1->Name = L"ChartArea1";
  16. this->m_spectraGraph1->ChartAreas->Add(chartArea1);
  17. this->m_spectraGraph1->Dock = System::Windows::Forms::DockStyle::Fill;
  18. legend1->Name = L"Legend1";
  19. this->m_spectraGraph1->Legends->Add(legend1);
  20. this->m_spectraGraph1->Location = System::Drawing::Point(3, 3);
  21. this->m_spectraGraph1->Name = L"m_spectraGraph1";
  22. series1->ChartArea = L"ChartArea1";
  23. series1->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::FastLine;
  24. series1->Legend = L"Legend1";
  25. series1->Name = L"Series1";
  26. this->m_spectraGraph1->Series->Add(series1);
  27. this->m_spectraGraph1->Size = System::Drawing::Size(331, 253);
  28. this->m_spectraGraph1->TabIndex = 0;
  29. this->m_spectraGraph1->Text = L"chart1";
  30. }
  31.  
  32. void ConfigureGraph(System::Windows::Forms::DataVisualization::Charting::Chart^% chart1)
  33. {
  34. chart1->DataSource = m_dataArray;
  35. chart1->Legends->Clear();
  36. }
  37.  
  38. void UpdateChart()
  39. {
  40. Random r(DateTime::Now.Millisecond);
  41. int count = m_dataArray->Length;
  42. for(int i = 0; i < count; ++i)
  43. {
  44. m_dataArray[i] = r.Next(90,110)/100.0f;
  45. }
  46. m_spectraGraph1->DataBind();
  47. }
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement