outlookform.cs

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

CS
996
字号
            // txtEmailAddr
            // 
            this.txtEmailAddr.Location = new System.Drawing.Point(7, 155);
            this.txtEmailAddr.Name = "txtEmailAddr";
            this.txtEmailAddr.Size = new System.Drawing.Size(121, 21);
            this.txtEmailAddr.TabIndex = 4;
            // 
            // txtNumber
            // 
            this.txtNumber.Location = new System.Drawing.Point(7, 208);
            this.txtNumber.Name = "txtNumber";
            this.txtNumber.Size = new System.Drawing.Size(121, 21);
            this.txtNumber.TabIndex = 5;
            // 
            // txtBody
            // 
            this.txtBody.Location = new System.Drawing.Point(7, 7);
            this.txtBody.MaxLength = 160;
            this.txtBody.Multiline = true;
            this.txtBody.Name = "txtBody";
            this.txtBody.Size = new System.Drawing.Size(226, 142);
            this.txtBody.TabIndex = 6;
            this.txtBody.Text = "type your message here";
            // 
            // tpRecurrence
            // 
            this.tpRecurrence.Controls.Add(this.lblInterval);
            this.tpRecurrence.Controls.Add(this.udInterval);
            this.tpRecurrence.Controls.Add(this.rbYearByNum);
            this.tpRecurrence.Controls.Add(this.rbMonthNum);
            this.tpRecurrence.Controls.Add(this.rbDaily);
            this.tpRecurrence.Controls.Add(this.lblInstances);
            this.tpRecurrence.Controls.Add(this.udOccurences);
            this.tpRecurrence.Controls.Add(this.rbYearly);
            this.tpRecurrence.Controls.Add(this.rbMonthly);
            this.tpRecurrence.Controls.Add(this.rbWeekly);
            this.tpRecurrence.Controls.Add(this.dtpStart);
            this.tpRecurrence.Controls.Add(this.btnRecurring);
            this.tpRecurrence.Controls.Add(this.treeView1);
            this.tpRecurrence.Location = new System.Drawing.Point(0, 0);
            this.tpRecurrence.Name = "tpRecurrence";
            this.tpRecurrence.Size = new System.Drawing.Size(232, 242);
            this.tpRecurrence.Text = "Recurrence";
            this.tpRecurrence.Click += new System.EventHandler(this.tpRecurrence_Click);
            // 
            // lblInterval
            // 
            this.lblInterval.Location = new System.Drawing.Point(133, 115);
            this.lblInterval.Name = "lblInterval";
            this.lblInterval.Size = new System.Drawing.Size(59, 20);
            this.lblInterval.Text = "Interval:";
            // 
            // udInterval
            // 
            this.udInterval.Location = new System.Drawing.Point(189, 115);
            this.udInterval.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.udInterval.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.udInterval.Name = "udInterval";
            this.udInterval.Size = new System.Drawing.Size(43, 22);
            this.udInterval.TabIndex = 10;
            this.udInterval.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // rbYearByNum
            // 
            this.rbYearByNum.Location = new System.Drawing.Point(160, 86);
            this.rbYearByNum.Name = "rbYearByNum";
            this.rbYearByNum.Size = new System.Drawing.Size(77, 20);
            this.rbYearByNum.TabIndex = 9;
            this.rbYearByNum.Text = "Yr /num";
            // 
            // rbMonthNum
            // 
            this.rbMonthNum.Location = new System.Drawing.Point(82, 86);
            this.rbMonthNum.Name = "rbMonthNum";
            this.rbMonthNum.Size = new System.Drawing.Size(79, 20);
            this.rbMonthNum.TabIndex = 8;
            this.rbMonthNum.Text = "Mth /num";
            // 
            // rbDaily
            // 
            this.rbDaily.Location = new System.Drawing.Point(8, 86);
            this.rbDaily.Name = "rbDaily";
            this.rbDaily.Size = new System.Drawing.Size(68, 20);
            this.rbDaily.TabIndex = 7;
            this.rbDaily.Text = "Daily";
            // 
            // lblInstances
            // 
            this.lblInstances.Location = new System.Drawing.Point(8, 114);
            this.lblInstances.Name = "lblInstances";
            this.lblInstances.Size = new System.Drawing.Size(78, 21);
            this.lblInstances.Text = "Occurences:";
            // 
            // udOccurences
            // 
            this.udOccurences.Location = new System.Drawing.Point(82, 115);
            this.udOccurences.Maximum = new decimal(new int[] {
            15,
            0,
            0,
            0});
            this.udOccurences.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.udOccurences.Name = "udOccurences";
            this.udOccurences.Size = new System.Drawing.Size(45, 22);
            this.udOccurences.TabIndex = 6;
            this.udOccurences.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            // 
            // rbYearly
            // 
            this.rbYearly.Location = new System.Drawing.Point(160, 60);
            this.rbYearly.Name = "rbYearly";
            this.rbYearly.Size = new System.Drawing.Size(73, 20);
            this.rbYearly.TabIndex = 5;
            this.rbYearly.TabStop = false;
            this.rbYearly.Text = "Yearly";
            // 
            // rbMonthly
            // 
            this.rbMonthly.Location = new System.Drawing.Point(82, 60);
            this.rbMonthly.Name = "rbMonthly";
            this.rbMonthly.Size = new System.Drawing.Size(71, 20);
            this.rbMonthly.TabIndex = 4;
            this.rbMonthly.TabStop = false;
            this.rbMonthly.Text = "Monthly";
            // 
            // rbWeekly
            // 
            this.rbWeekly.Checked = true;
            this.rbWeekly.Location = new System.Drawing.Point(8, 60);
            this.rbWeekly.Name = "rbWeekly";
            this.rbWeekly.Size = new System.Drawing.Size(68, 20);
            this.rbWeekly.TabIndex = 3;
            this.rbWeekly.Text = "Weekly";
            // 
            // dtpStart
            // 
            this.dtpStart.Location = new System.Drawing.Point(8, 31);
            this.dtpStart.MaxDate = new System.DateTime(2010, 12, 31, 0, 0, 0, 0);
            this.dtpStart.MinDate = new System.DateTime(2007, 1, 1, 0, 0, 0, 0);
            this.dtpStart.Name = "dtpStart";
            this.dtpStart.Size = new System.Drawing.Size(225, 22);
            this.dtpStart.TabIndex = 2;
            // 
            // btnRecurring
            // 
            this.btnRecurring.Location = new System.Drawing.Point(8, 4);
            this.btnRecurring.Name = "btnRecurring";
            this.btnRecurring.Size = new System.Drawing.Size(225, 20);
            this.btnRecurring.TabIndex = 1;
            this.btnRecurring.Text = "Create Recurring Appointment";
            this.btnRecurring.Click += new System.EventHandler(this.btnRecurring_Click);
            // 
            // treeView1
            // 
            this.treeView1.Location = new System.Drawing.Point(7, 143);
            this.treeView1.Name = "treeView1";
            this.treeView1.Size = new System.Drawing.Size(229, 99);
            this.treeView1.TabIndex = 0;
            // 
            // openFileDialog1
            // 
            this.openFileDialog1.FileName = "openFileDialog1";
            this.openFileDialog1.Filter = "All Files|*.*";
            // 
            // btnSync
            // 
            this.btnSync.Location = new System.Drawing.Point(179, 182);
            this.btnSync.Name = "btnSync";
            this.btnSync.Size = new System.Drawing.Size(54, 20);
            this.btnSync.TabIndex = 9;
            this.btnSync.Text = "Sync";
            this.btnSync.Click += new System.EventHandler(this.btnSync_Click);
            // 
            // btnCompose
            // 
            this.btnCompose.Location = new System.Drawing.Point(101, 182);
            this.btnCompose.Name = "btnCompose";
            this.btnCompose.Size = new System.Drawing.Size(72, 20);
            this.btnCompose.TabIndex = 10;
            this.btnCompose.Text = "Compose";
            this.btnCompose.Click += new System.EventHandler(this.btnCompose_Click);
            // 
            // OutlookForm
            // 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
            this.ClientSize = new System.Drawing.Size(240, 268);
            this.Controls.Add(this.tabControl1);
            this.Menu = this.mainMenu1;
            this.MinimizeBox = false;
            this.Name = "OutlookForm";
            this.Text = "Pocket Outlook";
            this.Closing += new System.ComponentModel.CancelEventHandler(this.OutlookForm_Closing);
            this.Load += new System.EventHandler(this.OutlookForm_Load);
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.tabPage2.ResumeLayout(false);
            this.tpRecurrence.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		private void mnuExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void OutlookForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
            session.Dispose();
			dataGrid1.DataSource = null;
			oic.Dispose();
			oic = null;
		}

		private void radContacts_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radContacts.Checked)
			{
				oic.Dispose();
                oic = session.Contacts.Items;

                dataGrid1.DataSource = oic;
			}
		}

		private void radTasks_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radTasks.Checked)
			{
				oic.Dispose();
                oic = session.Tasks.Items.Restrict("[Complete] = FALSE");
                dataGrid1.DataSource = oic;
			}	
		}


		private void radCalendar_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radCalendar.Checked)
			{
				oic.Dispose();
				oic = session.Appointments.Items;
				dataGrid1.DataSource = oic;
			}
		}

		private void btnNew_Click(object sender, System.EventArgs e)
		{
            PimItem pi = (PimItem)oic.AddNew();
            pi.ShowDialog();
		}

		private void btnChange_Click(object sender, System.EventArgs e)
		{
            object o = this.BindingContext[dataGrid1.DataSource].Current;
            if (o is PimItem)
            {
                PimItem oi = (PimItem)o;

                oi.ShowDialog();
            }		
		}

		private void btnRemove_Click(object sender, System.EventArgs e)
		{
            object o = this.BindingContext[dataGrid1.DataSource].Current;
            if (o is Appointment)
            {
                ((Appointment)o).Delete();
            }
            if (o is Contact)
            {
                ((Contact)o).Delete();
            }
            if (o is Task)
            {
                ((Task)o).Delete();
            }
			
		}

       
	
		private void OutlookForm_Load(object sender, System.EventArgs e)
		{
			//create new outlook application instance
			session = new OutlookSession();

            oic = session.Appointments.Items;
			dataGrid1.DataSource = oic;
		}

        
        private class Item
        {
            public Item(string name, object value)
            {
                this.name = name;
                this.value = value;
            }
            public string name;
            public object value;
        }
        private DataTable GetSystemState()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Value", typeof(object));

            System.Reflection.PropertyInfo[] pis = typeof(Microsoft.WindowsMobile.Status.SystemState).GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
            foreach (System.Reflection.PropertyInfo pi in pis)

⌨️ 快捷键说明

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