GDI+ Examples: Column Chart |
|
|
|
|
#pragma once namespace WeeklySales1 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public __gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } private: System::Windows::Forms::Button * btnGenerate; private: System::Windows::Forms::TextBox * txtFriday; private: System::Windows::Forms::Label * label5; private: System::Windows::Forms::TextBox * txtThursday; private: System::Windows::Forms::Label * label4; private: System::Windows::Forms::TextBox * txtWednesday; private: System::Windows::Forms::Label * label3; private: System::Windows::Forms::TextBox * txtTuesday; private: System::Windows::Forms::Label * label2; private: System::Windows::Forms::TextBox * txtMonday; private: System::Windows::Forms::Label * label1; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container * components; Graphics *graphDrawingArea; Bitmap *bmpDrawingArea; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { . . . No Change } private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e) { bmpDrawingArea = new Bitmap(Width, Height); graphDrawingArea = Graphics::FromImage(bmpDrawingArea); } }; } |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { e->Graphics->DrawImage(bmpDrawingArea, 0, 0); } |
private: System::Void btnGenerate_Click(System::Object * sender, System::EventArgs * e) { int monday = this->txtMonday->Text->ToInt32(0) / 100; int tuesday = this->txtTuesday->Text->ToInt32(0) / 100; int wednesday = this->txtWednesday->Text->ToInt32(0) / 100; int thursday = this->txtThursday->Text->ToInt32(0) / 100; int friday = this->txtFriday->Text->ToInt32(0) / 100; graphDrawingArea->Clear(this->BackColor); graphDrawingArea->FillRectangle(new SolidBrush(Color::Red), this->txtMonday->Left+5, 280-monday, 40, monday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), this->txtMonday->Left+5, 280-monday, 40, monday); graphDrawingArea->FillRectangle(new SolidBrush(Color::Blue), this->txtTuesday->Left+5, 280-tuesday, 40, tuesday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), this->txtTuesday->Left+5, 280-tuesday, 40, tuesday); graphDrawingArea->FillRectangle(new SolidBrush(Color::Fuchsia), this->txtWednesday->Left+5, 280-wednesday, 40, wednesday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), this->txtWednesday->Left+5, 280-wednesday, 40, wednesday); graphDrawingArea->FillRectangle(new SolidBrush(Color::Brown), this->txtThursday->Left+5, 280-thursday, 40, thursday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), this->txtThursday->Left+5, 280-thursday, 40, thursday); graphDrawingArea->FillRectangle(new SolidBrush(Color::Turquoise), this->txtFriday->Left+5, 280-friday, 40, friday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), this->txtFriday->Left+5, 280-friday, 40, friday); graphDrawingArea->DrawRectangle(new Pen(Color::Black), 10, 280, Width - 30, 1); Invalidate(); } |
|
||
Home | Copyright © 2004-2010 FunctionX, Inc. | |
|