1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public partial class ThisAddIn
{
private UserControlA myControl1;
private UserControlA myControl2;
private UserControlA myControl3;
private List<UserControlA> myControlX;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane1;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane2;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane3;
private List<Microsoft.Office.Tools.CustomTaskPane> myCustomTaskPaneX;
int iNbOfInstances=0 //to count and identify instances
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
myControl1 = new UserControlA();
myControl2 = new UserControlA();
myControl3 = new UserControlA();
myControlX = new List<UserControlA> {myControl1, myControl2, myControl3};
myCustomTaskPaneX = new List<Microsoft.Office.Tools.CustomTaskPane> { myCustomTaskPane1, myCustomTaskPane2, myCustomTaskPane3};
((EApplication_Event)this.Application).NewPresentation +=
new PowerPoint.EApplication_NewPresentationEventHandler(
Application_NewPrez);
this.Application.PresentationOpen +=
new PowerPoint.EApplication_PresentationOpenEventHandler(
Application_NewPrez);
}
private void Application_NewPrez(PowerPoint.Presentation Prez)
{
if (iNbOfInstances >= 0 && iNbOfInstances <= 3)
{
// I add the panel, make it visible, and increment the number of instance for the next use
myCustomTaskPaneX[iNbOfInstances] = this.CustomTaskPanes.Add(myControlX[iNbOfInstances], "AddinName");
myCustomTaskPaneX[iNbOfInstances].Visible = true;
iNbOfInstances++;
}
} |
Partager