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

📄 mainform.cs

📁 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 Microsoft.WindowsMobile.PocketOutlook;

namespace AccessingTasks
{
	public partial class MainForm : Form
	{
		OutlookSession m_outlookSession;

		public MainForm()
		{
			InitializeComponent();

			m_outlookSession = new OutlookSession();
			m_refreshTasks();
		}

		private void m_refreshTasks()
		{
			m_lstTasks.Items.Clear();

			try
			{
				foreach(Task t in m_outlookSession.Tasks.Items)
				{
					ListViewItem item = new ListViewItem(
						new string[]
						{
							t.Subject,
							t.Importance.ToString(),
							t.StartDate.ToString(),
							t.Complete.ToString()
						});

					if(t.Importance == Importance.High)
						item.ForeColor = Color.Red;
					else if(t.Importance == Importance.Low)
						item.ForeColor = Color.DarkGray;

					if(t.Complete)
						item.BackColor = Color.LightGray;

					m_lstTasks.Items.Add(item);
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(
					String.Format("Error: {0}", ex.Message),
					"Refresh",
					MessageBoxButtons.OK,
					MessageBoxIcon.Hand,
					MessageBoxDefaultButton.Button1);
			}
		}

		private void m_mnuNew_Click(object sender, EventArgs e)
		{
			try
			{
				Task t = m_outlookSession.Tasks.Items.AddNew();
				t.ShowDialog();
			}
			catch(Exception ex)
			{
				MessageBox.Show(
					String.Format("Error: {0}", ex.Message),
					"Refresh",
					MessageBoxButtons.OK,
					MessageBoxIcon.Hand,
					MessageBoxDefaultButton.Button1);
			}
		}

		private void m_mnuDetails_Click(object sender, EventArgs e)
		{
			if(m_lstTasks.SelectedIndices.Count == 0)
				return;

			int activeIndex = m_lstTasks.SelectedIndices[0];
			Task activeTask = m_outlookSession.Tasks.Items[activeIndex];
			activeTask.ShowDialog();
		}

		private void MainForm_Activated(object sender, EventArgs e)
		{
			m_refreshTasks();
		}

		private void m_lstTasks_ItemActivate(object sender, EventArgs e)
		{
			m_mnuDetails_Click(sender, e);
		}
	}
}

⌨️ 快捷键说明

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