outlookform.cs

来自「清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码」· CS 代码 · 共 996 行 · 第 1/3 页

CS
996
字号
using System;
using System.Drawing;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using Microsoft.WindowsMobile.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;


namespace Chapter17
{
	public class OutlookForm : System.Windows.Forms.Form
	{

        private OutlookSession session;
        

        private System.Windows.Forms.MenuItem mnuOptions;
		private System.Windows.Forms.MainMenu mainMenu1;
		
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.RadioButton radCalendar;
		private System.Windows.Forms.RadioButton radContacts;
		private System.Windows.Forms.RadioButton radTasks;
		private System.Windows.Forms.Button btnNew;
		private System.Windows.Forms.Button btnChange;
		private System.Windows.Forms.Button btnRemove;
        private PimItemCollection oic;
        private int sort = 0;
        private TabControl tabControl1;
        private TabPage tabPage1;
        private TabPage tabPage2;
        private Button btnEmail;
        private Button btnSms;
        private TextBox txtEmailAddr;
        private TextBox txtNumber;
        private TextBox txtBody;
        private RadioButton rbStatus;
        private Button btnAttach;
        private OpenFileDialog openFileDialog1;
        private TabPage tpRecurrence;
        private Button btnRecurring;
        private TreeView treeView1;
        private Label lblInstances;
        private NumericUpDown udOccurences;
        private RadioButton rbYearly;
        private RadioButton rbMonthly;
        private RadioButton rbWeekly;
        private DateTimePicker dtpStart;
        private RadioButton rbYearByNum;
        private RadioButton rbMonthNum;
        private RadioButton rbDaily;
        private Label lblInterval;
        private NumericUpDown udInterval;
        private Button btnLookupSms;
        private Button btnLookupEmail;
        private MenuItem mnuExit;
        private MenuItem mnuAddSample;
        private Button btnSync;
        private Button btnCompose;

        private MessageInterceptor mi;

		
		public OutlookForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//	
            mi = new MessageInterceptor(InterceptionAction.Notify);
            mi.MessageReceived += new MessageInterceptorEventHandler(mi_MessageReceived);

            
        }

        

