Extrait de code : gestionnaire de Ruban personnalisé
Dernière modification : vendredi 14 mai 2010
S’applique à : SharePoint Server 2010
L’exemple suivant montre l’implémentation d’un gestionnaire de Ruban personnalisé.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.BusinessApplications.Runtime;
using outlookPIA = Microsoft.Office.Interop.Outlook;
using Microsoft.BusinessData.Runtime;
using Microsoft.Office.BusinessData.Offlining;
using Microsoft.BusinessData.MetadataModel;
namespace ContosoCustomer
{
[ComVisible(true)]
public class CustomRibbonManager : Microsoft.Office.BusinessApplications.Runtime.RibbonManager
{
public static outlookPIA.Application currentOutlookApplication;
public override bool GetEnabled(IRibbonControl control)
{
//Retrive trusted Outlook Interop object.
if (currentOutlookApplication == null)
{
outlookPIA.Inspector CurrentInspector = control.Context as outlookPIA.Inspector;
currentOutlookApplication = CurrentInspector.Application as outlookPIA.Application;
}
return base.GetEnabled(control);
}
public override void OnAction(IRibbonControl control)
{
base.OnAction(control);
}
public override string GetCustomUI(string ribbonID)
{
return base.GetCustomUI(ribbonID);
}
public override bool GetVisible(IRibbonControl control)
{
return base.GetVisible(control);
}
public override void OnLoad(IRibbonUI ribbon)
{
base.OnLoad(ribbon);
}
}
}