MainForm.cs
上传用户:linger1010
上传日期:2008-12-08
资源大小:561k
文件大小:2k
- 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);
- }
- }
- }