Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
бдз с++.docx
Скачиваний:
35
Добавлен:
10.05.2014
Размер:
724.77 Кб
Скачать

3 Практическое решение и обоснование программы

Данная задача решена следующим образом: на C++ с использованием Visual Studio 2010 была написана программа, которая получает данные от пользователя в файле с расширением .txt и помещает из них данные в поле textbox, после нажатия кнопки «Выполнить расчет» запускается алгоритм расчета необходимых параметров: радиусы вписанной и описанной окружностей, площадь и периметр треугольника. После этого программа по полученным данным выполняет построение фигур на координатной плоскости. При необходимости все полученные данные можно сохранить в файл с расширением .txt. При нажатии на клавишу «О программе» выводится окно с данными о программе и команде разработчиков.

Рисунок 1 – Пример входных данных.

Рисунок 2 – Процесс работы программы

Рисунок 3- Пример выходных данных

Заключение

В данной работе требовалось написать программу на C++ по выполнению операций описанных в задании.

По введенным данным были построены необходимые геометрические фигуры и данные, являющиеся результатом работы программы, были сохранены в файл. Корректность работы программы была проверена с помощью тестовых расчетов. Тесты показали, что программа работает корректно и без ошибок. К недостаткам можно отнести то, что данная программа строит графики только на плоскости и только для значений, расположенных в определенной структуре в файле c расширением .txt.

Список использованных источников

1. http://bigcamagan.narod.ru/ - сайт с примерами программ на С++.

2. http://www.wikipedia.org – Энциклопедия.

Приложение а

Файл Form1.h

#pragma once

#include <math.h>

#include <fstream>

#include "about.h"

#include "about_programm.h"

namespace troll {

using namespace System::IO;

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

using namespace System::Text;

double AX,AY,BX,BY,CX,CY;

double L12,L23,L13;

double p,S,R,r;

int predohranitel=0;

int predohranitelRachet=0;

/// <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 ref class Form1 : public System::Windows::Forms::Form

{

public:

public:

public:

public:

Form1(void)

{

InitializeComponent();

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::MenuStrip^ GlavnoeMenu;

private: System::Windows::Forms::ToolStripMenuItem^ FileTab;

private: System::Windows::Forms::ToolStripMenuItem^ OpenTab;

private: System::Windows::Forms::ToolStripMenuItem^ SaveTab;

protected:

protected:

private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;

private: System::Windows::Forms::SaveFileDialog^ saveFileDialog1;

private: System::Windows::Forms::StatusStrip^ Nignaistr;

private: System::Windows::Forms::ToolStripStatusLabel^ Metkastatysa;

private: System::Windows::Forms::ToolStripProgressBar^ Statys;

private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel1;

private: System::Windows::Forms::ToolStripSeparator^ toolStripMenuItem1;

private: System::Windows::Forms::ToolStripMenuItem^ ExitTab;

private: System::Windows::Forms::ToolStripMenuItem^ ToolsTab;

private: System::Windows::Forms::ToolStripMenuItem^ CountTab;

private: System::Windows::Forms::ToolStripMenuItem^ CharacterTab;

private: System::Windows::Forms::ToolStrip^ toolStrip1;

private: System::Windows::Forms::ToolStripButton^ toolStripButton1;

private: System::Windows::Forms::ToolStripMenuItem^ оПрограммеToolStripMenuItem;

private: System::Windows::Forms::PictureBox^ pictureBox1;

private: System::Windows::Forms::ToolStripButton^ toolStripButton2;

private: System::Windows::Forms::ToolStripButton^ toolStripButton3;

private: System::Windows::Forms::ToolStrip^ toolStrip2;

private: System::Windows::Forms::ToolStripButton^ toolStripButton4;

private: System::Windows::Forms::ToolStripButton^ toolStripButton5;

private: System::Windows::Forms::ToolStrip^ toolStrip3;

private: System::Windows::Forms::ToolStripButton^ toolStripButton6;

private:

/// <summary>

/// Required designer variable.

/// </summary>

System::ComponentModel::Container ^components;

#pragma 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>

void InitializeComponent(void)

{

System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));

this->GlavnoeMenu = (gcnew System::Windows::Forms::MenuStrip());

this->FileTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->OpenTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->SaveTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());

this->ExitTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->ToolsTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->CountTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->CharacterTab = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->оПрограммеToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());

this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());

this->Nignaistr = (gcnew System::Windows::Forms::StatusStrip());

