1、outlook插件开发向outlook2010中开发一个计算器的插件1. 开发环境介绍:VS 2010、outlook 20102. 具体步骤如下:1) 新建一个插件项目,如下图所示:2) 点击确定按钮,进入如下页面:3) 选择解决方案中的“OutlookAddIn1”右键添加-新建项,如下图所示:4) 点击新建项目,进入以下页面:5) 选择“功能区(可视化设计器)”,出现如下页面6) 拖一个button控件到group1中,如下图所示:7) 新建一个winform页面命名为“Calculate”,如下图所示:8) 向Calculate页面中添加控件,设计成如下图所示的页面:9) 实现计算器的
2、功能:Calculate.cs文件的源代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace OutlookAddIn1 public partial class Calculator : Form double a, b; string m; bool flag = fa
3、lse; public Calculator() InitializeComponent(); / / 清?除y / / / private void btnClear_Click(object sender, EventArgs e) txtValue.Text = ; / / 数y值7 / / / private void btn7_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 7; else txtValue.Text = 7; / / 数y值8 / / / privat
4、e void btn8_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 8; else txtValue.Text = 8; / / 数y值9 / / / private void btn9_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 9; else txtValue.Text = 9; / / 数y值4 / / / private void btn4_Clic
5、k(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 4; else txtValue.Text = 4; / / 数y值5 / / / private void btn5_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 5; else txtValue.Text = 5; / / 数y值6 / / / private void btn6_Click(object sender,
6、 EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 6; else txtValue.Text = 6; / / 数y值1 / / / private void btn1_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 1; else txtValue.Text = 1; / / 数y值2 / / / private void btn2_Click(object sender, EventArgs e) if
7、 (txtValue.Text.Trim() != 0) txtValue.Text += 2; else txtValue.Text = 2; / / 数y值3 / / / private void btn3_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 3; else txtValue.Text = 3; / / 点? / / / private void btn10_Click(object sender, EventArgs e) if (txtValue.Text.T
8、rim() != & txtValue.Text.IndexOf(.)= 0) txtValue.Text += .; / / 数y值0 / / / private void btn0_Click(object sender, EventArgs e) if (txtValue.Text.Trim() != 0) txtValue.Text += 0; else txtValue.Text = 0; / / 等于号? / / / private void btn11_Click(object sender, EventArgs e) Calculators(); / / 退?位? / / /
9、private void btnRemove_Click(object sender, EventArgs e) string value = txtValue.Text.Trim(); if (value.Length 0) txtValue.Text = value.Substring(0, value.Length - 1); / / 除y号? / / / private void btn12_Click(object sender, EventArgs e) Operation(btn12.Text); / / 乘?号? / / / private void btn13_Click(o
10、bject sender, EventArgs e) Operation(btn13.Text); / / 减?号? / / / private void btn14_Click(object sender, EventArgs e) Operation(btn14.Text); / / 加号? / / / private void btn15_Click(object sender, EventArgs e) Operation(btn15.Text); / / 计?算?函数y / private void Calculators() b = Convert.ToDouble(txtValu
11、e.Text.Trim(); switch (m) case (/): if (b != 0) txtValue.Text = (a / b).ToString(); else txtValue.Text = 0; flag = false; break; case (X): txtValue.Text = (a * b).ToString(); flag = false; break; case (+): txtValue.Text = (a + b).ToString(); flag = false; break; case (-): if (b a) txtValue.Text = -
12、+ (b - a).ToString(); else txtValue.Text = (a - b).ToString(); flag = false; break; / / 运?算?符? / / private void Operation(string strValue) if (flag) Calculators(); a = Convert.ToDouble(txtValue.Text.Trim(); txtValue.Text = ; m = strValue; flag = true; Calculator.Desinger.cs代码如下:namespace OutlookAddI
13、n1 partial class Calculator / / Required designer variable. / private System.ComponentModel.IContainer components = null; / / Clean up any resources being used. / / true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) if (disposing & (compon
14、ents != null) components.Dispose(); base.Dispose(disposing); #region Windows Form Designer generated code / / Required method for Designer support - do not modify / the contents of this method with the code editor. / private void InitializeComponent() this.txtValue = new System.Windows.Forms.TextBox
15、(); this.btn7 = new System.Windows.Forms.Button(); this.btn8 = new System.Windows.Forms.Button(); this.btn9 = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); this.btn6 = new System.Windows.Forms.Button(); this.btn5 = new System.Windows.Forms.Button(); this.btn4
16、= new System.Windows.Forms.Button(); this.btn3 = new System.Windows.Forms.Button(); this.btn2 = new System.Windows.Forms.Button(); this.btn1 = new System.Windows.Forms.Button(); this.btn11 = new System.Windows.Forms.Button(); this.btn0 = new System.Windows.Forms.Button(); this.btn10 = new System.Win
17、dows.Forms.Button(); this.btnRemove = new System.Windows.Forms.Button(); this.btn12 = new System.Windows.Forms.Button(); this.btn13 = new System.Windows.Forms.Button(); this.btn14 = new System.Windows.Forms.Button(); this.btn15 = new System.Windows.Forms.Button(); this.SuspendLayout(); / / txtValue
18、/ this.txtValue.BackColor = System.Drawing.Color.Black; this.txtValue.Font = new System.Drawing.Font(宋?体?, 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)(134); this.txtValue.ForeColor = System.Drawing.SystemColors.Info; this.txtValue.Location = new System.Drawing.Po
19、int(13, 13); this.txtValue.Multiline = true; this.txtValue.Name = txtValue; this.txtValue.ReadOnly = true; this.txtValue.Size = new System.Drawing.Size(432, 56); this.txtValue.TabIndex = 0; this.txtValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; / / btn7 / this.btn7.Cursor = System
20、.Windows.Forms.Cursors.Hand; this.btn7.Font = new System.Drawing.Font(宋?体?, 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (byte)(134); this.btn7.Location = new System.Drawing.Point(12, 144); this.btn7.Name = btn7; this.btn7.Size = new System.Drawing.Size(70, 52); this.btn7.T
21、abIndex = 1; this.btn7.Text = 7; this.btn7.UseVisualStyleBackColor = true; this.btn7.Click += new System.EventHandler(this.btn7_Click); / / btn8 / this.btn8.Cursor = System.Windows.Forms.Cursors.Hand; this.btn8.Font = new System.Drawing.Font(宋?体?, 20F, System.Drawing.FontStyle.Bold, System.Drawing.G
22、raphicsUnit.Point, (byte)(134); this.btn8.Location = new System.Drawing.Point(109, 144); this.btn8.Name = btn8; this.btn8.Size = new System.Drawing.Size(70, 52); this.btn8.TabIndex = 2; this.btn8.Text = 8; this.btn8.UseVisualStyleBackColor = true; this.btn8.Click += new System.EventHandler(this.btn8
23、_Click); / / btn9 / this.btn9.Cursor = System.Windows.Forms.Cursors.Hand; this.btn9.Font = new System.Drawing.Font(宋?体?, 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (byte)(134); this.btn9.Location = new System.Drawing.Point(200, 144); this.btn9.Name = btn9; this.btn9.Size = new System.Drawing.Size(70, 52); this.btn9.TabIndex = 3; this.btn9.Text = 9; this.btn9.UseVisualStyleBackColor = true; this.btn9.Click += new System.EventHandler(this.btn9_Click); / / btnClear / this.btnClear.Cursor = System.Windows.Forms.Cursors.Hand; this.btnCl
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1