
- •Введение
- •Постановка задачи
- •Разработка технического задания
- •2.1 Анализ вариантов использования программы
- •Потоки событий
- •Основной поток
- •2.2. Альтернативные потоки
- •2.2 Требования к приложениям
- •Анализ алгоритма решения задачи
- •3.1 Метод Монте-Карло
- •3.2 Определение попадания точки внутрь трапеции
- •Настольное приложение wpf
- •4.1 Технология Windows Presentation Foundation
- •4.2 Логическое проектирование приложения
- •4.3 Тестирование приложения
- •5.1 Программные средства для разработки приложения
- •5.2 Логическое проектирование
- •5.2.1 Структура приложения
- •5.2.2 Проектирование приложения.
- •Листинг №1. Определение попадания точки в четырехугольник. HaXe.
- •6. Клиент-Серверное приложение на базе asp.Net
- •6.1 Программные средства разработки приложения
- •6.2 Логическое проектирование Web-сервиса
- •6.3 Логическое проектирование клиентской части
- •6.4 Генерирование прокси-класса
- •6.5 Системные требования
- •Руководство программиста
- •6.7.1 Назначение и условия применения приложения
- •Структура приложения
- •6.8.4 Сообщения оператору
- •6.9 Тестирование приложения
- •Анализ вычислительной эффективности приложений
- •Заключение
- •Приложения
- •9.1 Листинг приложения на базе wpf Файл MainWindow.Xaml
- •Файл MainWindow.Xaml.Cs
- •9.2 Листинг приложения на базе haXe/php Файл Main.Hx
- •Файл Index.Html
- •9.3 Листинг клиент-северного приложения на базе asp.Net Файл Service.Asmx
- •Файл Service.Cs
- •Файл MainWindow.Xaml
- •Файл MainWindow.Xaml.Cs
Файл MainWindow.Xaml.Cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
using WpfApplication1.localhost;
namespace П3_ТП
{
/// <summary>
/// Логика взаимодействия для Window1.xaml
/// </summary>
public partial class Window1 : Window
{
BitmapImage bitmap1, bitmap2, bitmap3, bitmap4, bitmap5;
public Window1()
{
InitializeComponent();
Uri uri = new Uri(@"C:\images\image2_old.gif");
BitmapImage bitmap = new BitmapImage(uri);
image1.Source = bitmap;
Uri uri1 = new Uri(@"C:\images\image1.gif");
Uri uri2 = new Uri(@"C:\images\image2.gif");
Uri uri3 = new Uri(@"C:\images\image3.gif");
Uri uri4 = new Uri(@"C:\images\image4.gif");
Uri uri5 = new Uri(@"C:\images\image5.gif");
bitmap1 = new BitmapImage(uri1);
bitmap2 = new BitmapImage(uri2);
bitmap3 = new BitmapImage(uri3);
bitmap4 = new BitmapImage(uri4);
bitmap5 = new BitmapImage(uri5);
}
public double Ax;
public double Ay;
public double Bx;
public double By;
public double Cx;
public double Ex;
public delegate double[] ClassicDelegate(double Ax, double Ay, double Bx, double By, double Cx, double Ex, int n);
//obrabotchik sobitiya Vichislit
// private void HelloWorldCompleted(object sender,
// HelloWorldCompletedEventArgs e)
private void MonteCarloABCECompleted(object sender, MonteCarloABCECompletedEventArgs e)
{
button7.IsEnabled = true;
object[] result = new object[5];
result = e.Result;
double caser = (double)result[0];
if (caser == 1000.0)
{
textBox6.Text = System.Convert.ToString(result[0]);
textBox7.Text = System.Convert.ToString(result[1]);
textBox8.Text = System.Convert.ToString(result[2]);
textBox9.Text = System.Convert.ToString(result[3]);
textBox10.Text = System.Convert.ToString(result[4]);
// textBox40.Text = "10000";
}
if (caser == 10000.0)
{
textBox11.Text = System.Convert.ToString(result[0]);
textBox12.Text = System.Convert.ToString(result[1]);
textBox13.Text = System.Convert.ToString(result[2]);
textBox14.Text = System.Convert.ToString(result[3]);
textBox15.Text = System.Convert.ToString(result[4]);
// textBox40.Text = "100000";
}
if (caser == 100000.0)
{
textBox16.Text = System.Convert.ToString(result[0]);
textBox17.Text = System.Convert.ToString(result[1]);
textBox18.Text = System.Convert.ToString(result[2]);
textBox19.Text = System.Convert.ToString(result[3]);
textBox20.Text = System.Convert.ToString(result[4]);
// textBox40.Text = "1000000";
}
if (caser == 1000000.0)
{
textBox21.Text = System.Convert.ToString(result[0]);
textBox22.Text = System.Convert.ToString(result[1]);
textBox23.Text = System.Convert.ToString(result[2]);
textBox24.Text = System.Convert.ToString(result[3]);
textBox25.Text = System.Convert.ToString(result[4]);
// textBox40.Text = "10000000";
}
if (caser == 10000000.0)
{
textBox26.Text = System.Convert.ToString(result[0]);
textBox27.Text = System.Convert.ToString(result[1]);
textBox28.Text = System.Convert.ToString(result[2]);
textBox29.Text = System.Convert.ToString(result[3]);
textBox36.Text = System.Convert.ToString(result[4]);
// textBox40.Text = "Завершено успешно!";
}
}
private void button7_Click(object sender, RoutedEventArgs e)
{
try
{
Ax = System.Convert.ToDouble(textBox30.Text);
Ay = System.Convert.ToDouble(textBox31.Text);
Bx = System.Convert.ToDouble(textBox32.Text);
By = System.Convert.ToDouble(textBox33.Text);
Cx = System.Convert.ToDouble(textBox34.Text);
Ex = System.Convert.ToDouble(textBox35.Text);
}
catch
{
MessageBox.Show("Ошибка", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (Ax > Bx || Bx > Cx || Ax > Ex || Ax > Cx || Ay > By)
{
MessageBox.Show("Проверьте правильность введенных данных", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (Ax == 0 && Bx == 0 && Cx == 0 && Ex == 0 && Ay == 0 && By == 0)
{
MessageBox.Show("Проверьте правильность введенных данных", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
double MaxX = 0;
double MaxY = 0;
double MinX = 0;
double MinY = 0;
double Cy = By;
double Ey = Ay;
MaxX = Math.Max(Math.Max(Ax, Bx), Math.Max(Cx, Ex));
MaxY = Math.Max(Math.Max(Ay, By), Math.Max(Cy, Ey));
MinX = Math.Min(Math.Min(Ax, Bx), Math.Min(Cx, Ex));
MinY = Math.Min(Math.Min(Ay, By), Math.Min(Cy, Ey));
double S_Rect_O = (MaxX - MinX) * (MaxY - MinY);
double S_Rect_Teor = (By - Ay) * (((Ex - Ax) + (Cx - Bx)) / 2);
double[] table_rez = new double[5];
textBox38.Text = System.Convert.ToString(S_Rect_O);
textBox40.Text = System.Convert.ToString(S_Rect_Teor);
//------------
//sozdanie proxy-class
// Service prefect = new Service();
int n;
if (comboBox1.Text == "auto")
{
n = 1000;
for (int i = 0; i < 5; i++)
{
Service proxy = new Service();
proxy.MonteCarloABCECompleted += new MonteCarloABCECompletedEventHandler(this.MonteCarloABCECompleted);
proxy.MonteCarloABCEAsync(Ax, Ay, Bx, By, Cx, Ex, n);
n *= 10;
}
}
else
{
n = System.Convert.ToInt32(comboBox1.Text);
Service proxy = new Service();
proxy.MonteCarloABCECompleted += new MonteCarloABCECompletedEventHandler(this.MonteCarloABCECompleted);
proxy.MonteCarloABCEAsync(Ax, Ay, Bx, By, Cx, Ex, n);
}
}
//slychai 1
private void button1_Click(object sender, RoutedEventArgs e)
{
Ax = 15; Ay = 10;
Bx = 30; By = 30;
Cx = 40; Ex = 50;
image1.Source = bitmap1;
//-------
textBox30.Text = Convert.ToString(Ax); textBox31.Text = Convert.ToString(Ay);
textBox32.Text = Convert.ToString(Bx); textBox33.Text = Convert.ToString(By);
textBox34.Text = Convert.ToString(Cx); textBox35.Text = Convert.ToString(Ex);
}
// slychai 2
private void button2_Click(object sender, RoutedEventArgs e)
{
Ax = 15; Ay = 10;
Bx = 30; By = 30;
Cx = 50; Ex = 50;
image1.Source = bitmap2;
//-------
textBox30.Text = Convert.ToString(Ax); textBox31.Text = Convert.ToString(Ay);
textBox32.Text = Convert.ToString(Bx); textBox33.Text = Convert.ToString(By);
textBox34.Text = Convert.ToString(Cx); textBox35.Text = Convert.ToString(Ex);
}
// slychai 3
private void button3_Click(object sender, RoutedEventArgs e)
{
Ax = 3; Ay = 14;
Bx = 7; By = 25;
Cx = 20; Ex = 16;
image1.Source = bitmap3;
//-------
textBox30.Text = Convert.ToString(Ax); textBox31.Text = Convert.ToString(Ay);
textBox32.Text = Convert.ToString(Bx); textBox33.Text = Convert.ToString(By);
textBox34.Text = Convert.ToString(Cx); textBox35.Text = Convert.ToString(Ex);
}
// slychai 1 random
private void button4_Click(object sender, RoutedEventArgs e)
{
Random input = new Random();
for (int i = 0; i < 1000000; i++)
{
Ax = Convert.ToInt32(input.NextDouble() * 1000);
Ay = Convert.ToInt32(input.NextDouble() * 1000);
Bx = Convert.ToInt32(input.NextDouble() * 1000);
By = Convert.ToInt32(input.NextDouble() * 1000);
Cx = Convert.ToInt32(input.NextDouble() * 1000);
Ex = Convert.ToInt32(input.NextDouble() * 1000);
if (Cx < Ex&&Ax<Bx&&Ay<By&&Bx<Cx&&Ax<Ex&&Ax<Cx)
{
break;
}
}
// RandX = (test.NextDouble() * (MaxX - MinX) + MinX);
image1.Source = bitmap4;
//-------
textBox30.Text = Convert.ToString(Ax); textBox31.Text = Convert.ToString(Ay);
textBox32.Text = Convert.ToString(Bx); textBox33.Text = Convert.ToString(By);
textBox34.Text = Convert.ToString(Cx); textBox35.Text = Convert.ToString(Ex);
}
// slychai 3 random
private void button5_Click(object sender, RoutedEventArgs e)
{
Random input = new Random();
for (int i = 0; i < 1000000; i++)
{
Ax = Convert.ToInt32(input.NextDouble() * 1000);
Ay = Convert.ToInt32(input.NextDouble() * 1000);
Bx = Convert.ToInt32(input.NextDouble() * 1000);
By = Convert.ToInt32(input.NextDouble() * 1000);
Cx = Convert.ToInt32(input.NextDouble() * 1000);
Ex = Convert.ToInt32(input.NextDouble() * 1000);
if (Cx > Ex && Ax < Bx && Ay < By && Bx < Cx&&Ax<Ex&&Ax<Cx)
{
break;
}
}
image1.Source = bitmap5;
//-------
textBox30.Text = Convert.ToString(Ax); textBox31.Text = Convert.ToString(Ay);
textBox32.Text = Convert.ToString(Bx); textBox33.Text = Convert.ToString(By);
textBox34.Text = Convert.ToString(Cx); textBox35.Text = Convert.ToString(Ex);
}
//Knopka Clears
private void button6_Click(object sender, RoutedEventArgs e)
{
textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";
textBox10.Text = ""; textBox11.Text = ""; textBox12.Text = ""; textBox13.Text = "";
textBox14.Text = ""; textBox15.Text = ""; textBox16.Text = ""; textBox17.Text = "";
textBox18.Text = ""; textBox19.Text = ""; textBox20.Text = ""; textBox21.Text = "";
textBox22.Text = ""; textBox23.Text = ""; textBox24.Text = ""; textBox25.Text = "";
textBox26.Text = ""; textBox27.Text = ""; textBox28.Text = ""; textBox29.Text = "";
textBox36.Text = "";
textBox30.Text = "";
textBox31.Text = "";
textBox32.Text = "";
textBox33.Text = "";
textBox34.Text = "";
textBox35.Text = "";
textBox38.Text = ""; textBox40.Text = "";
}
-
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void textBox39_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void textBox30_TextChanged(object sender, TextChangedEventArgs e)
{
}
}
}