this->Metkastatysa = (gcnew System::Windows::Forms::ToolStripStatusLabel());

this->Statys = (gcnew System::Windows::Forms::ToolStripProgressBar());

this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());

this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());

this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());

this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());

this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());

this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());

this->toolStrip2 = (gcnew System::Windows::Forms::ToolStrip());

this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton());

this->toolStripButton5 = (gcnew System::Windows::Forms::ToolStripButton());

this->toolStrip3 = (gcnew System::Windows::Forms::ToolStrip());

this->toolStripButton6 = (gcnew System::Windows::Forms::ToolStripButton());

this->GlavnoeMenu->SuspendLayout();

this->Nignaistr->SuspendLayout();

this->toolStrip1->SuspendLayout();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();

this->toolStrip2->SuspendLayout();

this->toolStrip3->SuspendLayout();

this->SuspendLayout();

//

// GlavnoeMenu

//

this->GlavnoeMenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->FileTab, this->ToolsTab,

this->оПрограммеToolStripMenuItem});

this->GlavnoeMenu->Location = System::Drawing::Point(0, 0);

this->GlavnoeMenu->Name = L"GlavnoeMenu";

this->GlavnoeMenu->Size = System::Drawing::Size(700, 24);

this->GlavnoeMenu->TabIndex = 0;

this->GlavnoeMenu->Text = L"menuStrip1";

this->GlavnoeMenu->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::GlavnoeMenu_ItemClicked);

//

// FileTab

//

this->FileTab->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->OpenTab, this->SaveTab,

this->toolStripMenuItem1, this->ExitTab});

this->FileTab->Name = L"FileTab";

this->FileTab->ShortcutKeyDisplayString = L"";

this->FileTab->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::F));

this->FileTab->Size = System::Drawing::Size(48, 20);

this->FileTab->Text = L"&Файл";

this->FileTab->Click += gcnew System::EventHandler(this, &Form1::FileTab_Click);

//

// OpenTab

//

this->OpenTab->Name = L"OpenTab";

this->OpenTab->ShortcutKeyDisplayString = L"Ctrl+O";

this->OpenTab->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));

this->OpenTab->Size = System::Drawing::Size(172, 22);

this->OpenTab->Text = L"&Открыть";

this->OpenTab->Click += gcnew System::EventHandler(this, &Form1::Opentab_Click);

//

// SaveTab

//

this->SaveTab->Name = L"SaveTab";

this->SaveTab->ShortcutKeyDisplayString = L"Ctrl+S";

this->SaveTab->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));

this->SaveTab->Size = System::Drawing::Size(172, 22);

this->SaveTab->Text = L"&Сохранить";

this->SaveTab->Click += gcnew System::EventHandler(this, &Form1::SaveTab_Click);

//

// toolStripMenuItem1

//

this->toolStripMenuItem1->Name = L"toolStripMenuItem1";

this->toolStripMenuItem1->Size = System::Drawing::Size(169, 6);

//

// ExitTab

//

this->ExitTab->Name = L"ExitTab";

this->ExitTab->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::End));

this->ExitTab->Size = System::Drawing::Size(172, 22);

this->ExitTab->Text = L"&Выход";

this->ExitTab->Click += gcnew System::EventHandler(this, &Form1::ExitTab_Click);

//

// ToolsTab

//

this->ToolsTab->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->CountTab, this->CharacterTab});

this->ToolsTab->Name = L"ToolsTab";

this->ToolsTab->Size = System::Drawing::Size(95, 20);

this->ToolsTab->Text = L"&Инструменты";

//

// CountTab

//

this->CountTab->Name = L"CountTab";

this->CountTab->ShortcutKeys = System::Windows::Forms::Keys::F7;

this->CountTab->Size = System::Drawing::Size(195, 22);

this->CountTab->Text = L"&Выполнить расчёт";

this->CountTab->Click += gcnew System::EventHandler(this, &Form1::CountTab_Click);

//

// CharacterTab

//

this->CharacterTab->Name = L"CharacterTab";

this->CharacterTab->ShortcutKeys = System::Windows::Forms::Keys::F5;

this->CharacterTab->Size = System::Drawing::Size(195, 22);

this->CharacterTab->Text = L"Ха&рактеристики";

this->CharacterTab->Click += gcnew System::EventHandler(this, &Form1::ToolsTab_Click);

//

// оПрограммеToolStripMenuItem

//

