System jest głównym w hierarchii obszarem nazw, zdefiniowanym w bibliotece mscorlib.dll.



Podobne dokumenty
- Narzędzie Windows Forms. - Przykładowe aplikacje. Wyższa Szkoła Techniczno Ekonomiczna w Świdnicy. Języki i paradygmaty programowania - 8

Rys. 1. Struktura środowiska.net 3.5. S. Fraser, Pro Visual C++/CLI and the.net 3.5 Platform, Apress, 2009.

Dodanie nowej formy do projektu polega na:

Prosta książka telefoniczna z wykorzystaniem zapisu do pliku

Biblioteka Windows Forms

Interfejs użytkownika (ang. User Interface, UI) w technice część urządzenia odpowiedzialna za interakcję z użytkownikiem

Projektowanie Graficznych Interfejsów Użytkownika Robert Szmurło

Politechnika Poznańska Wydział Budowy Maszyn i Zarządzania

Aby nadać jej pożądaną postać należy w pliku Window1.xaml stworzyć definicję swojego stylu modyfikując ręcznie postać zapisu XAML:

Visual Basic for Applications. Formatki tworzenie,

Zaawansowane środowiska programistyczne 2009/2010

Programowanie w środowiskach graficznych. Wykład 2 Windows Forms

Przykładowa dostępna aplikacja w Visual Studio - krok po kroku

- Narzędzie Windows Forms. - Przykładowe aplikacje. Wyższa Metody Szkoła programowania Techniczno Ekonomiczna 1 w Świdnicy

Politechnika Poznańska Wydział Budowy Maszyn i Zarządzania. Programowanie systemów informatycznych laboratorium. Ćw. 3: Akwizycja danych. RS 232 cd.

.NET Framework Technologia firmy Microsoft wprowadzona w 2002 roku

Visual Studio instalacja

Laboratorium 10 - Web Services

Kurs programowania 2 - listy

Programowanie aplikacji okienkowych Windows

Instrukcja laboratoryjna cz.3

Programowanie obiektowe

Programowanie w środowiskach graficznych. Wykład 1 OS, Podstawy Windows API

Materiały do zajęć IX

2. W oknie dialogowym Choose Toolbox Items w zakładce.net Framework Components naciskamy przycisk Browse...

Programowanie w środowiskach graficznych. Wykład 1 OS, Podstawy Windows API

Programowanie telefonów z Windows Phone 7, cz. 2

Testy jednostkowe - zastosowanie oprogramowania JUNIT 4.0 Zofia Kruczkiewicz

Podstawy programowania. Ćwiczenie. Pojęcia bazowe. Języki programowania. Środowisko programowania Visual Studio

Wykład 6 Dziedziczenie cd., pliki

