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

📄 formoptions.cs

📁 在windows mobile 5上的地图查看器
💻 CS
字号:
// 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;

#endregion

namespace PocketEarth
{
    /// <summary>
    /// Summary description for FormOptions.
    /// </summary>
    public class FormOptions : System.Windows.Forms.Form, IDisposable
    {
        private Label lblCacheSize;
        private TextBox txtCachedFileSize;
        private Label lblKB;
        private MenuItem menuDone;
        private MenuItem menuCancel;
        private ComboBox cmbStorageLocation;
        private Label lblStorageLocation;
        /// <summary>
        /// Main menu for the form.
        /// </summary>
        private System.Windows.Forms.MainMenu mainMenu1;

        public FormOptions()
        {
            InitializeComponent();
            DpiHelper.AdjustAllControls(this);
        }

        /// <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.menuDone = new System.Windows.Forms.MenuItem();
            this.menuCancel = new System.Windows.Forms.MenuItem();
            this.lblCacheSize = new System.Windows.Forms.Label();
            this.txtCachedFileSize = new System.Windows.Forms.TextBox();
            this.lblKB = new System.Windows.Forms.Label();
            this.cmbStorageLocation = new System.Windows.Forms.ComboBox();
            this.lblStorageLocation = new System.Windows.Forms.Label();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.menuDone);
            this.mainMenu1.MenuItems.Add(this.menuCancel);
            // 
            // menuDone
            // 
            this.menuDone.Text = "Done";
            this.menuDone.Click += new System.EventHandler(this.menuDone_Click);
            // 
            // menuCancel
            // 
            this.menuCancel.Text = "Cancel";
            this.menuCancel.Click += new System.EventHandler(this.menuCancel_Click);
            // 
            // lblCacheSize
            // 
            this.lblCacheSize.Location = new System.Drawing.Point(4, 79);
            this.lblCacheSize.Size = new System.Drawing.Size(152, 36);
            this.lblCacheSize.Text = "Approximate storage space to use for maps:";
            // 
            // txtCachedFileSize
            // 
            this.txtCachedFileSize.Location = new System.Drawing.Point(4, 118);
            this.txtCachedFileSize.Size = new System.Drawing.Size(36, 24);
            this.txtCachedFileSize.Text = "500";
            // 
            // lblKB
            // 
            this.lblKB.Location = new System.Drawing.Point(40, 121);
            this.lblKB.Size = new System.Drawing.Size(30, 18);
            this.lblKB.Text = "KB";
            // 
            // cmbStorageLocation
            // 
            this.cmbStorageLocation.Items.Add("Built-in storage");
            this.cmbStorageLocation.Items.Add("Removable storage card");
            this.cmbStorageLocation.Location = new System.Drawing.Point(4, 23);
            this.cmbStorageLocation.Size = new System.Drawing.Size(169, 24);
            // 
            // lblStorageLocation
            // 
            this.lblStorageLocation.Location = new System.Drawing.Point(4, 4);
            this.lblStorageLocation.Size = new System.Drawing.Size(152, 22);
            this.lblStorageLocation.Text = "Map storage location:";
            // 
            // FormOptions
            // 
            this.ClientSize = new System.Drawing.Size(176, 180);
            this.Controls.Add(this.lblCacheSize);
            this.Controls.Add(this.txtCachedFileSize);
            this.Controls.Add(this.lblKB);
            this.Controls.Add(this.cmbStorageLocation);
            this.Controls.Add(this.lblStorageLocation);
            this.Menu = this.mainMenu1;
            this.Text = "Options";
            this.Load += new System.EventHandler(this.FormOptions_Load);

        }

        #endregion



        private void FormOptions_Load(object sender, EventArgs e)
        {
            IntPtr hkey = Registry.OpenKey(Registry.GetRootKey(Registry.HKey.CURRENT_USER), 
                                "Software\\Jason Fuller's\\VirtualEarthMobile");

            int cacheSizeKb = (int)Registry.GetValue(hkey, "CacheSizeKB");
            txtCachedFileSize.Text = cacheSizeKb.ToString();

            cmbStorageLocation.SelectedIndex = (int)Registry.GetValue(hkey, "UseStorageCard");

            Registry.CloseKey(hkey);
        }


        private void menuDone_Click(object sender, EventArgs e)
        {
            IntPtr hkey = Registry.OpenKey(
                            Registry.GetRootKey(Registry.HKey.CURRENT_USER),
                            "Software\\Jason Fuller's\\VirtualEarthMobile"); 
            int cacheSizeKb = Convert.ToInt32(txtCachedFileSize.Text);
            if (cacheSizeKb != 0)
            {
                Registry.SetValue(hkey, "CacheSizeKB", cacheSizeKb);
            }
            Registry.SetValue(hkey, "UseStorageCard", cmbStorageLocation.SelectedIndex);

            Registry.CloseKey(hkey);
            Close();
        }


        private void menuCancel_Click(object sender, EventArgs e)
        {
            Close();
        }


    }
}

⌨️ 快捷键说明

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