this->оПрограммеToolStripMenuItem->Name = L"оПрограммеToolStripMenuItem";

this->оПрограммеToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::H));

this->оПрограммеToolStripMenuItem->Size = System::Drawing::Size(94, 20);

this->оПрограммеToolStripMenuItem->Text = L"&О программе";

this->оПрограммеToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::оПрограммеToolStripMenuItem_Click);

//

// openFileDialog1

//

this->openFileDialog1->FileName = L"openFileDialog1";

//

// Nignaistr

//

this->Nignaistr->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->Metkastatysa, this->Statys,

this->toolStripStatusLabel1});

this->Nignaistr->Location = System::Drawing::Point(0, 452);

this->Nignaistr->Name = L"Nignaistr";

this->Nignaistr->Size = System::Drawing::Size(700, 22);

this->Nignaistr->TabIndex = 7;

this->Nignaistr->Text = L"statusStrip1";

this->Nignaistr->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::Nignaistr_ItemClicked);

//

// Metkastatysa

//

this->Metkastatysa->Name = L"Metkastatysa";

this->Metkastatysa->Size = System::Drawing::Size(0, 17);

//

// Statys

//

this->Statys->Margin = System::Windows::Forms::Padding(0);

this->Statys->Name = L"Statys";

this->Statys->Size = System::Drawing::Size(100, 22);

//

// toolStripStatusLabel1

//

this->toolStripStatusLabel1->Margin = System::Windows::Forms::Padding(0);

this->toolStripStatusLabel1->Name = L"toolStripStatusLabel1";

this->toolStripStatusLabel1->Size = System::Drawing::Size(64, 22);

this->toolStripStatusLabel1->Text = L"Ожидание";

//

// toolStrip1

//

this->toolStrip1->Dock = System::Windows::Forms::DockStyle::None;

this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->toolStripButton1,

this->toolStripButton2, this->toolStripButton3});

this->toolStrip1->Location = System::Drawing::Point(0, 24);

this->toolStrip1->Name = L"toolStrip1";

this->toolStrip1->Size = System::Drawing::Size(81, 25);

this->toolStrip1->TabIndex = 8;

this->toolStrip1->Text = L"toolStrip1";

//

// toolStripButton1

//

this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^ >(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"toolStripButton1";

this->toolStripButton1->Click += gcnew System::EventHandler(this, &Form1::Opentab_Click);

//

// toolStripButton2

//

this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton2.Image")));

this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;

this->toolStripButton2->Name = L"toolStripButton2";

this->toolStripButton2->Size = System::Drawing::Size(23, 22);

this->toolStripButton2->Text = L"toolStripButton2";

this->toolStripButton2->Click += gcnew System::EventHandler(this, &Form1::SaveTab_Click);

//

// toolStripButton3

//

this->toolStripButton3->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton3.Image")));

this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;

this->toolStripButton3->Name = L"toolStripButton3";

this->toolStripButton3->Size = System::Drawing::Size(23, 22);

this->toolStripButton3->Text = L"toolStripButton3";

this->toolStripButton3->Click += gcnew System::EventHandler(this, &Form1::ExitTab_Click);

//

// pictureBox1

//

this->pictureBox1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.BackgroundImage")));

this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));

this->pictureBox1->Location = System::Drawing::Point(0, 52);

this->pictureBox1->Name = L"pictureBox1";

this->pictureBox1->Size = System::Drawing::Size(700, 400);

this->pictureBox1->TabIndex = 5;

this->pictureBox1->TabStop = false;

this->pictureBox1->Click += gcnew System::EventHandler(this, &Form1::pictureBox1_Click);

//

// toolStrip2

//

this->toolStrip2->Dock = System::Windows::Forms::DockStyle::None;

this->toolStrip2->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->toolStripButton4,

this->toolStripButton5});

this->toolStrip2->Location = System::Drawing::Point(171, 24);

this->toolStrip2->Name = L"toolStrip2";

this->toolStrip2->Size = System::Drawing::Size(58, 25);

this->toolStrip2->TabIndex = 9;

this->toolStrip2->Text = L"toolStrip2";

//

// toolStripButton4

//

this->toolStripButton4->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton4.Image")));

this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Magenta;

this->toolStripButton4->Name = L"toolStripButton4";

this->toolStripButton4->Size = System::Drawing::Size(23, 22);

this->toolStripButton4->Text = L"toolStripButton4";

this->toolStripButton4->Click += gcnew System::EventHandler(this, &Form1::CountTab_Click);

