⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formpocketearth.cs

📁 在windows mobile 5上的地图查看器
💻 CS
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) Jason Fuller. 
//
// Use of this source code is subject to the terms of the license found in the
// file License.txt.  If you did not accept the terms of that license, you are
// not authorized to use this source code.

#region Using directives

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using Microsoft.WindowsMobile.Samples.Location;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.Forms;
#endregion

namespace PocketEarth
{
    /// <summary>
    /// Summary description for form.
    /// </summary>
    public class FormPocketEarth : System.Windows.Forms.Form
    {
        private MenuItem menuAddress;
        private MenuItem menuItem2;
        private MenuItem menuLatLong;
        private MenuItem menuZoom;
        private MenuItem menuZoom1;
        private MenuItem menuZoom2;
        private MenuItem menuZoom3;
        private MenuItem menuZoom4;
        private MenuItem menuZoom5;
        private MenuItem menuZoom6;
        private MenuItem menuZoom7;
        private MenuItem menuZoom8;
        private MenuItem menuZoom9;
        private MenuItem menuItem15;
        private MenuItem menuRoad;
        private MenuItem menuAerial;
        private MenuItem menuHybrid;

        private MenuItem checkedMenu;

        private Map map;
        private MenuItem menuAbout;
        private MenuItem menuExit;
        private MenuItem menuGps;
        private MenuItem menuFindContact;
        private MenuItem menuLocalSearch;
        private MenuItem menuOptions;
        
        /// <summary>
        /// Main menu for the form.
        /// </summary>
        private System.Windows.Forms.MainMenu mainMenu1;

        public const string AppName = "Virtual Earth Mobile";


        public FormPocketEarth()
        {
            InitializeComponent();

            // This corresponds to the 13 we pass to the Map constructor below.
            checkedMenu = menuZoom6;

            // Before WindowsMobile 5.0, there was no GPS API or managed Contact chooser. 
            if (Environment.OSVersion.Version.Major < 5)
            {
                menuGps.Enabled = false;
                menuFindContact.Enabled = false;
            }

            map = new Map(
                  this.Size.Width,
                  this.Size.Height,
                  47.639611,
                  -122.127204,
                  /* zoom */ 11,
                  MapStyle.Road);

            RedrawMap();
        }

