|
//*****************************************************************************
//
// File: PreviewEventsProvider.cs
//
// Contents: definition for preview events provider
//
//*****************************************************************************
using RibbonLib.Interop;
namespace RibbonLib.Controls.Events
{
/// <summary>
/// Signature for OnPreview event
/// </summary>
/// <param name="key">the property that has changed</param>
/// <param name="currentValue">the new value of the property that has changed</param>
/// <param name="commandExecutionProperties">additional data for this execution</param>
public delegate void OnPreviewEventHandler(PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties);
/// <summary>
/// Signature for OnCancelPreview event
/// </summary>
/// <param name="key">the property that has changed</param>
/// <param name="currentValue">the new value of the property that has changed</param>
/// <param name="commandExecutionProperties">additional data for this execution</param>
public delegate void OnCancelPreviewEventHandler(PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties);
/// <summary>
/// Definition for Execute events provider
/// </summary>
public interface IPreviewEventsProvider
{
/// <summary>
/// Preview event
/// </summary>
event OnPreviewEventHandler OnPreview;
/// <summary>
/// Cancel Preview event
/// </summary>
event OnCancelPreviewEventHandler OnCancelPreview;
}
/// <summary>
/// Implementation of IPreviewEventsProvider
/// </summary>
class PreviewEventsProvider : BaseEventsProvider, IPreviewEventsProvider
{
public PreviewEventsProvider()
{
SupportedEvents.Add(ExecutionVerb.Preview);
SupportedEvents.Add(ExecutionVerb.CancelPreview);
}
/// <summary>
/// Handles IUICommandHandler.Execute function for supported events
/// </summary>
/// <param name="verb">the mode of execution</param>
/// <param name="key">the property that has changed</param>
/// <param name="currentValue">the new value of the property that has changed</param>
/// <param name="commandExecutionProperties">additional data for this execution</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
public override HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
{
switch (verb)
{
case ExecutionVerb.Preview:
if (OnPreview != null)
{
OnPreview(key, currentValue, commandExecutionProperties);
}
break;
case ExecutionVerb.CancelPreview:
if (OnCancelPreview != null)
{
OnCancelPreview(key, currentValue, commandExecutionProperties);
}
break;
}
return HRESULT.S_OK;
}
#region IPreviewEventsProvider Members
/// <summary>
/// Preview event
/// </summary>
public event OnPreviewEventHandler OnPreview;
/// <summary>
/// Cancel Preview event
/// </summary>
public event OnCancelPreviewEventHandler OnCancelPreview;
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Arik Poznanski is a senior software developer at Verint. He completed two B.Sc. degrees in Mathematics & Computer Science, summa cum laude, from the Technion in Israel.
Arik has extensive knowledge and experience in many Microsoft technologies, including .NET with C#, WPF, Silverlight, WinForms, Interop, COM/ATL programming, C++ Win32 programming and reverse engineering (assembly, IL).