//

// toolStripButton5

//

this->toolStripButton5->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton5->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton5.Image")));

this->toolStripButton5->ImageTransparentColor = System::Drawing::Color::Magenta;

this->toolStripButton5->Name = L"toolStripButton5";

this->toolStripButton5->Size = System::Drawing::Size(23, 22);

this->toolStripButton5->Text = L"toolStripButton5";

this->toolStripButton5->Click += gcnew System::EventHandler(this, &Form1::ToolsTab_Click);

//

// toolStrip3

//

this->toolStrip3->Dock = System::Windows::Forms::DockStyle::None;

this->toolStrip3->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->toolStripButton6});

this->toolStrip3->Location = System::Drawing::Point(286, 24);

this->toolStrip3->Name = L"toolStrip3";

this->toolStrip3->Size = System::Drawing::Size(35, 25);

this->toolStrip3->TabIndex = 10;

this->toolStrip3->Text = L"toolStrip3";

//

// toolStripButton6

//

this->toolStripButton6->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;

this->toolStripButton6->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton6.Image")));

this->toolStripButton6->ImageTransparentColor = System::Drawing::Color::Magenta;

this->toolStripButton6->Name = L"toolStripButton6";

this->toolStripButton6->Size = System::Drawing::Size(23, 22);

this->toolStripButton6->Text = L"toolStripButton6";

this->toolStripButton6->Click += gcnew System::EventHandler(this, &Form1::оПрограммеToolStripMenuItem_Click);

//

// Form1

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(700, 474);

this->Controls->Add(this->toolStrip3);

this->Controls->Add(this->toolStrip2);

this->Controls->Add(this->toolStrip1);

this->Controls->Add(this->Nignaistr);

this->Controls->Add(this->pictureBox1);

this->Controls->Add(this->GlavnoeMenu);

this->MainMenuStrip = this->GlavnoeMenu;

this->MaximumSize = System::Drawing::Size(716, 512);

this->Name = L"Form1";

this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;

this->Text = L"Расчёт треугольника";

this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);

this->GlavnoeMenu->ResumeLayout(false);

this->GlavnoeMenu->PerformLayout();

this->Nignaistr->ResumeLayout(false);

this->Nignaistr->PerformLayout();

this->toolStrip1->ResumeLayout(false);

this->toolStrip1->PerformLayout();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();

this->toolStrip2->ResumeLayout(false);

this->toolStrip2->PerformLayout();

this->toolStrip3->ResumeLayout(false);

this->toolStrip3->PerformLayout();

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void Opentab_Click(System::Object^ sender, System::EventArgs^ e) {

predohranitel=0;

predohranitelRachet=0;

predohranitelRachet++;

System::String ^text;

OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;

openFileDialog1->Filter = "txt files (*.txt)|*.txt";

if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )

{

String^ s;

s = openFileDialog1->FileName;

StreamReader^ sr = gcnew StreamReader( s );

for (int i = 0 ; i<6 ; i++)

{

Statys->Value = 20*i;

text = sr->ReadLine();

if (i == 0)

{ AX = Convert::ToDouble(text);}

if (i == 1)

{ AY = Convert::ToDouble(text);}

if (i == 2)

{ BX = Convert::ToDouble(text);}

if (i == 3)

{ BY = Convert::ToDouble(text);}

if (i == 4)

{ CX = Convert::ToDouble(text);}

if (i == 5)

{ CY = Convert::ToDouble(text);}

}

toolStripStatusLabel1->Text = "Данные загружены";

sr->Close();

}

pictureBox1->Refresh();

}

