using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Xml;
namespace PocketPC
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmView : System.Windows.Forms.Form
{
private DataSet ds;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.TabPage tab1;
private System.Windows.Forms.TabPage tab2;
private System.Windows.Forms.TextBox txtGasPrice;
private System.Windows.Forms.TextBox txtRes;
private System.Windows.Forms.Label lblStats;
private System.Windows.Forms.ComboBox cboName;
private System.Windows.Forms.TextBox txtGas;
private System.Windows.Forms.TextBox txtTraffic;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.HScrollBar hScrollBar1;
private System.Windows.Forms.VScrollBar vScrollBar1;
private System.Windows.Forms.TabControl tab3;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuCenter;
private System.Windows.Forms.MenuItem menuFit;
private System.Windows.Forms.MenuItem menuDefault;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Button Submit;
protected PocketPC.net.xmethods.www.TemperatureService tempServer = new PocketPC.net.xmethods.www.TemperatureService();
private System.Windows.Forms.TextBox txtTempe;
private System.Windows.Forms.TextBox txtZipcode;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label9;
private const string XMLPATH = "\\Program Files\\PocketClient\\w.xml";
public frmView()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmView));
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.timer1 = new System.Windows.Forms.Timer();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.tab3 = new System.Windows.Forms.TabControl();
this.tab1 = new System.Windows.Forms.TabPage();
this.btnExit = new System.Windows.Forms.Button();
this.txtGasPrice = new System.Windows.Forms.TextBox();
this.txtRes = new System.Windows.Forms.TextBox();
this.lblStats = new System.Windows.Forms.Label();
this.cboName = new System.Windows.Forms.ComboBox();
this.txtGas = new System.Windows.Forms.TextBox();
this.txtTraffic = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.tab2 = new System.Windows.Forms.TabPage();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuCenter = new System.Windows.Forms.MenuItem();
this.menuFit = new System.Windows.Forms.MenuItem();
this.menuDefault = new System.Windows.Forms.MenuItem();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.txtTempe = new System.Windows.Forms.TextBox();
this.txtZipcode = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.Submit = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.label9 = new System.Windows.Forms.Label();
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.textBox1.ForeColor = System.Drawing.Color.Magenta;
this.textBox1.Location = new System.Drawing.Point(88, 120);
this.textBox1.Multiline = true;
this.textBox1.Size = new System.Drawing.Size(144, 22);
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 256);
this.button1.Size = new System.Drawing.Size(64, 24);
this.button1.Text = "Exit";
//
// label5
//
this.label5.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label5.Location = new System.Drawing.Point(24, 40);
this.label5.Size = new System.Drawing.Size(200, 40);
this.label5.Text = "Online Information";
this.label5.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(88, 88);
this.comboBox1.Size = new System.Drawing.Size(144, 22);
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.textBox2.ForeColor = System.Drawing.Color.Magenta;
this.textBox2.Location = new System.Drawing.Point(88, 120);
this.textBox2.Multiline = true;
this.textBox2.Size = new System.Drawing.Size(144, 22);
this.textBox2.Text = "";
//
// button2
//
this.button2.Location = new System.Drawing.Point(8, 256);
this.button2.Size = new System.Drawing.Size(64, 24);
this.button2.Text = "Exit";
//
// label6
//
this.label6.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label6.Location = new System.Drawing.Point(24, 40);
this.label6.Size = new System.Drawing.Size(200, 40);
this.label6.Text = "Online Information";
this.label6.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// comboBox2
//
this.comboBox2.Location = new System.Drawing.Point(88, 88);
this.comboBox2.Size = new System.Drawing.Size(144, 22);
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem2);
//
// menuItem2
//
this.menuItem2.Text = "Exit";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 257);
this.statusBar1.Size = new System.Drawing.Size(242, 22);
//
// tab3
//
this.tab3.Controls.Add(this.tab1);
this.tab3.Controls.Add(this.tab2);
this.tab3.Controls.Add(this.tabPage1);
this.tab3.SelectedIndex = 0;
this.tab3.Size = new System.Drawing.Size(242, 248);
//
// tab1
//
this.tab1.Controls.Add(this.btnExit);
this.tab1.Controls.Add(this.txtGasPrice);
this.tab1.Controls.Add(this.txtRes);
this.tab1.Controls.Add(this.lblStats);
this.tab1.Controls.Add(this.cboName);
this.tab1.Controls.Add(this.txtGas);
this.tab1.Controls.Add(this.txtTraffic);
this.tab1.Controls.Add(this.label4);
this.tab1.Controls.Add(this.label3);
this.tab1.Controls.Add(this.label2);
this.tab1.Controls.Add(this.label1);
this.tab1.Location = new System.Drawing.Point(4, 4);
this.tab1.Size = new System.Drawing.Size(234, 222);
this.tab1.Text = "Information";
//
// btnExit
//
this.btnExit.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold);
this.btnExit.Location = new System.Drawing.Point(8, 192);
this.btnExit.Size = new System.Drawing.Size(64, 24);
this.btnExit.Text = "Exit";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click_1);
//
// txtGasPrice
//
this.txtGasPrice.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.txtGasPrice.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(0)), ((System.Byte)(0)));
this.txtGasPrice.Location = new System.Drawing.Point(165, 120);
this.txtGasPrice.Size = new System.Drawing.Size(64, 22);
this.txtGasPrice.Text = "";
//
// txtRes
//
this.txtRes.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.txtRes.ForeColor = System.Drawing.Color.Magenta;
this.txtRes.Location = new System.Drawing.Point(85, 88);
this.txtRes.Size = new System.Drawing.Size(144, 22);
this.txtRes.Text = "";
//
// lblStats
//
this.lblStats.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.lblStats.Location = new System.Drawing.Point(5, 8);
this.lblStats.Size = new System.Drawing.Size(224, 32);
this.lblStats.Text = "Online Information";
//
// cboName
//
this.cboName.Location = new System.Drawing.Point(85, 56);
this.cboName.Size = new System.Drawing.Size(144, 22);
this.cboName.SelectedIndexChanged += new System.EventHandler(this.cboName_SelectedIndexChanged_1);
//
// txtGas
//
this.txtGas.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(255)));
this.txtGas.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
this.txtGas.Location = new System.Drawing.Point(85, 120);
this.txtGas.Size = new System.Drawing.Size(72, 22);
this.txtGas.Text = "";
//
// txtTraffic
//
this.txtTraffic.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
this.txtTraffic.ForeColor = System.Drawing.Color.Red;
this.txtTraffic.Location = new System.Drawing.Point(85, 152);
this.txtTraffic.Multiline = true;
this.txtTraffic.Size = new System.Drawing.Size(144, 64);
this.txtTraffic.Text = "";
//
// label4
//
this.label4.ForeColor = System.Drawing.Color.Red;
this.label4.Location = new System.Drawing.Point(5, 152);
this.label4.Size = new System.Drawing.Size(80, 24);
this.label4.Text = "Traffic Report";
//
// label3
//
this.label3.ForeColor = System.Drawing.Color.Brown;
this.label3.Location = new System.Drawing.Point(5, 120);
this.label3.Size = new System.Drawing.Size(64, 20);
this.label3.Text = "Gas";
//
// label2
//
this.label2.ForeColor = System.Drawing.Color.Brown;
this.label2.Location = new System.Drawing.Point(5, 88);
this.label2.Size = new System.Drawing.Size(64, 20);
this.label2.Text = "Restaurant";
//
// label1
//
this.label1.ForeColor = System.Drawing.Color.Brown;
this.label1.Location = new System.Drawing.Point(5, 56);
this.label1.Size = new System.Drawing.Size(64, 20);
this.label1.Text = "City";
//
// tab2
//
this.tab2.Controls.Add(this.vScrollBar1);
this.tab2.Controls.Add(this.hScrollBar1);
this.tab2.Controls.Add(this.pictureBox1);
this.tab2.Location = new System.Drawing.Point(4, 4);
this.tab2.Size = new System.Drawing.Size(234, 222);
this.tab2.Text = "Maps";
//
// vScrollBar1
//
this.vScrollBar1.Location = new System.Drawing.Point(216, 8);
this.vScrollBar1.Maximum = 91;
this.vScrollBar1.Size = new System.Drawing.Size(16, 208);
//
// hScrollBar1
//
this.hScrollBar1.Location = new System.Drawing.Point(8, 200);
this.hScrollBar1.Maximum = 91;
this.hScrollBar1.Size = new System.Drawing.Size(208, 16);
//
// pictureBox1
//
this.pictureBox1.ContextMenu = this.contextMenu1;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Size = new System.Drawing.Size(208, 192);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
//
// contextMenu1
//
this.contextMenu1.MenuItems.Add(this.menuCenter);
this.contextMenu1.MenuItems.Add(this.menuFit);
this.contextMenu1.MenuItems.Add(this.menuDefault);
//
// menuCenter
//
this.menuCenter.Text = "ImageCenter";
this.menuCenter.Click += new System.EventHandler(this.menuCenter_Click);
//
// menuFit
//
this.menuFit.Text = "ImageFit";
this.menuFit.Click += new System.EventHandler(this.menuFit_Click);
//
// menuDefault
//
this.menuDefault.Text = "ImageDefault";
this.menuDefault.Click += new System.EventHandler(this.menuDefault_Click);
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label9);
this.tabPage1.Controls.Add(this.txtTempe);
this.tabPage1.Controls.Add(this.txtZipcode);
this.tabPage1.Controls.Add(this.label8);
this.tabPage1.Controls.Add(this.label7);
this.tabPage1.Controls.Add(this.Submit);
this.tabPage1.Location = new System.Drawing.Point(4, 4);
this.tabPage1.Size = new System.Drawing.Size(234, 222);
this.tabPage1.Text = "Web Services";
this.tabPage1.EnabledChanged += new System.EventHandler(this.tabPage1_EnabledChanged);
//
// txtTempe
//
this.txtTempe.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.txtTempe.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(64)), ((System.Byte)(0)));
this.txtTempe.Location = new System.Drawing.Point(96, 80);
this.txtTempe.Size = new System.Drawing.Size(104, 22);
this.txtTempe.Text = "";
//
// txtZipcode
//
this.txtZipcode.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.txtZipcode.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(0)), ((System.Byte)(192)));
this.txtZipcode.Location = new System.Drawing.Point(96, 32);
this.txtZipcode.Size = new System.Drawing.Size(104, 22);
this.txtZipcode.Text = "06810";
//
// label8
//
this.label8.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
this.label8.Location = new System.Drawing.Point(16, 80);
this.label8.Size = new System.Drawing.Size(80, 20);
this.label8.Text = "Temperature";
//
// label7
//
this.label7.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
this.label7.Location = new System.Drawing.Point(15, 40);
this.label7.Size = new System.Drawing.Size(57, 20);
this.label7.Text = "Zip Code";
//
// Submit
//
this.Submit.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold);
this.Submit.Location = new System.Drawing.Point(160, 184);
this.Submit.Size = new System.Drawing.Size(64, 24);
this.Submit.Text = "Submit";
this.Submit.Click += new System.EventHandler(this.Submit_Click);
//
// label9
//
this.label9.ForeColor = System.Drawing.Color.Red;
this.label9.Location = new System.Drawing.Point(16, 8);
this.label9.Size = new System.Drawing.Size(176, 16);
this.label9.Text = "Enter you zip code.";
//
// frmView
//
this.BackColor = System.Drawing.Color.AntiqueWhite;
this.ClientSize = new System.Drawing.Size(242, 279);
this.Controls.Add(this.tab3);
this.Controls.Add(this.statusBar1);
this.Menu = this.mainMenu1;
this.Text = "Personal Assistant";
this.Load += new System.EventHandler(this.frmView_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new frmView());
}
private void frmView_Load(object sender, System.EventArgs e)
{
LoadData();
}
private void LoadData()
{
loadXml(XMLPATH);
DisplayData();
cboName_SelectedIndexChanged_1(null,null);
}
private void loadXml(string file)
{
try
{
FileStream fin = new FileStream(file, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
ds = new DataSet();
ds.ReadXml(new XmlTextReader(fin));
fin.Close();
}
catch(Exception ex)
{
lblStats.Text = ex.ToString();
}
}
private void DisplayData()
{
cboName.DisplayMember = "name";
cboName.DataSource = ds.Tables["city"];
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void timer1_Tick(object sender, System.EventArgs e)
{
statusBar1.Text = DateTime.Now.ToString();
}
private void cboName_SelectedIndexChanged_1(object sender, System.EventArgs e)
{
DataRowView temp;
if (cboName.SelectedIndex >= 0)
{
try
{
temp = (DataRowView) cboName.Items[cboName.SelectedIndex];
txtGas.Text = temp["gas"].ToString();
txtGasPrice.Text = temp["GasRate"].ToString();
txtRes.Text = temp["Restaurant"].ToString();
txtTraffic.Text = temp["Traffic1"].ToString()
+ "\r\n" + temp["Traffic2"].ToString() ;
try
{
lblStats.Text = "Welcome to " + temp["name"].ToString() + " city.\r\nTemperature is " + tempServer.getTemp(temp["zipcode"].ToString()) + " F";
}
catch(Exception ex)
{}
}
catch(Exception ex)
{
lblStats.Text = ex.ToString();
}
}
}
private void btnExit_Click_1(object sender, System.EventArgs e)
{
Application.Exit();
}
private void menuCenter_Click(object sender, System.EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
}
private void menuFit_Click(object sender, System.EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
private void menuDefault_Click(object sender, System.EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
}
private void tabPage1_EnabledChanged(object sender, System.EventArgs e)
{
}
private void Submit_Click(object sender, System.EventArgs e)
{
try
{
txtTempe.Text = tempServer.getTemp(txtZipcode.Text).ToString();
}
catch(Exception ex)
{
}
}
}
}