#pragma once
namespace Projekt {
using namespace System;
// własne dopisane
using namespace System::IO;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
///
/// Summary for OknoGlowne
///
/// 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.
///
public ref class OknoGlowne : public System::Windows::Forms::Form
{
public:
OknoGlowne(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///
~OknoGlowne()
{
if (components)
{
delete components;
}
}
// public :
// virtual void Write
// (
// array^ buffer,
// int index,
// int count
// )
// override;
private: System::Windows::Forms::ToolStripMenuItem^ Zakończ;
protected:
protected:
private: System::Windows::Forms::ToolStripMenuItem^ otwórzToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ zapiszToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ pomocToolStripMenuItem;
private: System::Windows::Forms::ToolStrip^ toolStrip1;
private: System::Windows::Forms::ToolStripButton^ pasekNarzedziowy;
private: System::Windows::Forms::ToolStripButton^ toolStripButton1;
private: System::Windows::Forms::StatusStrip^ statusStrip1;
private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ txtImie;
private: System::Windows::Forms::TextBox^ txtNazwisko;
private: System::Windows::Forms::CheckBox^ cbPoczatkujacy;
private: System::Windows::Forms::ComboBox^ cmbJezyk;
private: System::Windows::Forms::Button^ btnOK;
private: System::Windows::Forms::OpenFileDialog^ openFileDialog;
private: System::Windows::Forms::ToolStripMenuItem^ zakończToolStripMenuItem;
private:
///
/// Required designer variable.
///
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
System::Windows::Forms::MenuStrip^ menuGlowne;
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(OknoGlowne::typeid));
this->Zakończ = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->otwórzToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->zapiszToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->zakończToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->pomocToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
this->pasekNarzedziowy = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->txtImie = (gcnew System::Windows::Forms::TextBox());
this->txtNazwisko = (gcnew System::Windows::Forms::TextBox());
this->cbPoczatkujacy = (gcnew System::Windows::Forms::CheckBox());
this->cmbJezyk = (gcnew System::Windows::Forms::ComboBox());
this->btnOK = (gcnew System::Windows::Forms::Button());
this->openFileDialog = (gcnew System::Windows::Forms::OpenFileDialog());
menuGlowne = (gcnew System::Windows::Forms::MenuStrip());
menuGlowne->SuspendLayout();
this->toolStrip1->SuspendLayout();
this->statusStrip1->SuspendLayout();
this->SuspendLayout();
//
// menuGlowne
//
menuGlowne->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->Zakończ, this->pomocToolStripMenuItem});
menuGlowne->Location = System::Drawing::Point(0, 0);
menuGlowne->Name = L"menuGlowne";
menuGlowne->Size = System::Drawing::Size(384, 24);
menuGlowne->TabIndex = 0;
menuGlowne->Text = L"menuStrip1";
//
// Zakończ
//
this->Zakończ->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->otwórzToolStripMenuItem,
this->zapiszToolStripMenuItem, this->zakończToolStripMenuItem});
this->Zakończ->Name = L"Zakończ";
this->Zakończ->Size = System::Drawing::Size(38, 20);
this->Zakończ->Text = L"Plik";
//
// otwórzToolStripMenuItem
//
this->otwórzToolStripMenuItem->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->otwórzToolStripMenuItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->otwórzToolStripMenuItem->Name = L"otwórzToolStripMenuItem";
this->otwórzToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->otwórzToolStripMenuItem->Text = L"Otwórz";
this->otwórzToolStripMenuItem->Click += gcnew System::EventHandler(this, &OknoGlowne::otwórzToolStripMenuItem_Click);
//
// zapiszToolStripMenuItem
//
this->zapiszToolStripMenuItem->Name = L"zapiszToolStripMenuItem";
this->zapiszToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->zapiszToolStripMenuItem->Text = L"Zapisz";
this->zapiszToolStripMenuItem->Click += gcnew System::EventHandler(this, &OknoGlowne::zapiszToolStripMenuItem_Click);
//
// zakończToolStripMenuItem
//
this->zakończToolStripMenuItem->Name = L"zakończToolStripMenuItem";
this->zakończToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->zakończToolStripMenuItem->Text = L"Zakończ";
this->zakończToolStripMenuItem->Click += gcnew System::EventHandler(this, &OknoGlowne::zakończToolStripMenuItem_Click);
//
// pomocToolStripMenuItem
//
this->pomocToolStripMenuItem->Name = L"pomocToolStripMenuItem";
this->pomocToolStripMenuItem->Size = System::Drawing::Size(57, 20);
this->pomocToolStripMenuItem->Text = L"Pomoc";
this->pomocToolStripMenuItem->Click += gcnew System::EventHandler(this, &OknoGlowne::pomocToolStripMenuItem_Click);
//
// toolStrip1
//
this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->pasekNarzedziowy,
this->toolStripButton1});
this->toolStrip1->Location = System::Drawing::Point(0, 24);
this->toolStrip1->Name = L"toolStrip1";
this->toolStrip1->Size = System::Drawing::Size(384, 25);
this->toolStrip1->TabIndex = 1;
this->toolStrip1->Text = L"toolStrip1";
//
// pasekNarzedziowy
//
this->pasekNarzedziowy->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->pasekNarzedziowy->Image = (cli::safe_cast(resources->GetObject(L"pasekNarzedziowy.Image")));
this->pasekNarzedziowy->ImageTransparentColor = System::Drawing::Color::Magenta;
this->pasekNarzedziowy->Name = L"pasekNarzedziowy";
this->pasekNarzedziowy->Size = System::Drawing::Size(23, 22);
this->pasekNarzedziowy->Text = L"Otwarcie pliku";
this->pasekNarzedziowy->ToolTipText = L"Otwórz";
this->pasekNarzedziowy->Click += gcnew System::EventHandler(this, &OknoGlowne::pasekNarzedziowy_Click);
//
// toolStripButton1
//
this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->toolStripButton1->Image = (cli::safe_cast(resources->GetObject(L"toolStripButton1.Image")));
this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripButton1->Name = L"toolStripButton1";
this->toolStripButton1->Size = System::Drawing::Size(23, 22);
this->toolStripButton1->Text = L"Zapis pliku";
this->toolStripButton1->ToolTipText = L"Zapisz";
//
// statusStrip1
//
this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->toolStripStatusLabel1});
this->statusStrip1->Location = System::Drawing::Point(0, 242);
this->statusStrip1->Name = L"statusStrip1";
this->statusStrip1->RenderMode = System::Windows::Forms::ToolStripRenderMode::Professional;
this->statusStrip1->Size = System::Drawing::Size(384, 22);
this->statusStrip1->TabIndex = 10;
this->statusStrip1->Text = L"statusStrip1";
//
// toolStripStatusLabel1
//
this->toolStripStatusLabel1->Name = L"toolStripStatusLabel1";
this->toolStripStatusLabel1->Size = System::Drawing::Size(51, 17);
this->toolStripStatusLabel1->Text = L"Gotowy!";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(52, 94);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(26, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Imię";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(52, 134);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(53, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"Nazwisko";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(209, 134);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(109, 13);
this->label3->TabIndex = 7;
this->label3->Text = L"Język programowania";
//
// txtImie
//
this->txtImie->AccessibleRole = System::Windows::Forms::AccessibleRole::None;
this->txtImie->Location = System::Drawing::Point(55, 111);
this->txtImie->Name = L"txtImie";
this->txtImie->Size = System::Drawing::Size(100, 20);
this->txtImie->TabIndex = 3;
//
// txtNazwisko
//
this->txtNazwisko->Location = System::Drawing::Point(55, 150);
this->txtNazwisko->Name = L"txtNazwisko";
this->txtNazwisko->Size = System::Drawing::Size(100, 20);
this->txtNazwisko->TabIndex = 5;
//
// cbPoczatkujacy
//
this->cbPoczatkujacy->AutoSize = true;
this->cbPoczatkujacy->Location = System::Drawing::Point(212, 111);
this->cbPoczatkujacy->Name = L"cbPoczatkujacy";
this->cbPoczatkujacy->Size = System::Drawing::Size(146, 17);
this->cbPoczatkujacy->TabIndex = 6;
this->cbPoczatkujacy->Text = L"początkujący programista";
this->cbPoczatkujacy->UseVisualStyleBackColor = true;
//
// cmbJezyk
//
this->cmbJezyk->FormattingEnabled = true;
this->cmbJezyk->Items->AddRange(gcnew cli::array< System::Object^ >(7) {L"C", L"C++", L"C++/CLI", L"Perl", L"PHP", L"Java",
L"C#"});
this->cmbJezyk->Location = System::Drawing::Point(212, 149);
this->cmbJezyk->Name = L"cmbJezyk";
this->cmbJezyk->Size = System::Drawing::Size(121, 21);
this->cmbJezyk->TabIndex = 8;
this->cmbJezyk->SelectedIndexChanged += gcnew System::EventHandler(this, &OknoGlowne::cmbJezyk_SelectedIndexChanged);
//
// btnOK
//
this->btnOK->Location = System::Drawing::Point(55, 202);
this->btnOK->Name = L"btnOK";
this->btnOK->Size = System::Drawing::Size(75, 23);
this->btnOK->TabIndex = 9;
this->btnOK->Text = L"OK";
this->btnOK->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->btnOK->UseVisualStyleBackColor = true;
this->btnOK->Click += gcnew System::EventHandler(this, &OknoGlowne::btnOK_Click);
//
// OknoGlowne
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(384, 264);
this->Controls->Add(this->btnOK);
this->Controls->Add(this->cmbJezyk);
this->Controls->Add(this->cbPoczatkujacy);
this->Controls->Add(this->txtNazwisko);
this->Controls->Add(this->txtImie);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->statusStrip1);
this->Controls->Add(this->toolStrip1);
this->Controls->Add(menuGlowne);
this->MainMenuStrip = menuGlowne;
this->Name = L"OknoGlowne";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Mój pierwszy program";
this->Load += gcnew System::EventHandler(this, &OknoGlowne::OknoGlowne_Load);
menuGlowne->ResumeLayout(false);
menuGlowne->PerformLayout();
this->toolStrip1->ResumeLayout(false);
this->toolStrip1->PerformLayout();
this->statusStrip1->ResumeLayout(false);
this->statusStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void pasekNarzedziowy_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void OknoGlowne_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void cmbJezyk_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
// tekstowa komenda sumująca łańcuch danych
private: System::Void btnOK_Click(System::Object^ sender, System::EventArgs^ e) {
String^ komunikat = txtImie->Text + " " + txtNazwisko->Text + “\n”;
if (cbPoczatkujacy->Checked)
{
komunikat += “Poczatkujacy programista\n”;
}
else
{
komunikat += “Zaawansowany programista\n”;
}
if (cmbJezyk->Text->Length !=0)
{
komunikat += "Jezyk programowania: " + cmbJezyk->Text;
}
MessageBox::Show(komunikat, “Dane programisty”, MessageBoxButtons::
OK, MessageBoxIcon::Information);
}
// Otwórz plik
private: System::Void otwórzToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if (openFileDialog->ShowDialog() == System::Windows::Forms::DialogResult::OK){
System::IO::StreamReader^ sr = System::IO::File::OpenText(openFileDialog->FileName);
//try
//{
String^ s = “”;
txtImie->Text = sr->ReadLine();
txtNazwisko->Text = sr->ReadLine();
cbPoczatkujacy->Text = sr->ReadLine();
cmbJezyk->Text = sr->ReadLine();
// }
// finally
{
if (sr)
delete (IDisposable^)(sr);
}
}
}
//Zapisywanie do pliku
private: System::Void zapiszToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
//if (openFileDialog->ShowDialog() == System::Windows::Forms::DialogResult::OK){
//System::String^ txtImie;
StreamWriter^ plik =
gcnew StreamWriter(“Plik.txt”,0,System::Text::Encoding::Default);
plik->WriteLine(txtImie);
plik->WriteLine(txtNazwisko);
plik->WriteLine(cbPoczatkujacy);
plik->WriteLine(cmbJezyk);
//plik->WriteLine(cmbJezyk);
plik->Close();
//gcnew StreamWriter(“Plik.txt”,0,0,System::Text::Encoding::Default);
}
// Zamykanie okna
private: System::Void zakończToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Close();
}
private: System::Void pomocToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show(“Demonstaracja elementów kontrolnych”, “O programie” ,
MessageBoxButtons::OK,MessageBoxIcon::Information);
}
}
;}
– Dodane 11.11.2009 (Śr) 19:47 –
komendy to Otwórz plik i Zapisywanie do pliku