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

📄 mainform.cs

📁 Accessing microsoft live web services from windows mobile
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using LiveExpoService;

namespace LiveExpoApp
{
    public partial class MainForm : Form
    {
        private Thread splashScreenThread;
        private AutoResetEvent appInitialized;

        public MainForm()
        {
            // Create a seperate thread into which we immediately will display a splash screen.
            // While displaying the splash screen the application will initialize.
            appInitialized = new AutoResetEvent(false);
            splashScreenThread = new Thread(SplashScreenThread);
            splashScreenThread.Priority = ThreadPriority.AboveNormal;
            splashScreenThread.Start();

            InitializeComponent();
            this.Enabled = false;

#if DEBUG
            this.MinimizeBox = false;
#else
            this.MinimizeBox = true;
#endif
        }

        /// <summary>
        /// This method is the actual thread, responsible for displaying the splash screen.
        /// The thread is very simple, it creates a SplashScreen object and displays it as a dialog to make
        /// sure that the worker thread remains alive until the splash screen is closed. This allows the MainForm
        /// to wait for the SplashScreenThread to terminate, knowing that it should display the application's
        /// main form as soon as the SplashScreenThread terminates.
        /// </summary>
        private void SplashScreenThread()
        {
            // show a splash screen as soon as possible, after which we continue
            // initializing our application.
            SplashScreen splashScreen = new SplashScreen(appInitialized, 15);
            splashScreen.ShowDialog();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            // Read all categories from the Live Expo Service and show them in a ListBox.
            LiveExpoCategories categories = LiveExpoCategories.Instance();
            List<LiveExpoCategory> categoryList = categories.GetCategories();
            if (categoryList != null)
            {
                foreach (LiveExpoCategory c in categoryList)
                {
                    listBox1.Items.Add(c.Name);
                }
            }

            // We are done initializing, so inform the splash screen that it can
            // close by setting an event.
            appInitialized.Set();
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;

            this.Enabled = true;
            this.Visible = true;

            // Wait until the splash screen is really closed and start working.
            splashScreenThread.Join();
            Thread.CurrentThread.Priority = ThreadPriority.Normal;
        }

        private void menuItemSettings_Click(object sender, EventArgs e)
        {
            SearchSettings searchSettingsForm = new SearchSettings();
            searchSettingsForm.ShowDialog();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            LiveExpoCategories categories = LiveExpoCategories.Instance();
            if (categories.NrCategoriesAvailable() > 0)
            {
                SearchResultsForm srf = new SearchResultsForm(listBox1.SelectedIndex);
                srf.ShowDialog();
            }
        }

    }
}

⌨️ 快捷键说明

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