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

📄 form1.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MobileDevelopersHandbook
{
    public partial class Form1 : Form
    {
        private Dictionary<string, string> configSettings;

        public Form1()
        {
            InitializeComponent();
        }

        private void menuItemExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            configSettings = new Dictionary<string, string>();

            Timer tmr = new Timer();
            tmr.Tick += new EventHandler(tmr_Tick);
            tmr.Interval = 10;
            tmr.Enabled = true;
        }

        void tmr_Tick(object sender, EventArgs e)
        {
            ((Timer)sender).Enabled = false;
            DoLogin();
        }

        private void DoLogin()
        {
            // Get the user to login
            using (LoginForm frm = new LoginForm(configSettings))
            {
                frm.ShowDialog();
            }

            // Set connectionstring to database
            this.messagesTableAdapter.Connection.ConnectionString =
                @"Data Source =""" + GetApplicationDirectory() + @"\AppDatabase.sdf""; password="
                + configSettings["DatabasePassword"];

            if (AppDatabaseDataSetUtil.DesignerUtil.IsRunTime())
            {
                // TODO: Delete this line of code to remove the default AutoFill for 'appDatabaseDataSet.Messages'.
                this.messagesTableAdapter.Fill(this.appDatabaseDataSet.Messages);
            }
        }

        private string GetApplicationDirectory()
        {
            return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
        }
    }
}

⌨️ 快捷键说明

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