        /// <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()
        {
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.menuAddress = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.menuLatLong = new System.Windows.Forms.MenuItem();
            this.menuItem15 = new System.Windows.Forms.MenuItem();
            this.menuRoad = new System.Windows.Forms.MenuItem();
            this.menuAerial = new System.Windows.Forms.MenuItem();
            this.menuHybrid = new System.Windows.Forms.MenuItem();
            this.menuZoom = new System.Windows.Forms.MenuItem();
            this.menuZoom1 = new System.Windows.Forms.MenuItem();
            this.menuZoom2 = new System.Windows.Forms.MenuItem();
            this.menuZoom3 = new System.Windows.Forms.MenuItem();
            this.menuZoom4 = new System.Windows.Forms.MenuItem();
            this.menuZoom5 = new System.Windows.Forms.MenuItem();
            this.menuZoom6 = new System.Windows.Forms.MenuItem();
            this.menuZoom7 = new System.Windows.Forms.MenuItem();
            this.menuZoom8 = new System.Windows.Forms.MenuItem();
            this.menuZoom9 = new System.Windows.Forms.MenuItem();
            this.menuGps = new System.Windows.Forms.MenuItem();
            this.menuLocalSearch = new System.Windows.Forms.MenuItem();
            this.menuFindContact = new System.Windows.Forms.MenuItem();
            this.menuOptions = new System.Windows.Forms.MenuItem();
            this.menuAbout = new System.Windows.Forms.MenuItem();
            this.menuExit = new System.Windows.Forms.MenuItem();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.menuAddress);
            this.mainMenu1.MenuItems.Add(this.menuItem2);
            // 
            // menuAddress
            // 
            this.menuAddress.Text = "Address";
            this.menuAddress.Click += new System.EventHandler(this.menuAddress_Click);
            // 
            // menuItem2
            // 
            this.menuItem2.MenuItems.Add(this.menuLatLong);
            this.menuItem2.MenuItems.Add(this.menuItem15);
            this.menuItem2.MenuItems.Add(this.menuZoom);
            this.menuItem2.MenuItems.Add(this.menuGps);
            this.menuItem2.MenuItems.Add(this.menuLocalSearch);
            this.menuItem2.MenuItems.Add(this.menuFindContact);
            this.menuItem2.MenuItems.Add(this.menuOptions);
            this.menuItem2.MenuItems.Add(this.menuAbout);
            this.menuItem2.MenuItems.Add(this.menuExit);
            this.menuItem2.Text = "Menu";
            // 
            // menuLatLong
            // 
            this.menuLatLong.Text = "Go to Lat/Long";
            this.menuLatLong.Click += new System.EventHandler(this.menuLatLong_Click);
            // 
            // menuItem15
            // 
            this.menuItem15.MenuItems.Add(this.menuRoad);
            this.menuItem15.MenuItems.Add(this.menuAerial);
            this.menuItem15.MenuItems.Add(this.menuHybrid);
            this.menuItem15.Text = "Map type";
            // 
            // menuRoad
            // 
            this.menuRoad.Text = "Road";
            this.menuRoad.Click += new System.EventHandler(this.menuRoad_Click);
            // 
            // menuAerial
            // 
            this.menuAerial.Text = "Aerial";
            this.menuAerial.Click += new System.EventHandler(this.menuAerial_Click);
            // 
            // menuHybrid
            // 
            this.menuHybrid.Text = "Road and Aerial";
            this.menuHybrid.Click += new System.EventHandler(this.menuHybrid_Click);
            // 
            // menuZoom
            // 
            this.menuZoom.MenuItems.Add(this.menuZoom1);
            this.menuZoom.MenuItems.Add(this.menuZoom2);
            this.menuZoom.MenuItems.Add(this.menuZoom3);
            this.menuZoom.MenuItems.Add(this.menuZoom4);
            this.menuZoom.MenuItems.Add(this.menuZoom5);
            this.menuZoom.MenuItems.Add(this.menuZoom6);
            this.menuZoom.MenuItems.Add(this.menuZoom7);
            this.menuZoom.MenuItems.Add(this.menuZoom8);
            this.menuZoom.MenuItems.Add(this.menuZoom9);
            this.menuZoom.Text = "Zoom";
            this.menuZoom.Popup += new System.EventHandler(this.menuZoom_Popup);
            // 
            // menuZoom1
            // 
            this.menuZoom1.Text = ". Zoom out";
            this.menuZoom1.Click += new System.EventHandler(this.menuZoom1_Click);
            // 
            // menuZoom2
            // 
            this.menuZoom2.Text = ".";
            this.menuZoom2.Click += new System.EventHandler(this.menuZoom2_Click);
            // 
            // menuZoom3
            // 
            this.menuZoom3.Text = ".";
            this.menuZoom3.Click += new System.EventHandler(this.menuZoom3_Click);
            // 
            // menuZoom4
            // 
            this.menuZoom4.Text = ".";
            this.menuZoom4.Click += new System.EventHandler(this.menuZoom4_Click);
            // 
            // menuZoom5
            // 
            this.menuZoom5.Text = ".";
            this.menuZoom5.Click += new System.EventHandler(this.menuZoom5_Click);
            // 
            // menuZoom6
            // 
            this.menuZoom6.Text = ".";
            this.menuZoom6.Click += new System.EventHandler(this.menuZoom6_Click);
            // 
            // menuZoom7
            // 
            this.menuZoom7.Text = ".";
            this.menuZoom7.Click += new System.EventHandler(this.menuZoom7_Click);
            // 
            // menuZoom8
            // 
            this.menuZoom8.Text = ".";
            this.menuZoom8.Click += new System.EventHandler(this.menuZoom8_Click);
            // 
            // menuZoom9
            // 
            this.menuZoom9.Text = ". Zoom in";
            this.menuZoom9.Click += new System.EventHandler(this.menuZoom9_Click);
            // 
            // menuGps
            // 
            this.menuGps.Text = "GPS";
            this.menuGps.Click += new System.EventHandler(this.menuGps_Click);
            // 
            // menuLocalSearch
            // 
            this.menuLocalSearch.Text = "Find a business";
            this.menuLocalSearch.Click += new System.EventHandler(this.menuLocalSearch_Click);
            // 
            // menuFindContact
            // 
            this.menuFindContact.Text = "Find a contact";
            this.menuFindContact.Click += new System.EventHandler(this.menuFindContact_Click);
            // 
            // menuOptions
            // 
            this.menuOptions.Text = "Options";
            this.menuOptions.Click += new System.EventHandler(this.menuOptions_Click);
            // 
            // menuAbout
            // 
            this.menuAbout.Text = "About";
            this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click);
            // 
            // menuExit
            // 
            this.menuExit.Text = "Exit";
            this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
            // 
            // FormPocketEarth
            // 
            this.ClientSize = new System.Drawing.Size(176, 180);
            this.Menu = this.mainMenu1;
            this.Text = "Virtual Earth Mobile";
            this.Deactivate += new System.EventHandler(this.FormPocketEarth_Deactivate);
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.FormPocketEarth_Paint);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormPocketEarth_KeyDown);
            this.Load += new System.EventHandler(this.FormPocketEarth_Load);

        }

        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            Application.Run(new FormPocketEarth());
        }

        private void menuHybrid_Click(object sender, EventArgs e)
        {
            map.MapStyle = MapStyle.Hybrid;
            RedrawMap();
        }
        private void menuAerial_Click(object sender, EventArgs e)
        {
            map.MapStyle = MapStyle.Aerial;
            RedrawMap();
        }
        private void menuRoad_Click(object sender, EventArgs e)
        {
            map.MapStyle = MapStyle.Road;
            RedrawMap();
        }

        private void menuLatLong_Click(object sender, EventArgs e)
        {
            FormLatLong dlg = new FormLatLong();
            // Pre-populate the dialog with the current lat/long
            dlg.Latitude = map.Latitude;
            dlg.Longitude = map.Longitude;

            if (dlg.ShowDialog() != DialogResult.Cancel)
            {
                // Set the map to lat/long specified by the user.
                map.Latitude = dlg.Latitude;
                map.Longitude = dlg.Longitude;
                RedrawMap();
            }
            dlg.Dispose();
        }

        /// <summary>
        /// Zoom to the specified zoom level.
        /// </summary>
        /// <param name="zoomLevel">The requested zoom level</param>
        private void Zoom(int zoomLevel)
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -