基本信息
源码名称:C# 手机GPS开发源码
源码大小:0.32M
文件格式:.zip
开发语言:C#
更新时间:2015-08-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



手机GPS开发



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;

namespace Inspection
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            //读取GPS端口文件,配置端口组件
            try
            {
                StreamReader sr = new StreamReader(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)   "\\Port.dat", System.Text.Encoding.Unicode, false);
                string strLine = sr.ReadLine();//读取文件中的一行
                while (strLine != null)//判断是否为空,表示到文件最后一行了
                {
                    string[] lineArr = strLine.Split('=');
                    if (lineArr.Length == 2)
                    {
                        switch (lineArr[0])
                        {
                            case "SerialPort":
                                serialPort1.PortName = lineArr[1];
                                break;
                            case "BaudRate":
                                serialPort1.BaudRate = int.Parse(lineArr[1]);
                                break;
                            case "DataBits":
                                serialPort1.DataBits = int.Parse(lineArr[1]);
                                break;
                            case "Parity":
                                switch (lineArr[1])
                                {
                                    case "None":
                                        serialPort1.Parity = System.IO.Ports.Parity.None;
                                        break;
                                    case "Odd":
                                        serialPort1.Parity = System.IO.Ports.Parity.Odd;
                                        break;
                                    case "Even":
                                        serialPort1.Parity = System.IO.Ports.Parity.Even;
                                        break;
                                    case "Mark":
                                        serialPort1.Parity = System.IO.Ports.Parity.Mark;
                                        break;
                                    case "Space":
                                        serialPort1.Parity = System.IO.Ports.Parity.Space;
                                        break;
                                }
                                break;
                            case "StopBits":
                                switch (lineArr[1])
                                {
                                    case "One":
                                        serialPort1.StopBits = System.IO.Ports.StopBits.One;
                                        break;
                                    case "Two":
                                        serialPort1.StopBits = System.IO.Ports.StopBits.Two;
                                        break;
                                    case "OnePointFive":
                                        serialPort1.StopBits = System.IO.Ports.StopBits.OnePointFive;
                                        break;
                                }
                                break;
                        }
                    }
                    strLine = sr.ReadLine();
                }
                sr.Close();//关闭流
                sr.Dispose();
            }
            catch
            {
                MessageBox.Show("读取端口文件失败!");
            }
            //创建界面按钮
            //第一行3个
            //巡检按钮
            ImageButton imageButton_XunJian = new ImageButton();
            imageButton_XunJian.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.xunjian.png"));
            imageButton_XunJian.Location = new Point( (this.Width-64*3) / 4, 8);
            imageButton_XunJian.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_XunJian.Click  = new EventHandler(imageButton_XunJian_Click);
            this.Controls.Add(imageButton_XunJian);
            Label xunjianLabel = new Label(); 
            xunjianLabel.Size = new Size(64, 20);
            xunjianLabel.Location = new Point( (this.Width - 64 * 3) / 4, 74);
            xunjianLabel.Text = "开始巡检";
            xunjianLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            xunjianLabel.ForeColor = Color.FromArgb(255,255,255);
            this.Controls.Add(xunjianLabel);
            //巡检任务
            ImageButton imageButton_RenWu = new ImageButton();
            imageButton_RenWu.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.Search.png"));
            imageButton_RenWu.Location = new Point( 2*(this.Width - 64 * 3) / 4   64, 8);
            imageButton_RenWu.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_RenWu.Click  = new EventHandler(imageButton_XunJian_Click);
            this.Controls.Add(imageButton_RenWu);
            Label renwuLabel = new Label();
            renwuLabel.Size = new Size(64, 20);
            renwuLabel.Location = new Point(2 * (this.Width - 64 * 3) / 4   64, 74);
            renwuLabel.Text = "任务查询";
            renwuLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            renwuLabel.ForeColor = Color.FromArgb(255, 255, 255);
            this.Controls.Add(renwuLabel);
            //导航按钮
            ImageButton imageButton_DaoHang = new ImageButton();
            imageButton_DaoHang.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.daohang.png"));
            imageButton_DaoHang.Location = new Point(3 * (this.Width - 64 * 3) / 4   2*64, 8);
            imageButton_DaoHang.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_DaoHang.Click  = new EventHandler(imageButton_XunJian_Click);
            this.Controls.Add(imageButton_DaoHang);
            Label daohangLabel = new Label();
            daohangLabel.Size = new Size(64, 20);
            daohangLabel.Location = new Point(3 * (this.Width - 64 * 3) / 4   2 * 64, 74);
            daohangLabel.Text = "定位导航";
            daohangLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            daohangLabel.ForeColor = Color.FromArgb(255, 255, 255);
            this.Controls.Add(daohangLabel);
            //第二行,3个
            //系统信息
            ImageButton imageButton_mail = new ImageButton();
            imageButton_mail.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.Mail.png"));
            imageButton_mail.Location = new Point((this.Width - 64 * 3) / 4, 98);
            imageButton_mail.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_mail.Click  = new EventHandler(imageButton_XunJian_Click);
            this.Controls.Add(imageButton_mail);
            Label mailLabel = new Label();
            mailLabel.Size = new Size(64, 20);
            mailLabel.Location = new Point((this.Width - 64 * 3) / 4, 164);
            mailLabel.Text = "系统消息";
            mailLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            mailLabel.ForeColor = Color.FromArgb(255, 255, 255);
            this.Controls.Add(mailLabel);
            //GPS信号检测
            ImageButton imageButton_JianCe = new ImageButton();
            imageButton_JianCe.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.gpstest.png"));
            imageButton_JianCe.Location = new Point(2 * (this.Width - 64 * 3) / 4   64, 98);
            imageButton_JianCe.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_JianCe.Click  = new EventHandler(imageButton_JianCe_Click);
            this.Controls.Add(imageButton_JianCe);
            Label JianCeLabel = new Label();
            JianCeLabel.Size = new Size(64, 20);
            JianCeLabel.Location = new Point(2 * (this.Width - 64 * 3) / 4   64, 164);
            JianCeLabel.Text = "GPS信号";
            JianCeLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            JianCeLabel.ForeColor = Color.FromArgb(255, 255, 255);
            this.Controls.Add(JianCeLabel);

            //系统设置
            ImageButton imageButton_SysSetting = new ImageButton();
            imageButton_SysSetting.Image = new
            Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Inspection.SystemSetting.png"));
            imageButton_SysSetting.Location = new Point(3 * (this.Width - 64 * 3) / 4   2 * 64, 98);
            imageButton_SysSetting.Size = new Size(64, 64);
            //Hook up into click event
            imageButton_SysSetting.Click  = new EventHandler(imageButton_SysSetting_Click);
            this.Controls.Add(imageButton_SysSetting);
            Label SysSetLabel = new Label();
            SysSetLabel.Size = new Size(64, 20);
            SysSetLabel.Location = new Point(3 * (this.Width - 64 * 3) / 4   2 * 64, 164);
            SysSetLabel.Text = "系统设置";
            SysSetLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            SysSetLabel.ForeColor = Color.FromArgb(255, 255, 255);
            this.Controls.Add(SysSetLabel);
        }

        //定时器
        private void timer1_Tick(object sender, EventArgs e)
        {
            //if (serialPort1.IsOpen)
            //{
            //    mGps.SetGPSdata(serialPort1.ReadExisting());
            //}
        }
        //
        private void MainForm_Load(object sender, EventArgs e)
        {
            //这两句保证按下X就会关闭程序,如果没有只会最小化窗口
            this.ControlBox = true;
            this.MinimizeBox = false;
        }
        //窗口关闭事件
        private void MainForm_Closed(object sender, EventArgs e)
        {
        }
        //退出程序按钮
        private void menuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        //系统设置
        private void imageButton_SysSetting_Click(object sender, EventArgs e)
        {
            SysSetForm mForm = new SysSetForm(this.serialPort1);
            mForm.Show();
        }
        //线路巡检
        private void imageButton_XunJian_Click(object sender, EventArgs e)
        {
        }
        //GPS信号
        private void imageButton_JianCe_Click(object sender, EventArgs e)
        {
            ShowGPSXinXi mForm = new ShowGPSXinXi(this.serialPort1);
            mForm.Show();
        }

    }
}