private: System::Void richTextBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void progressBar1_Click(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void toolStripProgressBar1_Click(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void Nignaistr_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) {

}

private: System::Void FileTab_Click(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void ExitTab_Click(System::Object^ sender, System::EventArgs^ e) {

Form1::Close();

}

private: System::Void ToolsTab_Click(System::Object^ sender, System::EventArgs^ e) {

if (predohranitel == 1){

about^ NewForm;

NewForm = gcnew about();

NewForm->PloshTreyg->Text = S.ToString("00.0");

NewForm->PerimTreyg->Text = p.ToString("00.0");

NewForm->RadiusOpis->Text = R.ToString("00.0");

NewForm->RadiusVpis->Text = r.ToString("00.0");

NewForm->ShowDialog();

}

else{

MessageBox::Show( "Вы ещё не произвели необходимые расчёты", "Ошибка вывода информации",MessageBoxButtons::OK, MessageBoxIcon::Exclamation );

}

}

private: System::Void CountTab_Click(System::Object^ sender, System::EventArgs^ e) {

if (predohranitelRachet == 1){

toolStripStatusLabel1->Text = "Идёт процесс обработки...";

Statys->Value = 0;

int ax = Convert::ToInt32(AX);

int ay = Convert::ToInt32(AY*(-1));

int bx = Convert::ToInt32(BX);

int by = Convert::ToInt32(BY*(-1));

int cx = Convert::ToInt32(CX);

int cy = Convert::ToInt32(CY*(-1));

Statys->Value = 10;

Point point1 = Point(ax,ay);

Point point2 = Point(bx,by);

Point point3 = Point(cx,cy);

array<Point>^ curvePoints = {point1,point2,point3};

Statys->Value = 20;

L12 = sqrt((AX - BX)*(AX - BX) + (AY - BY)*(AY - BY));

L23 = sqrt((BX - CX)*(BX - CX) + (BY - CY)*(BY - CY));

L13 = sqrt((CX - AX)*(CX - AX) + (CY - AY)*(CY - AY));

double y0 = (L23 * AY + L13 * BY + L12 * CY) / (L23 + L13 + L12);

double x0 = (L23 * AX + L13 * BX + L12 * CX) / (L23 + L13 + L12);

Statys->Value = 30;

p = (L12+L23+L13)/2;

S = sqrt((p*(p-L12)*(p-L23)*(p-L13)));

r = (S/p);

R = (L12*L23*L13/(4*S));

Statys->Value = 40;

double X0=((AX*AX+AY*AY)*(BY-CY)-AY*(BX*BX+BY*BY-CX*CX-CY*CY)+CY*(BX*BX+BY*BY)-BY*(CX*CX+CY*CY))/((-4)*S);

double Y0=((AX*AX+AY*AY)*(BX-CX)-AX*(BX*BX+BY*BY-CX*CX-CY*CY)+CX*(BX*BX+BY*BY)-BX*(CX*CX-CY*CY))/((4)*S);

Statys->Value = 50;

int rr = Convert::ToInt32(r);

int x00 = Convert::ToInt32(x0);

int y00 = Convert::ToInt32(y0*(-1));

int RR = Convert::ToInt32(R);

int X00 = Convert::ToInt32(X0*(-1));

int Y00 = Convert::ToInt32(Y0);

Statys->Value = 60;

Pen^ fatbluePen = gcnew Pen( Color::Blue,3.0f );

Pen^ fatgreenPen = gcnew Pen( Color::Green,3.0f );

Pen^ greenPen = gcnew Pen( Color::Green,2.0f );

Pen^ redPen = gcnew Pen( Color::Red,5.0f );

Statys->Value = 80;

Graphics^ g = pictureBox1->CreateGraphics();

g->TranslateTransform(350,200);

g->DrawPolygon( fatbluePen, curvePoints);

g->DrawEllipse(fatgreenPen,x00-rr,y00-rr,rr*2,rr*2);

g->DrawEllipse(greenPen,X00-RR,Y00-RR,RR*2,RR*2);

g->DrawEllipse(redPen, ax,ay, 1,1);

g->DrawEllipse(redPen, bx,by, 1,1);

g->DrawEllipse(redPen, cx,cy, 1,1);

Statys->Value = 100;

toolStripStatusLabel1->Text = "Готово!";

predohranitel++; }

else{ MessageBox::Show( "Вы ещё не указали значения координат!", "Ошибка вывода информации",MessageBoxButtons::OK, MessageBoxIcon::Exclamation );

}

}

private: System::Void SaveTab_Click(System::Object^ sender, System::EventArgs^ e) {

toolStripStatusLabel1->Text = "Cохранение";

Statys->Value = 0;

SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;

saveFileDialog1->Filter = "txt files (*.txt)|*.txt";

if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )

{

Statys->Value = 30;

String^ s;

s = saveFileDialog1->FileName;

StreamWriter^ sw = gcnew StreamWriter(s);

Statys->Value = 50;

sw->WriteLine("Площадь треугольника: " + S.ToString("00.0"));

sw->WriteLine("Периметр треугольника: " + p.ToString("00.0"));

sw->WriteLine("Радиус описанной окружности: " + R.ToString("00.0"));

sw->WriteLine("Радиус вписанной Окружности: " + r.ToString("00.0"));

sw->Close();

Statys->Value = 100;

}

toolStripStatusLabel1->Text = "Вывод завершён";

predohranitelRachet++;

}

private: System::Void toolStripButton1_Click(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void GlavnoeMenu_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) {

}

private: System::Void оПрограммеToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {

about_programm^ NewForm;

NewForm = gcnew about_programm();

NewForm->ShowDialog();

}

};

}