        void mi_MessageReceived(object sender, MessageInterceptorEventArgs e)
        {
            MessageBox.Show(((SmsMessage)e.Message).Body);
        }
        
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.mnuExit = new System.Windows.Forms.MenuItem();
            this.mnuOptions = new System.Windows.Forms.MenuItem();
            this.mnuAddSample = new System.Windows.Forms.MenuItem();
            this.btnNew = new System.Windows.Forms.Button();
            this.dataGrid1 = new System.Windows.Forms.DataGrid();
            this.radCalendar = new System.Windows.Forms.RadioButton();
            this.radContacts = new System.Windows.Forms.RadioButton();
            this.radTasks = new System.Windows.Forms.RadioButton();
            this.btnChange = new System.Windows.Forms.Button();
            this.btnRemove = new System.Windows.Forms.Button();
            this.rbStatus = new System.Windows.Forms.RadioButton();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.btnLookupSms = new System.Windows.Forms.Button();
            this.btnLookupEmail = new System.Windows.Forms.Button();
            this.btnAttach = new System.Windows.Forms.Button();
            this.btnEmail = new System.Windows.Forms.Button();
            this.btnSms = new System.Windows.Forms.Button();
            this.txtEmailAddr = new System.Windows.Forms.TextBox();
            this.txtNumber = new System.Windows.Forms.TextBox();
            this.txtBody = new System.Windows.Forms.TextBox();
            this.tpRecurrence = new System.Windows.Forms.TabPage();
            this.lblInterval = new System.Windows.Forms.Label();
            this.udInterval = new System.Windows.Forms.NumericUpDown();
            this.rbYearByNum = new System.Windows.Forms.RadioButton();
            this.rbMonthNum = new System.Windows.Forms.RadioButton();
            this.rbDaily = new System.Windows.Forms.RadioButton();
            this.lblInstances = new System.Windows.Forms.Label();
            this.udOccurences = new System.Windows.Forms.NumericUpDown();
            this.rbYearly = new System.Windows.Forms.RadioButton();
            this.rbMonthly = new System.Windows.Forms.RadioButton();
            this.rbWeekly = new System.Windows.Forms.RadioButton();
            this.dtpStart = new System.Windows.Forms.DateTimePicker();
            this.btnRecurring = new System.Windows.Forms.Button();
            this.treeView1 = new System.Windows.Forms.TreeView();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.btnSync = new System.Windows.Forms.Button();
            this.btnCompose = new System.Windows.Forms.Button();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.tpRecurrence.SuspendLayout();
            this.SuspendLayout();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.mnuExit);
            this.mainMenu1.MenuItems.Add(this.mnuOptions);
            // 
            // mnuExit
            // 
            this.mnuExit.Text = "Exit";
            this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
            // 
            // mnuOptions
            // 
            this.mnuOptions.MenuItems.Add(this.mnuAddSample);
            this.mnuOptions.Text = "Options";
            // 
            // mnuAddSample
            // 
            this.mnuAddSample.Text = "Add Sample content";
            this.mnuAddSample.Click += new System.EventHandler(this.mnuAddSample_Click);
            // 
            // btnNew
            // 
            this.btnNew.Location = new System.Drawing.Point(8, 7);
            this.btnNew.Name = "btnNew";
            this.btnNew.Size = new System.Drawing.Size(40, 24);
            this.btnNew.TabIndex = 1;
            this.btnNew.Text = "New";
            this.btnNew.Click += new System.EventHandler(this.btnNew_Click);
            // 
            // dataGrid1
            // 
            this.dataGrid1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
            this.dataGrid1.Location = new System.Drawing.Point(8, 37);
            this.dataGrid1.Name = "dataGrid1";
            this.dataGrid1.Size = new System.Drawing.Size(224, 146);
            this.dataGrid1.TabIndex = 5;
            // 
            // radCalendar
            // 
            this.radCalendar.Checked = true;
            this.radCalendar.Location = new System.Drawing.Point(3, 189);
            this.radCalendar.Name = "radCalendar";
            this.radCalendar.Size = new System.Drawing.Size(84, 24);
            this.radCalendar.TabIndex = 7;
            this.radCalendar.Text = "Calendar";
            this.radCalendar.CheckedChanged += new System.EventHandler(this.radCalendar_CheckedChanged);
            // 
            // radContacts
            // 
            this.radContacts.Location = new System.Drawing.Point(87, 189);
            this.radContacts.Name = "radContacts";
            this.radContacts.Size = new System.Drawing.Size(78, 24);
            this.radContacts.TabIndex = 8;
            this.radContacts.Text = "Contacts";
            this.radContacts.CheckedChanged += new System.EventHandler(this.radContacts_CheckedChanged);
            // 
            // radTasks
            // 
            this.radTasks.Location = new System.Drawing.Point(171, 189);
            this.radTasks.Name = "radTasks";
            this.radTasks.Size = new System.Drawing.Size(62, 24);
            this.radTasks.TabIndex = 6;
            this.radTasks.Text = "Tasks";
            this.radTasks.CheckedChanged += new System.EventHandler(this.radTasks_CheckedChanged);
            // 
            // btnChange
            // 
            this.btnChange.Location = new System.Drawing.Point(54, 7);
            this.btnChange.Name = "btnChange";
            this.btnChange.Size = new System.Drawing.Size(56, 24);
            this.btnChange.TabIndex = 2;
            this.btnChange.Text = "Change";
            this.btnChange.Click += new System.EventHandler(this.btnChange_Click);
            // 
            // btnRemove
            // 
            this.btnRemove.Location = new System.Drawing.Point(116, 7);
            this.btnRemove.Name = "btnRemove";
            this.btnRemove.Size = new System.Drawing.Size(56, 24);
            this.btnRemove.TabIndex = 4;
            this.btnRemove.Text = "Remove";
            this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
            // 
            // rbStatus
            // 
            this.rbStatus.Location = new System.Drawing.Point(3, 219);
            this.rbStatus.Name = "rbStatus";
            this.rbStatus.Size = new System.Drawing.Size(63, 20);
            this.rbStatus.TabIndex = 3;
            this.rbStatus.Text = "Status";
            this.rbStatus.CheckedChanged += new System.EventHandler(this.rbStatus_CheckedChanged);
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Controls.Add(this.tpRecurrence);
            this.tabControl1.Location = new System.Drawing.Point(0, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(240, 268);
            this.tabControl1.TabIndex = 0;
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.btnNew);
            this.tabPage1.Controls.Add(this.btnChange);
            this.tabPage1.Controls.Add(this.rbStatus);
            this.tabPage1.Controls.Add(this.btnRemove);
            this.tabPage1.Controls.Add(this.dataGrid1);
            this.tabPage1.Controls.Add(this.radTasks);
            this.tabPage1.Controls.Add(this.radCalendar);
            this.tabPage1.Controls.Add(this.radContacts);
            this.tabPage1.Location = new System.Drawing.Point(0, 0);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Size = new System.Drawing.Size(240, 245);
            this.tabPage1.Text = "View";
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.Add(this.btnCompose);
            this.tabPage2.Controls.Add(this.btnSync);
            this.tabPage2.Controls.Add(this.btnLookupSms);
            this.tabPage2.Controls.Add(this.btnLookupEmail);
            this.tabPage2.Controls.Add(this.btnAttach);
            this.tabPage2.Controls.Add(this.btnEmail);
            this.tabPage2.Controls.Add(this.btnSms);
            this.tabPage2.Controls.Add(this.txtEmailAddr);
            this.tabPage2.Controls.Add(this.txtNumber);
            this.tabPage2.Controls.Add(this.txtBody);
            this.tabPage2.Location = new System.Drawing.Point(0, 0);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Size = new System.Drawing.Size(240, 245);
            this.tabPage2.Text = "Send";
            // 
            // btnLookupSms
            // 
            this.btnLookupSms.Location = new System.Drawing.Point(135, 208);
            this.btnLookupSms.Name = "btnLookupSms";
            this.btnLookupSms.Size = new System.Drawing.Size(38, 20);
            this.btnLookupSms.TabIndex = 8;
            this.btnLookupSms.Text = "...";
            this.btnLookupSms.Click += new System.EventHandler(this.btnLookupSms_Click);
            // 
            // btnLookupEmail
            // 
            this.btnLookupEmail.Location = new System.Drawing.Point(135, 155);
            this.btnLookupEmail.Name = "btnLookupEmail";
            this.btnLookupEmail.Size = new System.Drawing.Size(38, 20);
            this.btnLookupEmail.TabIndex = 7;
            this.btnLookupEmail.Text = "...";
            this.btnLookupEmail.Click += new System.EventHandler(this.btnLookupEmail_Click);
            // 
            // btnAttach
            // 
            this.btnAttach.Location = new System.Drawing.Point(7, 182);
            this.btnAttach.Name = "btnAttach";
            this.btnAttach.Size = new System.Drawing.Size(64, 20);
            this.btnAttach.TabIndex = 0;
            this.btnAttach.Text = "Attach";
            this.btnAttach.Click += new System.EventHandler(this.btnAttach_Click);
            // 
            // btnEmail
            // 
            this.btnEmail.Location = new System.Drawing.Point(179, 155);
            this.btnEmail.Name = "btnEmail";
            this.btnEmail.Size = new System.Drawing.Size(54, 20);
            this.btnEmail.TabIndex = 2;
            this.btnEmail.Text = "Email";
            this.btnEmail.Click += new System.EventHandler(this.btnEmail_Click);
            // 
            // btnSms
            // 
            this.btnSms.Location = new System.Drawing.Point(179, 208);
            this.btnSms.Name = "btnSms";
            this.btnSms.Size = new System.Drawing.Size(54, 20);
            this.btnSms.TabIndex = 3;
            this.btnSms.Text = "Sms";
            this.btnSms.Click += new System.EventHandler(this.btnSms_Click);
            // 

⌨️ 快捷键说明

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