
Form2.Cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Google.Api.Maps.Service.Geocoding;
using Google.Api.Maps.Service;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
int count = 0;
public Form2()
{
InitializeComponent();
listBox1.HorizontalScrollbar = true;
label1.Text = "Найдено адресов: ";
listBox1.Items.Clear();
}
private void AddressLoad()//загрузка адресов
{
try
{
label1.Text = "Найдено адресов: ";
listBox1.Items.Clear();
var request = new GeocodingRequest();
request.Address = adress.Data;
request.Sensor = "false";
var response = GeocodingService.GetResponse(request);
if (response.Status == ServiceResponseStatus.Ok)
{
count = response.Results.Length;
label1.Text = label1.Text + response.Results.Length;
for (int i = 0; i < count; i++)
listBox1.Items.Add(response.Results[i].FormattedAddress);
}
else
{
MessageBox.Show("Данного адреса не существует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
adress.flag = false;
Close();
}
}
catch (System.Net.WebException)
{
MessageBox.Show("Проблемы с соединением", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
catch { MessageBox.Show("Ошибка при загрузке адресов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void ButtonChoose_Click(object sender, EventArgs e)//выбор адреса
{
if (listBox1.SelectedIndex != -1)
{
adress.Data = listBox1.SelectedItem.ToString();
adress.flag = true;
adress.k = 1;
Close();
}
else
{
MessageBox.Show("Выберите адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
private void ButtonRefresh_Click(object sender, EventArgs e)
{
AddressLoad();
}
}
}
Form3.Cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Google.Api.Maps.Service.Geocoding;
using Google.Api.Maps.Service;
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
int count = 0;
public Form3()
{
InitializeComponent();
listBox1.HorizontalScrollbar = true;
label1.Text = "Найдено адресов: ";
listBox1.Items.Clear();
}
private void AddressLoad()
{
try
{
label1.Text = "Найдено адресов: ";
listBox1.Items.Clear();
var request = new GeocodingRequest();
request.Address = adress.DataTo;
request.Sensor = "false";
var response = GeocodingService.GetResponse(request);
if (response.Status == ServiceResponseStatus.Ok)
{
count = response.Results.Length;
label1.Text = label1.Text + response.Results.Length;
for (int i = 0; i < count; i++)
listBox1.Items.Add(response.Results[i].FormattedAddress);
}
else
{
MessageBox.Show("Данного адреса не существует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
adress.flag = false;
Close();
}
}
catch (System.Net.WebException)
{
MessageBox.Show("Проблемы с соединением", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
catch { MessageBox.Show("Ошибка при загрузке адресов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void ButtonRefresh_Click(object sender, EventArgs e)
{
AddressLoad();
}
private void ButtonChoose_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex != -1)
{
adress.DataTo = listBox1.SelectedItem.ToString();
adress.flag = true;
adress.k = 1;
Close();
}
else
{
MessageBox.Show("Выберите адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
}
}