outlook插件开发.docx
《outlook插件开发.docx》由会员分享,可在线阅读,更多相关《outlook插件开发.docx(35页珍藏版)》请在冰豆网上搜索。
![outlook插件开发.docx](https://file1.bdocx.com/fileroot1/2023-5/29/89d97a4c-285b-4023-84f5-17f518d39ada/89d97a4c-285b-4023-84f5-17f518d39ada1.gif)
outlook插件开发
向outlook2010中开发一个计算器的插件
1.开发环境介绍:
VS2010、outlook2010
2.具体步骤如下:
1)新建一个插件项目,如下图所示:
2)点击确定按钮,进入如下页面:
3)选择解决方案中的“OutlookAddIn1”右键—》添加---》新建项,如下图所示:
4)点击新建项目,进入以下页面:
5)选择“功能区(可视化设计器)”,出现如下页面
6)拖一个button控件到group1中,如下图所示:
7)新建一个winform页面命名为“Calculate”,如下图所示:
8)向Calculate页面中添加控件,设计成如下图所示的页面:
9)实现计算器的功能:
Calculate.cs文件的源代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceOutlookAddIn1
{
publicpartialclassCalculator:
Form
{
doublea,b;
stringm;
boolflag=false;
publicCalculator()
{
InitializeComponent();
}
///
///清?
除y
///
///
///
privatevoidbtnClear_Click(objectsender,EventArgse)
{
txtValue.Text="";
}
///
///数ºy值¦Ì7
///
///
///
privatevoidbtn7_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="7";
else
txtValue.Text="7";
}
///
///数ºy值¦Ì8
///
///
///
privatevoidbtn8_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="8";
else
txtValue.Text="8";
}
///
///数ºy值¦Ì9
///
///
///
privatevoidbtn9_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="9";
else
txtValue.Text="9";
}
///
///数ºy值¦Ì4
///
///
///
privatevoidbtn4_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="4";
else
txtValue.Text="4";
}
///
///数ºy值¦Ì5
///
///
///
privatevoidbtn5_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="5";
else
txtValue.Text="5";
}
///
///数ºy值¦Ì6
///
///
///
privatevoidbtn6_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="6";
else
txtValue.Text="6";
}
///
///数ºy值¦Ì1
///
///
///
privatevoidbtn1_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="1";
else
txtValue.Text="1";
}
///
///数ºy值¦Ì2
///
///
///
privatevoidbtn2_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="2";
else
txtValue.Text="2";
}
///
///数ºy值¦Ì3
///
///
///
privatevoidbtn3_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="3";
else
txtValue.Text="3";
}
///
///点Ì?
///
///
///
privatevoidbtn10_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
=""&&txtValue.Text.IndexOf('.')<=0)
txtValue.Text+=".";
}
///
///数ºy值¦Ì0
///
///
///
privatevoidbtn0_Click(objectsender,EventArgse)
{
if(txtValue.Text.Trim()!
="0")
txtValue.Text+="0";
else
txtValue.Text="0";
}
///
///等̨¨于®¨²号?
///
///
///
privatevoidbtn11_Click(objectsender,EventArgse)
{
Calculators();
}
///
///退ª?
位?
///
///
///
privatevoidbtnRemove_Click(objectsender,EventArgse)
{
stringvalue=txtValue.Text.Trim();
if(value.Length>0)
txtValue.Text=value.Substring(0,value.Length-1);
}
///
///除y号?
///
///
///
privatevoidbtn12_Click(objectsender,EventArgse)
{
Operation(btn12.Text);
}
///
///乘?
号?
///
///
///
privatevoidbtn13_Click(objectsender,EventArgse)
{
Operation(btn13.Text);
}
///
///减?
号?
///
///
///
privatevoidbtn14_Click(objectsender,EventArgse)
{
Operation(btn14.Text);
}
///
///加¨®号?
///
///
///
privatevoidbtn15_Click(objectsender,EventArgse)
{
Operation(btn15.Text);
}
///
///计?
算?
函¡¥数ºy
///
privatevoidCalculators()
{
b=Convert.ToDouble(txtValue.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="-"+(b-a).ToString();
else
txtValue.Text=(a-b).ToString();
flag=false;
break;
}
}
///
///运?
算?
符¤?
///
///
privatevoidOperation(stringstrValue)
{
if(flag)
Calculators();
a=Convert.ToDouble(txtValue.Text.Trim());
txtValue.Text="";
m=strValue;
flag=true;
}
}
}
Calculator.Desinger.cs代码如下:
namespaceOutlookAddIn1
{
partialclassCalculator
{
///
///Requireddesignervariable.
///
privateSystem.ComponentModel.IContainercomponents=null;
///
///Cleanupanyresourcesbeingused.
///
///trueifmanagedresourcesshouldbedisposed;otherwise,false.
protectedoverridevoidDispose(booldisposing)
{
if(disposing&&(components!
=null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#regionWindowsFormDesignergeneratedcode
///
///RequiredmethodforDesignersupport-donotmodify
///thecontentsofthismethodwiththecodeeditor.
///
privatevoidInitializeComponent()
{
this.txtValue=newSystem.Windows.Forms.TextBox();
this.btn7=newSystem.Windows.Forms.Button();
this.btn8=newSystem.Windows.Forms.Button();
this.btn9=newSystem.Windows.Forms.Button();
this.btnClear=newSystem.Windows.Forms.Button();
this.btn6=newSystem.Windows.Forms.Button();
this.btn5=newSystem.Windows.Forms.Button();
this.btn4=newSystem.Windows.Forms.Button();
this.btn3=newSystem.Windows.Forms.Button();
this.btn2=newSystem.Windows.Forms.Button();
this.btn1=newSystem.Windows.Forms.Button();
this.btn11=newSystem.Windows.Forms.Button();
this.btn0=newSystem.Windows.Forms.Button();
this.btn10=newSystem.Windows.Forms.Button();
this.btnRemove=newSystem.Windows.Forms.Button();
this.btn12=newSystem.Windows.Forms.Button();
this.btn13=newSystem.Windows.Forms.Button();
this.btn14=newSystem.Windows.Forms.Button();
this.btn15=newSystem.Windows.Forms.Button();
this.SuspendLayout();
//
//txtValue
//
this.txtValue.BackColor=System.Drawing.Color.Black;
this.txtValue.Font=newSystem.Drawing.Font("宋?
体¬?
",30F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.txtValue.ForeColor=System.Drawing.SystemColors.Info;
this.txtValue.Location=newSystem.Drawing.Point(13,13);
this.txtValue.Multiline=true;
this.txtValue.Name="txtValue";
this.txtValue.ReadOnly=true;
this.txtValue.Size=newSystem.Drawing.Size(432,56);
this.txtValue.TabIndex=0;
this.txtValue.TextAlign=System.Windows.Forms.HorizontalAlignment.Right;
//
//btn7
//
this.btn7.Cursor=System.Windows.Forms.Cursors.Hand;
this.btn7.Font=newSystem.Drawing.Font("宋?
体¬?
",20F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.btn7.Location=newSystem.Drawing.Point(12,144);
this.btn7.Name="btn7";
this.btn7.Size=newSystem.Drawing.Size(70,52);
this.btn7.TabIndex=1;
this.btn7.Text="7";
this.btn7.UseVisualStyleBackColor=true;
this.btn7.Click+=newSystem.EventHandler(this.btn7_Click);
//
//btn8
//
this.btn8.Cursor=System.Windows.Forms.Cursors.Hand;
this.btn8.Font=newSystem.Drawing.Font("宋?
体¬?
",20F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.btn8.Location=newSystem.Drawing.Point(109,144);
this.btn8.Name="btn8";
this.btn8.Size=newSystem.Drawing.Size(70,52);
this.btn8.TabIndex=2;
this.btn8.Text="8";
this.btn8.UseVisualStyleBackColor=true;
this.btn8.Click+=newSystem.EventHandler(this.btn8_Click);
//
//btn9
//
this.btn9.Cursor=System.Windows.Forms.Cursors.Hand;
this.btn9.Font=newSystem.Drawing.Font("宋?
体¬?
",20F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte)(134)));
this.btn9.Location=newSystem.Drawing.Point(200,144);
this.btn9.Name="btn9";
this.btn9.Size=newSystem.Drawing.Size(70,52);
this.btn9.TabIndex=3;
this.btn9.Text="9";
this.btn9.UseVisualStyleBackColor=true;
this.btn9.Click+=newSystem.EventHandler(this.btn9_Click);
//
//btnClear
//
this.btnClear.Cursor=System.Windows.Forms.Cursors.Hand;
this.btnCl