Файл about.h

#pragma once

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

namespace troll {

/// <summary>

/// Summary for about

///

/// 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 ref class about : public System::Windows::Forms::Form

{

public:

about(void)

{

InitializeComponent();

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~about()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Button^ knopkaClose;

public: System::Windows::Forms::Label^ PloshTreyg;

private:

private: System::Windows::Forms::Label^ MetkaPloshTreyg;

public:

private: System::Windows::Forms::Label^ MetkaPerimTreyg;

private: System::Windows::Forms::Label^ MetkaRadiusOpis;

private: System::Windows::Forms::Label^ MetkaRadiusМpis;

public: System::Windows::Forms::Label^ PerimTreyg;

public: System::Windows::Forms::Label^ RadiusOpis;

public: System::Windows::Forms::Label^ RadiusVpis;

private:

private:

public:

private: System::ComponentModel::IContainer^ components;

public:

public:

protected:

protected:

protected:

private:

/// <summary>

/// Required designer variable.

/// </summary>

#pragma 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>

void InitializeComponent(void)

{

this->knopkaClose = (gcnew System::Windows::Forms::Button());

this->PloshTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaPloshTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaPerimTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaRadiusOpis = (gcnew System::Windows::Forms::Label());

this->MetkaRadiusМpis = (gcnew System::Windows::Forms::Label());

this->PerimTreyg = (gcnew System::Windows::Forms::Label());

this->RadiusOpis = (gcnew System::Windows::Forms::Label());

this->RadiusVpis = (gcnew System::Windows::Forms::Label());

this->SuspendLayout();

//

// knopkaClose

//

this->knopkaClose->Location = System::Drawing::Point(75, 197);

this->knopkaClose->Name = L"knopkaClose";

this->knopkaClose->Size = System::Drawing::Size(121, 24);

this->knopkaClose->TabIndex = 1;

this->knopkaClose->Text = L"Закрыть";

this->knopkaClose->UseVisualStyleBackColor = true;

this->knopkaClose->Click += gcnew System::EventHandler(this, &about::knopkaClose_Click);

//

// PloshTreyg

//

this->PloshTreyg->Location = System::Drawing::Point(155, 47);

this->PloshTreyg->Name = L"PloshTreyg";

this->PloshTreyg->Size = System::Drawing::Size(68, 14);

this->PloshTreyg->TabIndex = 2;

this->PloshTreyg->Click += gcnew System::EventHandler(this, &about::label1_Click);

//

// MetkaPloshTreyg

//

this->MetkaPloshTreyg->AutoSize = true;

this->MetkaPloshTreyg->Location = System::Drawing::Point(20, 48);

this->MetkaPloshTreyg->Name = L"MetkaPloshTreyg";

this->MetkaPloshTreyg->Size = System::Drawing::Size(129, 13);

this->MetkaPloshTreyg->TabIndex = 3;

this->MetkaPloshTreyg->Text = L"Площадь треугольника:";

//

// MetkaPerimTreyg

//

this->MetkaPerimTreyg->AutoSize = true;

this->MetkaPerimTreyg->Location = System::Drawing::Point(20, 85);

this->MetkaPerimTreyg->Name = L"MetkaPerimTreyg";

this->MetkaPerimTreyg->Size = System::Drawing::Size(133, 13);

this->MetkaPerimTreyg->TabIndex = 4;

this->MetkaPerimTreyg->Text = L"Периметр треугольника:";

//

// MetkaRadiusOpis

//

this->MetkaRadiusOpis->AutoSize = true;

this->MetkaRadiusOpis->Location = System::Drawing::Point(21, 120);

this->MetkaRadiusOpis->Name = L"MetkaRadiusOpis";

this->MetkaRadiusOpis->Size = System::Drawing::Size(166, 13);

this->MetkaRadiusOpis->TabIndex = 5;

this->MetkaRadiusOpis->Text = L"Радиус описанной окружности:";

//

// MetkaRadiusМpis

//

this->MetkaRadiusМpis->AutoSize = true;

this->MetkaRadiusМpis->Location = System::Drawing::Point(20, 154);

this->MetkaRadiusМpis->Name = L"MetkaRadiusМpis";

this->MetkaRadiusМpis->Size = System::Drawing::Size(166, 13);

this->MetkaRadiusМpis->TabIndex = 6;

this->MetkaRadiusМpis->Text = L"Радиус вписанной окружности:";

//

// PerimTreyg

//

this->PerimTreyg->AutoSize = true;

this->PerimTreyg->Location = System::Drawing::Point(159, 85);

this->PerimTreyg->Name = L"PerimTreyg";

this->PerimTreyg->Size = System::Drawing::Size(0, 13);

this->PerimTreyg->TabIndex = 7;

//

// RadiusOpis

//

this->RadiusOpis->AutoSize = true;

this->RadiusOpis->Location = System::Drawing::Point(193, 120);

this->RadiusOpis->Name = L"RadiusOpis";

this->RadiusOpis->Size = System::Drawing::Size(0, 13);

this->RadiusOpis->TabIndex = 8;

//

// RadiusVpis

//

this->RadiusVpis->AutoSize = true;

this->RadiusVpis->Location = System::Drawing::Point(192, 154);

this->RadiusVpis->Name = L"RadiusVpis";

this->RadiusVpis->Size = System::Drawing::Size(0, 13);

this->RadiusVpis->TabIndex = 9;

//

// about

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(284, 262);

this->Controls->Add(this->RadiusVpis);

this->Controls->Add(this->RadiusOpis);

this->Controls->Add(this->PerimTreyg);

this->Controls->Add(this->MetkaRadiusМpis);

this->Controls->Add(this->MetkaRadiusOpis);

this->Controls->Add(this->MetkaPerimTreyg);

this->Controls->Add(this->MetkaPloshTreyg);

this->Controls->Add(this->knopkaClose);

this->Controls->Add(this->PloshTreyg);

this->MaximumSize = System::Drawing::Size(300, 300);

this->MinimumSize = System::Drawing::Size(300, 300);

this->Name = L"about";

this->Text = L"about";

this->Load += gcnew System::EventHandler(this, &about::about_Load);

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

private: System::Void about_Load(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void knopkaClose_Click(System::Object^ sender, System::EventArgs^ e) {

about::Close();

}

private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {

}

};

}

Файл about_programm.h

#pragma once

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

namespace troll {

/// <summary>

/// Summary for about

///

/// 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 ref class about : public System::Windows::Forms::Form

{

public:

about(void)

{

InitializeComponent();

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~about()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Button^ knopkaClose;

public: System::Windows::Forms::Label^ PloshTreyg;

private:

private: System::Windows::Forms::Label^ MetkaPloshTreyg;

public:

private: System::Windows::Forms::Label^ MetkaPerimTreyg;

private: System::Windows::Forms::Label^ MetkaRadiusOpis;

private: System::Windows::Forms::Label^ MetkaRadiusМpis;

public: System::Windows::Forms::Label^ PerimTreyg;

public: System::Windows::Forms::Label^ RadiusOpis;

public: System::Windows::Forms::Label^ RadiusVpis;

private:

private:

public:

private: System::ComponentModel::IContainer^ components;

public:

public:

protected:

protected:

protected:

private:

/// <summary>

/// Required designer variable.

/// </summary>

#pragma 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>

void InitializeComponent(void)

{

this->knopkaClose = (gcnew System::Windows::Forms::Button());

this->PloshTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaPloshTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaPerimTreyg = (gcnew System::Windows::Forms::Label());

this->MetkaRadiusOpis = (gcnew System::Windows::Forms::Label());

this->MetkaRadiusМpis = (gcnew System::Windows::Forms::Label());

this->PerimTreyg = (gcnew System::Windows::Forms::Label());

this->RadiusOpis = (gcnew System::Windows::Forms::Label());

this->RadiusVpis = (gcnew System::Windows::Forms::Label());

this->SuspendLayout();

//

// knopkaClose

//

this->knopkaClose->Location = System::Drawing::Point(75, 197);

this->knopkaClose->Name = L"knopkaClose";

this->knopkaClose->Size = System::Drawing::Size(121, 24);

this->knopkaClose->TabIndex = 1;

this->knopkaClose->Text = L"Закрыть";

this->knopkaClose->UseVisualStyleBackColor = true;

this->knopkaClose->Click += gcnew System::EventHandler(this, &about::knopkaClose_Click);

//

// PloshTreyg

//

this->PloshTreyg->Location = System::Drawing::Point(155, 47);

this->PloshTreyg->Name = L"PloshTreyg";

this->PloshTreyg->Size = System::Drawing::Size(68, 14);

this->PloshTreyg->TabIndex = 2;

this->PloshTreyg->Click += gcnew System::EventHandler(this, &about::label1_Click);

//

// MetkaPloshTreyg

//

this->MetkaPloshTreyg->AutoSize = true;

this->MetkaPloshTreyg->Location = System::Drawing::Point(20, 48);

this->MetkaPloshTreyg->Name = L"MetkaPloshTreyg";

this->MetkaPloshTreyg->Size = System::Drawing::Size(129, 13);

this->MetkaPloshTreyg->TabIndex = 3;

this->MetkaPloshTreyg->Text = L"Площадь треугольника:";

//

// MetkaPerimTreyg

//

this->MetkaPerimTreyg->AutoSize = true;

this->MetkaPerimTreyg->Location = System::Drawing::Point(20, 85);

this->MetkaPerimTreyg->Name = L"MetkaPerimTreyg";

this->MetkaPerimTreyg->Size = System::Drawing::Size(133, 13);

this->MetkaPerimTreyg->TabIndex = 4;

this->MetkaPerimTreyg->Text = L"Периметр треугольника:";

//

// MetkaRadiusOpis

//

this->MetkaRadiusOpis->AutoSize = true;

this->MetkaRadiusOpis->Location = System::Drawing::Point(21, 120);

this->MetkaRadiusOpis->Name = L"MetkaRadiusOpis";

this->MetkaRadiusOpis->Size = System::Drawing::Size(166, 13);

this->MetkaRadiusOpis->TabIndex = 5;

this->MetkaRadiusOpis->Text = L"Радиус описанной окружности:";

//

// MetkaRadiusМpis

//

this->MetkaRadiusМpis->AutoSize = true;

this->MetkaRadiusМpis->Location = System::Drawing::Point(20, 154);

this->MetkaRadiusМpis->Name = L"MetkaRadiusМpis";

this->MetkaRadiusМpis->Size = System::Drawing::Size(166, 13);

this->MetkaRadiusМpis->TabIndex = 6;

this->MetkaRadiusМpis->Text = L"Радиус вписанной окружности:";

//

// PerimTreyg

//

this->PerimTreyg->AutoSize = true;

this->PerimTreyg->Location = System::Drawing::Point(159, 85);

this->PerimTreyg->Name = L"PerimTreyg";

this->PerimTreyg->Size = System::Drawing::Size(0, 13);

this->PerimTreyg->TabIndex = 7;

//

// RadiusOpis

//

this->RadiusOpis->AutoSize = true;

this->RadiusOpis->Location = System::Drawing::Point(193, 120);

this->RadiusOpis->Name = L"RadiusOpis";

this->RadiusOpis->Size = System::Drawing::Size(0, 13);

this->RadiusOpis->TabIndex = 8;

//

// RadiusVpis

//

this->RadiusVpis->AutoSize = true;

this->RadiusVpis->Location = System::Drawing::Point(192, 154);

this->RadiusVpis->Name = L"RadiusVpis";

this->RadiusVpis->Size = System::Drawing::Size(0, 13);

this->RadiusVpis->TabIndex = 9;

//

// about

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(284, 262);

this->Controls->Add(this->RadiusVpis);

this->Controls->Add(this->RadiusOpis);

this->Controls->Add(this->PerimTreyg);

this->Controls->Add(this->MetkaRadiusМpis);

this->Controls->Add(this->MetkaRadiusOpis);

this->Controls->Add(this->MetkaPerimTreyg);

this->Controls->Add(this->MetkaPloshTreyg);

this->Controls->Add(this->knopkaClose);

this->Controls->Add(this->PloshTreyg);

this->MaximumSize = System::Drawing::Size(300, 300);

this->MinimumSize = System::Drawing::Size(300, 300);

this->Name = L"about";

this->Text = L"about";

this->Load += gcnew System::EventHandler(this, &about::about_Load);

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

private: System::Void about_Load(System::Object^ sender, System::EventArgs^ e) {

}

private: System::Void knopkaClose_Click(System::Object^ sender, System::EventArgs^ e) {

about::Close();

}

private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {

}

};

}

35

Соседние файлы в предмете Информатика