private: System::Void button1_click(system::object^ sender, System::EventArgs^ e) {

Ekspert radzi. mechanizm w enova, umożliwiający wskazanie domyślnej drukarki dla danego stanowiska i wydruku. Strona 1 z 8. Ekspert radzi.

Wykład 12. Programowanie serwera MS SQL 2005 w C#

Programowanie obiektowe i zdarzeniowe

Przewodnik krok po kroku:

Metodyka programowania. Visual Studio C# Formularze

Programowanie w środowisku graficznym GUI

Kompilacja i kompilatory

Prosta aplikacja klient - serwer na bazie protokoªu UDP. Sprawozdanie.

Rozdział 3. Zapisywanie stanu aplikacji w ustawieniach lokalnych

Wykład 5 Okna MDI i SDI, dziedziczenie

Henryk Budzisz. materiały przygotowane w ramach projektu ZPORR nr POKL /08-00

Programowanie w technologii.net wykład 4 Aplikacja i okna

Java - interfejs graficzny

Zdarzenie Zachodzi gdy Kolejność zdarzeń Kolejność Zdarzenie Opis uwaga: CausesValidation True.

using System;... using System.Threading;

Politechnika Gdańska Katedra Optoelektroniki i Systemów Elektronicznych

X11R5. .Xresources. Pliki konfiguracyjne X-Windows. Zasada działania X11. .xinitrc. X protocol X server. X client. X library

Wykład 4 Delegat (delegate), właściwości indeksowane, zdarzenie (event) Zofia Kruczkiewicz

Instrukcja obsługi User s manual

Camspot 4.4 Camspot 4.5

Zmiany techniczne wprowadzone w wersji Comarch ERP Altum

Installation of EuroCert software for qualified electronic signature

Programowanie telefonów z Windows Phone 7, cz. 4

Metodyka programowania. Visual Studio C#

Programowanie obiektowe i zdarzeniowe wykład 4 Kompozycja, kolekcje, wiązanie danych

Programowanie obiektowe i zdarzeniowe wykład 1 Wprowadzenie do programowania zdarzeniowego

Politechnika Poznańska Wydział Budowy Maszyn i Zarządzania

Wybieramy File->New->Project Wybieramy aplikację MFC->MFC Application jak na rysunku poniżej:

Ćwiczenia 9 - Swing - część 1

Instrukcja laboratoryjna nr.4

Platforma.NET laboratorium 1. Visual Basic.NET podstawowe elementy języka. Wykonanie warunkowe If End If

Wyjątki i obsługa błędów

2. Kliknij Insert->Userform. Jeżeli Toolbox nie pojawi się automatycznie, kliknij View -> Toolbox. Otrzymany widok powinien być jak poniżej.

1. CZYM JEST SERIALIZACJA

Sposoby tworzenia projektu zawierającego aplet w środowisku NetBeans. Metody zabezpieczenia komputera użytkownika przed działaniem apletu.

Wykład 5_2 Arkusze stylów dziedziczenie. Technologie internetowe Zofia Kruczkiewicz

Narzędzia 4. dr inż. Tadeusz Jeleniewski

Instytut Sterowania i Systemów Informatycznych Uniwersytet Zielonogórski SYSTEMY SCADA

Budowa aplikacji wielowarstwowych zastosowanie szablonów. Laboratorium 2 Programowanie komponentowe Zofia Kruczkiewicz


Rys. 3. Kod elementów na stronie po dodaniu kontrolek podstawowych.

Volcano MC-GM4 OPTICAL MOUSE USER S MANUAL MODECOM

Aplikacje geodezyjne

4 C#. Tworzenie aplikacji sieciowych. 101 gotowych projektów

Ćwiczenia laboratoryjne. Oprogramowanie i badanie prostych metod sortowania w tablicach

Program ćwiczenia nr 4: Okna dialogowe.

Zarządzanie sieciami telekomunikacyjnymi

Volcano MC-GMX4 OPTICAL MOUSE USER S MANUAL MODECOM

TabControl kontrolka odpowiedzialna za wyświetlenie zestawu zakładek. PageControl podobnie jak TabControl ale posiada wbudowane strony.

Multimedia JAVA. Historia

Ćwiczenie laboratoryjne. Oprogramowanie i badanie stosu lub kolejki w środowisku Visual Basic 2005

Laboratorium z przedmiotu: Inżynieria Oprogramowania INEK Instrukcja 7

Diagram stanów Laboratorium 9

Zaawansowane aplikacje WWW - laboratorium

Laboratorium 8 Diagramy aktywności

Programowanie obiektowe

1. W systemie Windows przejdź do Panel sterowania> Sieć i Internet> Centrum sieci i udostępniania.

Dzisiejszy wykład. Wzorce projektowe. Visitor Client-Server Factory Singleton


Wykład 7 Okna dialogowe, menu, pasek stanu itp.

GUI - projektowanie interfejsów cz. II

Instrukcja konfiguracji usługi Wirtualnej Sieci Prywatnej w systemie Mac OSX

Projekt Hurtownia. Koło Naukowe Programistów.NET Wyższa Szkoła Biznesu - National Louis University w Nowym Sączu

WYŻSZA SZKOŁA ZARZĄDZANIA I ADMINISTRACJI z siedzibą w Zamościu

Cel szkolenia. Konspekt

Oracle Application Express

1. Wprowadzenie do WPF i XAML. Tworzenie interfejsu użytkownika.

Kurs programowania. Wykład 1. Wojciech Macyna. 3 marca 2016

Notatnik w Windows Forms

Transkrypt:

6.1 Obszary nazw.net... 1 6.2 Obszar nazw System::Windows::Forms... 2 6.3 Klasa Form. Wybrane metody i property.... 3 6.4 Zadarzenia klasy Control... 5 6.5 Formatka z przyciskiem i polem tekstowym... 7 6.6 Wątki. Formatka z ProgressBar em... 9 6.7 Dodatek. Formatka z przyciskiem i polem tekstowym w języku C#... 12 6.1 Obszary nazw.net System jest głównym w hierarchii obszarem nazw, zdefiniowanym w bibliotece mscorlib.dll. Nazwa System::Collections System::Configuration System::Data System::Deployment System::Diagnostics System::DirectoryServices System::Drawing System::EnterpriseServices System::Globalization System::IO System::Management System::Net System::Reflection System::Resources System::Runtime::InteropServices System::Runtime::Remoting System::Runtime::Serialization System::Security System::Threading System::Web System::Windows::Forms System::Xml Microsoft::Win32 Opis Zawiera typy ArrayList, BitArray Hashtable, Queue, SortedList, Stack, inne bardziej specjalistyczne typy danych. dynamiczna modyfikacja plików application.config, web.config. Zawiera klasy ADO.NET. Umożliwia programowe uaktualnienia aplikacji. Deklaracja: #using <System.Deployment.dll>. Umożliwia uzyskiwanie informacji o środowisku CLR. Deklaracja: #using <System.Directoryservices.dll>. Zawiera elementy graficzne GDI+. Umożliwia dostęp do obiektów COM+. Umożliwia dostęp do danych w różnych formatach, specyficznych dla konkretnego języka, waluty, kalendarza. Biblioteki wejścia/wyjścia, operacje na plikach. U dostęp do narzędzi i informacji o działających aplikacjach, urządzeniach. Umożliwia tworzenie aplikacji.net. Umożliwia dynamiczne tworzenie typów danych. Umożliwia zarządzanie zasobami. Usługi systemowe i COM. Umożliwia budowę aplikacji rozproszonych (DCOM). serializacja i deserializacja obiektów, czyli konwersji obiektów a różne typy danych (txt, binary, ). Umożliwia wprowadzanie zabezpieczeń do kodu, działania aplikacji (autoryzacja, identyfikacja, szyfrowanie, ). Umożliwia tworzenie i zarządzanie wątkami. Umożliwia budowę aplikacji w oparciu o usługę WWW. Umożliwia budowę aplikacji okienkowych. U zarządzanie danymi XML. Umożliwia budowę aplikacji win32. 1

6.2 Obszar nazw System::Windows::Forms Nazwa Application AxHost BorderStyle Button ButtonState CheckBox Clipboard ColorDialog ComboBox Cursor DataGrid DateTimePicker Form HScrollBar ImageList Label ListBox ListView Menu MessageBox Panel ProgressBar RadioButton Splitter StatusBar TextBox ToolBar Opis Provides static methods to manage applications, including starting and stopping them, and getting information about them. Provides a way to host ActiveX controls in Windows Forms applications. An enumeration that specifies the border style for controls. BorderStyle has three members: Fixed3D for three-dimensional borders, FixedSingle for simple line borders, and None for no border. Represents a Windows button control. An enumeration that specifies the appearance of a button. Members include Inactive, Pushed, and Normal. Represents a Windows check box control. Lets you place data onto and retrieve it from the system clipboard. Displays a standard dialog box to let the user pick a color. Represents a Windows combo box control. Represents a cursor. Displays ADO.NET data in a scrollable grid. Windows date-time picker control. Window or a dialog box. Windows horizontal scroll bar control. Collection of images typically used by toolbars. Windows label control. Windows list box control. Displays a list of items in one of four views. Represents a menu. Displays a message box. A control that can contain other controls. Windows progress bar control. Windows radio button control. Provides splitter functionality to a window. Windows status bar control. Windows edit control. Windows toolbar control. Przykład 1. Obszary nazw użyte do tworzenia okna w szablonie CLR->Windows Forms Aplication. using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; 2

6.3 Klasa Form. Wybrane metody i property. Nazwa M - Metoda Opis P - Property AcceptButton P Gets or sets a reference to the button control that corresponds to the user pressing Enter. Activate M Activates the window, bringing it to the front of the application s collection of windows. ActiveForm P Gets the currently active form for this application, meaning the one at the front of the application s collection of windows. AutoScale P Gets or sets a Boolean value indicating whether the form adjusts its size to fit the height of the font used on the form and scales its controls accordingly. The default is true. AutoScroll P Gets or sets a value indicating whether the form displays scroll bars when controls fall outside the displayable area. The default is true. CancelButton P Gets or sets a reference to the button control that corresponds to the user pressing Esc. ClientSize P Gets or sets the size of the client area of the form. (The client area is the portion of the form that excludes the title bar and borders.) Close M Closes the form and frees any resources the form has used. DesktopLocation P Gets or sets the location of the form on the Windows desktop. FormBorderStyle P Gets or sets the border style of the form. The default is FormBorderStyle::Sizeable. HelpButton P Gets or sets a Boolean value indicating if the form is to display a Help button on the title bar. The default is false. Icon P Gets or sets the icon associated with the form. MaximizeBox P Gets or sets a Boolean value that indicates if the form is displaying a Maximize box on the title bar. The default is true. Menu P Gets or sets a reference to the menu that is displayed on this form. MinimizeBox P Gets or sets a Boolean value that indicates if the form is displaying a Minimize box on the title bar. The default is true. OwnedForms P Holds the collection of child forms owned by this form, if any. SetDesktopLocation M Sets the location of the form on the desktop. ShowDialog M Shows the form as a modal dialog box. ShowInTaskBar P Gets or sets a Boolean value, which is true if the form is to be shown in the Windows taskbar. The default is true. Size P Gets or sets the form s size. SizeGripStyle P Determines how (or even whether) the sizing grip is shown at the lower right of the form. The default is SizeGripStyle::Hide. TopLevel P Gets or sets a Boolean value, which is true if the form is a top-level window, meaning that it has no parent other than the Windows desktop. The default is true. TopMost P Gets or sets a Boolean value, which is true if the form is a topmost window, meaning it is always displayed on top of other windows, even when it doesn t have the focus. The default is false. WindowState P Gets or sets the form s window state, which determines how the form is displayed minimized, maximized, or normal. The default is FormWindowState::Normal. 3

Przykład 1. Metody, property, zdarzenia atrybuty klasy Form użyte do tworzenia okna w szablonie CLR->Windows Forms Aplication. // metody this->suspendlayout(); this->autoscaledimensions = System::Drawing::SizeF(6, 13); this->clientsize = System::Drawing::Size(292, 270); this->resumelayout(false); // zdarzenie this->load += gcnew System::EventHandler(this, &Form1::Form1_Load); // property this->autoscalemode = System::Windows::Forms::AutoScaleMode::Font; // atrybuty this->name = L"Form1"; this->text = L"Form1"; Implementacja metody Form1_Load()przypisanej do zdarzenia Load. Przed utworzeniem formatki pojawi się MessageBox z komunikatem Form1. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) MessageBox::Show("Form1", "Okno przed formatka", MessageBoxButtons::OK, MessageBoxIcon::Information); 4

6.4 Zadarzenia klasy Control Przkład 1. Wybrane zdarzenia klasy Control (Control Events). Click Zachodzi gdy kontrolka jest kliknięta. Occurs when the control is clicked. DoubleClick Zachodzi gdy kontrolka jest podwójnie kliknięta. Occurs when the control is double-clicked. Enter Zachodzi gdy kontrolka jest wybrana tabem. Occurs when the control is entered. GotFocus Zachodzi gdy kontrolka jest wybrana. Occurs when the control receives focus. KeyDown Zachodzi gdy przycisk klawiatury jest przyciskany i kontrolka jest wybrana. Occurs when a key is pressed while the control has focus. KeyPress Zachodzi gdy przycisk klawiatury jest naciśnięty i kontrolka jest wybrana Occurs when a key is pressed while the control has focus. KeyUp Zachodzi gdy przycisk klawiatury jest zwalniany i kontrolka jest wybrana. Occurs when a key is released while the control has focus. Leave Zachodzi gdy tab opuszcza kontrolkę. Occurs when the input focus leaves the control. LostFocus Zachodzi gdy kontrolkę jest opuszczana. Occurs when the control loses focus. MouseDown Zachodzi gdy kursor myszy jest na kontrolce i naciśnięty jest przycisk myszy. Occurs when the mouse pointer is over the control and a mouse button is pressed. MouseEnter Zachodzi gdy kursor myszy wchodzi na kontrolkę. Occurs when the mouse pointer enters the control. MouseHover Zachodzi gdy kursor myszy zawieszony nad kontrolką. Occurs when the mouse pointer hovers over the control. MouseLeave Zachodzi gdy kursor myszy wychodzi z kontrolki. Occurs when the mouse pointer leaves the control. MouseMove Zachodzi gdy kursor myszy jest poruszany na kontrolce. Occurs when the mouse pointer is moved over the control. MouseUp Zachodzi gdy kursor myszy jest na kontrolce i zwalniany jest przycisk myszy. Occurs when the mouse pointer is over the control and a mouse button is released. 5

Przykład. Zdarzenia Enter i Leave dla kontrolki TextBox. Private: void textbox1_enter( Object^ /*sender*/, System::EventArgs^ /*e*/ ) // Jeżeli w TextBox wpisany jest tekst, zmień kolor tła if ( textbox1->text!= String::Empty ) textbox1->forecolor = Color::Red; textbox1->backcolor = Color::Black; // przesuń kursor na koniec tekstu textbox1->select(textbox1->text->length,0); void textbox1_leave( Object^ /*sender*/, System::EventArgs^ /*e*/ ) // Powróć do poprzednich kolorów i elementu z listy wyboru po przejściu // tabem do innego obiektu textbox1->forecolor = Color::Black; textbox1->backcolor = Color::White; textbox1->select(0,0); W kodzie formatki należy dodać następujące void InitializeComponent(void) this-> textbox1_enter += gcnew System::EventHandler(this, &Form1::textBox1_Enter); this-> textbox1_leave += gcnew System::EventHandler(this, &Form1::textBox1_Leave); 6

6.5 Formatka z przyciskiem i polem tekstowym Plik Form1.h. #pragma once namespace AplikacjaWf using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form public: Form1(void) InitializeComponent(); protected: ~Form1() if (components) delete components; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::TextBox^ textbox1; private: System::Windows::Forms::Label^ label1; private: System::ComponentModel::Container ^components; 7

#pragma region Windows Form Designer generated code void InitializeComponent(void) this->button1 = (gcnew System::Windows::Forms::Button()); this->textbox1 = (gcnew System::Windows::Forms::TextBox()); this->label1 = (gcnew System::Windows::Forms::Label()); this->suspendlayout(); // button1 this->button1->location = System::Drawing::Point(173, 119); this->button1->name = L"button1"; this->button1->size = System::Drawing::Size(75, 23); this->button1->tabindex = 0; this->button1->text = L"Pokaz tekst"; this->button1->usevisualstylebackcolor = true; this->button1->click += gcnew System::EventHandler(this, &Form1::button1_Click); // textbox1 this->textbox1->location = System::Drawing::Point(38, 77); this->textbox1->name = L"textBox1"; this->textbox1->size = System::Drawing::Size(210, 20); this->textbox1->tabindex = 1; // label1 this->label1->autosize = true; this->label1->location = System::Drawing::Point(38, 58); this->label1->name = L"label1"; this->label1->size = System::Drawing::Size(65, 13); this->label1->tabindex = 2; this->label1->text = L"Wpisz tekst "; // Form1 this->autoscaledimensions = System::Drawing::SizeF(6, 13); this->autoscalemode = System::Windows::Forms::AutoScaleMode::Font; this->clientsize = System::Drawing::Size(292, 273); this->controls->add(this->label1); this->controls->add(this->textbox1); this->controls->add(this->button1); this->name = L"Form1"; this->text = L"Form1"; this->resumelayout(false); this->performlayout(); #pragma endregion private: System::Void button1_click(system::object^ sender, System::EventArgs^ e) String^ tekst = textbox1->text + "\n"; MessageBox::Show(tekst, "Wpisany tekst", MessageBoxButtons::OK, MessageBoxIcon::Information); ; 8

6.6 Wątki. Formatka z ProgressBar em Przykład pochodzi z książki R. Wileczek, Visual C++ 2005 Express Edition. Tworzenie aplikacji dla Windows, Helion, 2006. Etykiety dla ComboBox ów, ProgressBar ów należy wykonać na ćwiczeniach. Plik Form1.h nowe elementy. #pragma once namespace AplikacjaWf public ref class Form1 : public System::Windows::Forms::Form private: int postep1, postep2; public: Form1(void) InitializeComponent(); postep1 = postep2 = 0; protected: ~Form1()if (components) delete components; private: System::ComponentModel::BackgroundWorker^ bgworker1; private: System::ComponentModel::BackgroundWorker^ bgworker2; private: System::Windows::Forms::ComboBox^ cbczas1; private: System::Windows::Forms::ComboBox^ cbczas2; private: System::Windows::Forms::CheckBox^ checkwatek1; private: System::Windows::Forms::CheckBox^ checkwatek2; private: System::Windows::Forms::ProgressBar^ progresswatek1; private: System::Windows::Forms::ProgressBar^ progresswatek2; private: System::Windows::Forms::ErrorProvider^ err; private: System::ComponentModel::IContainer^ components; private: #pragma region Windows Form Designer generated code void InitializeComponent(void) this->components = (gcnew System::ComponentModel::Container()); this->bgworker1 = (gcnew System::ComponentModel::BackgroundWorker()); this->bgworker2 = (gcnew System::ComponentModel::BackgroundWorker()); this->cbczas1 = (gcnew System::Windows::Forms::ComboBox()); this->cbczas2 = (gcnew System::Windows::Forms::ComboBox()); this->checkwatek1 = (gcnew System::Windows::Forms::CheckBox()); this->checkwatek2 = (gcnew System::Windows::Forms::CheckBox()); this->progresswatek1 = (gcnew System::Windows::Forms::ProgressBar()); this->progresswatek2 = (gcnew System::Windows::Forms::ProgressBar()); this->err = (gcnew System::Windows::Forms::ErrorProvider(this->components)); (cli::safe_cast<system::componentmodel::isupportinitialize^ >(this->err))->begininit(); this->suspendlayout(); 9

// bgworker1 this->bgworker1->workerreportsprogress = true; this->bgworker1->workersupportscancellation = true; this->bgworker1->dowork += gcnew System::ComponentModel::DoWorkEventHandler(this, &Form1::bgWorker1_DoWork); // dodanie metody bgworker1_progresschanged() do eventu ProgressChanged this->bgworker1->progresschanged += gcnew System::ComponentModel::ProgressChangedEventHandler(this,Form1::bgWorker1_ProgressChanged); // bgworker2 // // cbczas1 this->cbczas1->dropdownstyle = System::Windows::Forms::ComboBoxStyle::DropDownList; this->cbczas1->formattingenabled = true; this->cbczas1->items->addrange(gcnew cli::array< System::Object^ >(3) L"100", L"200", L"300"); this->cbczas1->location = System::Drawing::Point(109, 6); this->cbczas1->name = L"cbCzas1"; this->cbczas1->size = System::Drawing::Size(121, 21); this->cbczas1->tabindex = 2; // cbczas2 // // checkwatek1 this->checkwatek1->autosize = true; this->checkwatek1->location = System::Drawing::Point(275, 8); this->checkwatek1->name = L"checkWatek1"; this->checkwatek1->size = System::Drawing::Size(129, 17); this->checkwatek1->tabindex = 4; this->checkwatek1->text = L"Uruchomiony wątek 1"; this->checkwatek1->usevisualstylebackcolor = true; this->checkwatek1->checkedchanged += gcnew System::EventHandler(this, &Form1::checkWatek1_CheckedChanged); // checkwatek2 // // progresswatek1 this->progresswatek1->location = System::Drawing::Point(15, 84); this->progresswatek1->name = L"progressWatek1"; this->progresswatek1->size = System::Drawing::Size(572, 23); this->progresswatek1->style = System::Windows::Forms::ProgressBarStyle::Continuous; this->progresswatek1->tabindex = 8; // progresswatek2 // // err this->err->containercontrol = this; // Form1 this->autoscaledimensions = System::Drawing::SizeF(6, 13); this->autoscalemode = System::Windows::Forms::AutoScaleMode::Font; this->clientsize = System::Drawing::Size(599, 162); this->controls->add(this->progresswatek2); this->controls->add(this->progresswatek1); this->controls->add(this->checkwatek2); this->controls->add(this->checkwatek1); this->controls->add(this->cbczas2); this->controls->add(this->cbczas1); this->name = L"Form1"; this->text = L"Wątki"; (cli::safe_cast<system::componentmodel::isupportinitialize^ >(this->err))->endinit(); this->resumelayout(false); this->performlayout(); #pragma endregion ; // koniec ref class Form1 // koniec namespace AplikacjaWf 10

Plik Form1.h - implementacje zdarzeń. // uruchom, zatrzymaj watek 1 private: System::Void checkwatek1_checkedchanged(system::object^ sender, System::EventArgs^ e) err->clear(); if (checkwatek1->checked) // CStringT::Trim, Trims all leading and trailing whitespace from the string. if (cbczas1->text->trim()->equals("")) checkwatek1->checked = false; err->seterror(cbczas1, "Wybierz czas"); else bgworker1->runworkerasync(system::convert::toint32(cbczas1->text)); else bgworker1->cancelasync(); // uruchom, zatrzymaj watek 2 private: System::Void checkwatek2_checkedchanged(system::object^ sender, System::EventArgs^ e) // // Worker 1 / DoWorkEventArgs class, provides data for the DoWork event handler. private: System::Void bgworker1_dowork(system::object^ sender, System::ComponentModel::DoWorkEventArgs^ e) BackgroundWorker^ worker = dynamic_cast<backgroundworker^>(sender); while (!bgworker1->cancellationpending) worker->reportprogress(postep1); postep1++; postep1 %= 100; System::Threading::Thread::Sleep(safe_cast<System::Int32>(e->Argument)); private: System::Void bgworker1_progresschanged(system::object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) progresswatek1->value = e->progresspercentage; // Worker 2 private: System::Void bgworker2_dowork(system::object^ sender, System::ComponentModel::DoWorkEventArgs^ e) // private: System::Void bgworker2_progresschanged(system::object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) // 11

6.7 Dodatek. Formatka z przyciskiem i polem tekstowym w języku C# Struktura i zawartość plików projektu Plik: Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace AplikacjaWF public partial class Formatka1 : Form public Formatka1() InitializeComponent(); 12

plik: Form1.Designer.cs namespace AplikacjaWF using System; using System.Windows.Forms; //using System.Drawing; partial class Formatka1 /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) if (disposing && (components!= null)) components.dispose(); base.dispose(disposing); #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() this.przycisk1 = new System.Windows.Forms.Button(); this.poletekstowe1 = new System.Windows.Forms.TextBox(); this.suspendlayout(); // // przycisk1 // this.przycisk1.location = new System.Drawing.Point(145, 165); this.przycisk1.name = "przycisk1"; this.przycisk1.size = new System.Drawing.Size(104, 23); this.przycisk1.tabindex = 0; this.przycisk1.text = "Naciśnij mnie"; this.przycisk1.usevisualstylebackcolor = true; przycisk1.click += new System.EventHandler(przycisk1_Click); // // poletekstowe1 // this.poletekstowe1.location = new System.Drawing.Point(40, 52); this.poletekstowe1.name = "poletekstowe1"; this.poletekstowe1.size = new System.Drawing.Size(209, 20); this.poletekstowe1.tabindex = 1; this.poletekstowe1.text = "Wpisz tekst"; // // Formatka1 // 13

Programowanie 2. Język C++. Wykład 6. this.autoscaledimensions = new System.Drawing.SizeF(6F, 13F); this.autoscalemode = System.Windows.Forms.AutoScaleMode.Font; this.clientsize = new System.Drawing.Size(284, 261); this.controls.add(this.poletekstowe1); this.controls.add(this.przycisk1); this.name = "Formatka1"; this.text = "Formatka "; this.resumelayout(false); this.performlayout(); private void przycisk1_click(object sender, EventArgs evargs) MessageBox.Show("Wpisałeś: '" + poletekstowe1.text + "'"); #endregion private System.Windows.Forms.Button przycisk1; private System.Windows.Forms.TextBox poletekstowe1; 14