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 AccessingAppointments
- {
- public partial class MainForm : Form
- {
- OutlookSession m_outlookSession;
- public MainForm()
- {
- InitializeComponent();
- m_outlookSession = new OutlookSession();
- m_refreshAppointments();
- }
- private void m_refreshAppointments()
- {
- m_lstAppointments.Items.Clear();
- try
- {
- foreach(Appointment a in m_outlookSession.Appointments.Items)
- {
- ListViewItem item = new ListViewItem(
- new string[]
- {
- a.Subject,
- a.Start.ToString(),
- a.End.ToString()
- });
- if(a.End < DateTime.Now)
- item.ForeColor = Color.Gray;
- else if(a.Start > DateTime.Now)
- item.ForeColor = Color.Black;
- else
- item.ForeColor = Color.Blue;
- m_lstAppointments.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
- {
- Appointment a = m_outlookSession.Appointments.Items.AddNew();
- a.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_lstAppointments.SelectedIndices.Count == 0)
- return;
- int activeIndex = m_lstAppointments.SelectedIndices[0];
- Appointment activeAppointment = m_outlookSession.Appointments.Items[activeIndex];
- activeAppointment.ShowDialog();
- }
- private void MainForm_Activated(object sender, EventArgs e)
- {
- m_refreshAppointments();
- }
- private void m_lstAppointments_ItemActivate(object sender, EventArgs e)
- {
- m_mnuDetails_Click(sender, e);
- }
- }
- }