public int LoadItemsSource(GalleryItems items, PropVariantRef currentValue, ref PropVariant newValue) { if (currentValue != null && currentValue.PropVariant.Value is IUICollection) { IUICollection collection = (IUICollection)currentValue.PropVariant.Value; collection.Clear(); foreach (GalleryItem item in items) { SimplePropertySet sps; LoadSimplePropertySet(item, out sps); collection.Add(sps); } newValue.SetIUnknown(collection); return(HRESULT.S_OK); } List <IUISimplePropertySet> list = new List <IUISimplePropertySet>(); foreach (GalleryItem item in items) { SimplePropertySet sps; LoadSimplePropertySet(item, out sps); list.Add(sps); } newValue.SetIUnknown(new BasicCollection(list)); return(HRESULT.S_OK); }
public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { Command command = ParentCommandManager.Get((CommandId)commandId); if (command == null) { return NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue); } try { newValue = new PropVariant(); command.GetPropVariant(key, currentValue, ref newValue); if (newValue.IsNull()) { Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString()); newValue = PropVariant.FromObject(currentValue.PropVariant.Value); } } catch (Exception ex) { Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex); newValue = PropVariant.FromObject(currentValue.PropVariant.Value); } return HRESULT.S_OK; }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.DecimalValue) { value.SetDecimal(Value); } else if (key == PropertyKeys.MinValue) { value.SetDecimal(MinValue); } else if (key == PropertyKeys.MaxValue) { value.SetDecimal(MaxValue); } else if (key == PropertyKeys.Increment) { value.SetDecimal(Increment); } else if (key == PropertyKeys.DecimalPlaces) { value.SetUInt(DecimalPlaces); } else if (key == PropertyKeys.FormatString) { value.SetString(FormatString); } else { base.GetPropVariant(key, currentValue, ref value); } }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.Categories) { if (CategoriesReady != null) { CategoriesReady(_sender, EventArgs.Empty); } } else if (key == RibbonProperties.ItemsSource) { if (ItemsSourceReady != null) { ItemsSourceReady(_sender, EventArgs.Empty); } } else if (key == RibbonProperties.SelectedItem) { if (_selectedItem.HasValue) { newValue.SetUInt(_selectedItem.Value); } } return(HRESULT.S_OK); }
public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { Command command = ParentCommandManager.Get((CommandId)commandId); if (command == null) { return(NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue)); } try { newValue = new PropVariant(); command.GetPropVariant(key, currentValue, ref newValue); if (newValue.IsNull()) { Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString()); newValue = PropVariant.FromObject(currentValue.PropVariant.Value); } } catch (Exception ex) { Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex); newValue = PropVariant.FromObject(currentValue.PropVariant.Value); } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.LargeImage) { if (_largeImage != null) { newValue.SetIUnknown(_largeImage); } } else if (key == RibbonProperties.SmallImage) { if (_smallImage != null) { newValue.SetIUnknown(_smallImage); } } else if (key == RibbonProperties.LargeHighContrastImage) { if (_largeHighContrastImage != null) { newValue.SetIUnknown(_largeHighContrastImage); } } else if (key == RibbonProperties.SmallHighContrastImage) { if (_smallHighContrastImage != null) { newValue.SetIUnknown(_smallHighContrastImage); } } return(HRESULT.S_OK); }
/// <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) { if (verb == ExecutionVerb.Execute) { if (ExecuteEvent != null) { try { ExecuteEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } catch (Exception ex) { BaseRibbonControl ctrl = _sender as BaseRibbonControl; if (ctrl != null) { ThreadExceptionEventArgs e = new ThreadExceptionEventArgs(ex); if (ctrl._ribbon.OnRibbonEventException(_sender, e)) { return(HRESULT.E_FAIL); } } Environment.FailFast(ex.StackTrace); return(HRESULT.E_ABORT); } } } return(HRESULT.S_OK); }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.ContextAvailable) { value.SetUInt((uint)ContextAvailability); } else base.GetPropVariant(key, currentValue, ref value); }
/// <summary> /// Implementation of IUICommandHandler.UpdateProperty /// Responds to property update requests from the Windows Ribbon (Ribbon) framework. /// </summary> /// <param name="commandID">The ID for the Command, which is specified in the Markup resource file</param> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> /// <remarks>This method is used internally by the Ribbon class and should not be called by the user.</remarks> public virtual HRESULT UpdateProperty(uint commandID, ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (_mapRibbonControls.ContainsKey(commandID)) { return(_mapRibbonControls[commandID].UpdateProperty(ref key, currentValue, ref newValue)); } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be null</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.Categories) { if (!categoriesReadyFired && CategoriesReady != null) { categoriesReadyFired = true; try { CategoriesReady(_sender, EventArgs.Empty); } catch (Exception ex) { ThreadExceptionEventArgs e = new ThreadExceptionEventArgs(ex); if (_ribbon.OnRibbonEventException(_sender, e)) { return(HRESULT.E_FAIL); } Environment.FailFast(ex.StackTrace); return(HRESULT.E_ABORT); } } } else if (key == RibbonProperties.ItemsSource) { if (!itemsSourceReadyFired && ItemsSourceReady != null) { itemsSourceReadyFired = true; try { ItemsSourceReady(_sender, EventArgs.Empty); } catch (Exception ex) { ThreadExceptionEventArgs e = new ThreadExceptionEventArgs(ex); if (_ribbon.OnRibbonEventException(_sender, e)) { return(HRESULT.E_FAIL); } Environment.FailFast(ex.StackTrace); return(HRESULT.E_ABORT); } } } else if (key == RibbonProperties.SelectedItem) { if (_selectedItem.HasValue) { newValue.SetUInt(_selectedItem.Value); _selectedItem = null; } } return(HRESULT.S_OK); }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.ContextAvailable) { value.SetUInt((uint)ContextAvailability); } else { base.GetPropVariant(key, currentValue, ref value); } }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.LabelDescription) { // In order to vertically align the label title, we need to return an error for the label description. value.SetError(); return; } base.GetPropVariant(key, currentValue, ref value); }
public override int OverrideProperty(ref PropertyKey key, PropVariantRef overrideValue) { // In this case the override applies to each of the commands associated with each gallery item as well. // Normally, you can't disable individual gallery items, but these items have shortcuts associated with // them that must be disabled/enabled according to the override. foreach (var v in _elements) { _editingSite.CommandManager.OverrideProperty((uint)v.CommandId, ref key, overrideValue); } return(base.OverrideProperty(ref key, overrideValue)); }
/// <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) { if (verb == ExecutionVerb.Execute) { if (ExecuteEvent != null) { ExecuteEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } } return HRESULT.S_OK; }
/// <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) { if (verb == ExecutionVerb.Execute) { if (ExecuteEvent != null) { ExecuteEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } } return(HRESULT.S_OK); }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.ItemsSource) { // We are a command gallery (not an item gallery), so load our items as commands LoadItemsSourceAsCommands(ref value); } else { base.GetPropVariant(key, currentValue, ref value); } }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.Enabled) { if (_enabled.HasValue) { newValue.SetBool(_enabled.Value); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.RepresentativeString) { if (_representativeString != null) { newValue.SetString(_representativeString); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.RecentItems) { if (_recentItems != null) { newValue.SetSafeArray(_recentItems.ToArray()); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.ContextAvailable) { if (_contextAvailable.HasValue) { newValue.SetUInt((uint)_contextAvailable.Value); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.LabelDescription) { if (_labelDescription != null) { newValue.SetString(_labelDescription); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.Keytip) { if (_keytip != null) { newValue.SetString(_keytip); } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be null</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.BooleanValue) { if (_booleanValue.HasValue) { newValue.SetBool(_booleanValue.Value); _booleanValue = null; } } return(HRESULT.S_OK); }
/// <summary> /// Implementation of IUICommandHandler.UpdateProperty /// Responds to property update requests from the Windows Ribbon (Ribbon) framework. /// </summary> /// <param name="commandID">The ID for the Command, which is specified in the Markup resource file</param> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> /// <remarks>This method is used internally by the Ribbon class and should not be called by the user.</remarks> public virtual HRESULT UpdateProperty(uint commandID, ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { #if DEBUG Debug.WriteLine(string.Format("UpdateProperty key: {0} for command {1}", RibbonProperties.GetPropertyKeyName(ref key), commandID)); #endif if (_mapRibbonControls.ContainsKey(commandID)) { return(_mapRibbonControls[commandID].UpdateProperty(ref key, currentValue, ref newValue)); } return(HRESULT.S_OK); }
public virtual int Execute(UInt32 commandId, CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { switch (verb) { case CommandExecutionVerb.Execute: ParentCommandManager.Execute((CommandId)commandId); return HRESULT.S_OK; case CommandExecutionVerb.Preview: break; case CommandExecutionVerb.CancelPreview: break; } return HRESULT.S_OK; }
/// <summary> /// Handles IUICommandHandler.Execute function for this ribbon control /// </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 virtual HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { // check if verb is registered with this ribbon control if (_mapEvents.ContainsKey(verb)) { // find events provider IEventsProvider eventsProvider = _mapEvents[verb]; // delegates execution to events provider return(eventsProvider.Execute(verb, key, currentValue, commandExecutionProperties)); } Debug.WriteLine(string.Format("Class {0} does not support verb: {1}.", GetType(), verb)); return(HRESULT.E_NOTIMPL); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for this ribbon control /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be null</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public virtual HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { // check if property is registered with this ribbon control if (_mapProperties.ContainsKey(key)) { // find property provider IPropertiesProvider propertiesProvider = _mapProperties[key]; // delegates execution to property provider return(propertiesProvider.UpdateProperty(ref key, currentValue, ref newValue)); } Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType(), RibbonProperties.GetPropertyKeyName(ref key))); return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be null</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.DecimalValue) { if (_decimalValue.HasValue) { newValue.SetDecimal(_decimalValue.Value); _decimalValue = null; } } else if (key == RibbonProperties.Increment) { if (_increment.HasValue) { newValue.SetDecimal(_increment.Value); } } else if (key == RibbonProperties.MaxValue) { if (_maxValue.HasValue) { newValue.SetDecimal(_maxValue.Value); } } else if (key == RibbonProperties.MinValue) { if (_minValue.HasValue) { newValue.SetDecimal(_minValue.Value); } } else if (key == RibbonProperties.DecimalPlaces) { if (_decimalPlaces.HasValue) { newValue.SetUInt(_decimalPlaces.Value); } } else if (key == RibbonProperties.FormatString) { if (_formatString != null) { newValue.SetString(_formatString); } } return(HRESULT.S_OK); }
public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { try { Command command = Get((CommandId)commandId); if (command == null) { return(genericCommandHandler.NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue)); } return(command.UpdateProperty(ref key, currentValue, out newValue)); } catch (Exception ex) { Debug.Fail("Exception throw in CommandManager.UpdateProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key)); throw; } }
public int OverrideProperty(uint commandId, ref PropertyKey key, PropVariantRef overrideValue) { try { IOverridableCommand overridableCommand = Get((CommandId)commandId) as IOverridableCommand; if (overridableCommand == null) { return(HRESULT.E_INVALIDARG); } return(overridableCommand.OverrideProperty(ref key, overrideValue)); } catch (Exception ex) { Debug.Fail("Exception throw in CommandManager.OverrideProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key)); throw; } }
public virtual int OverrideProperty(ref PropertyKey key, PropVariantRef overrideValue) { if (key == PropertyKeys.Enabled) { bool currentValue = Enabled; _overrides[key] = overrideValue.PropVariant; UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToBoolean(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue); return HRESULT.S_OK; } else if (key == PropertyKeys.ContextAvailable) { uint currentValue = (uint)ContextAvailability; _overrides[key] = overrideValue.PropVariant; UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToUInt32(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue); return HRESULT.S_OK; } return HRESULT.E_INVALIDARG; }
public virtual int OverrideProperty(ref PropertyKey key, PropVariantRef overrideValue) { if (key == PropertyKeys.Enabled) { bool currentValue = Enabled; _overrides[key] = overrideValue.PropVariant; UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToBoolean(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue); return(HRESULT.S_OK); } else if (key == PropertyKeys.ContextAvailable) { uint currentValue = (uint)ContextAvailability; _overrides[key] = overrideValue.PropVariant; UpdateInvalidationStateAndNotifyIfDifferent(ref key, Convert.ToUInt32(overrideValue.PropVariant.Value, CultureInfo.InvariantCulture), () => currentValue); return(HRESULT.S_OK); } return(HRESULT.E_INVALIDARG); }
/// <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 (PreviewEvent != null) { PreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } break; case ExecutionVerb.CancelPreview: if (CancelPreviewEvent != null) { CancelPreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } break; } return HRESULT.S_OK; }
/// <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 (PreviewEvent != null) { PreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } break; case ExecutionVerb.CancelPreview: if (CancelPreviewEvent != null) { CancelPreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties)); } break; } return(HRESULT.S_OK); }
/// <summary> /// /// </summary> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { //if (key == RibbonProperties.ItemsSource) //{ // if (_itemsSource != null) // { // IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value; // itemsSource.Clear(); // uint count; // _itemsSource.GetCount(out count); // for (uint i = 0; i < count; ++i) // { // object item; // _itemsSource.GetItem(i, out item); // itemsSource.Add(item); // } // } //} return(HRESULT.S_OK); }
/// <summary> /// /// </summary> public HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.ItemsSource) { if (_itemsSource != null) { IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value; itemsSource.Clear(); uint count; _itemsSource.GetCount(out count); for (uint i = 0; i < count; ++i) { object item; _itemsSource.GetItem(i, out item); itemsSource.Add(item); } } } return(HRESULT.S_OK); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.LargeImage) { if (_largeImage != null) { newValue.SetIUnknown(_largeImage); } } else if (key == RibbonProperties.SmallImage) { if (_smallImage != null) { newValue.SetIUnknown(_smallImage); } } else if (key == RibbonProperties.LargeHighContrastImage) { if (_largeHighContrastImage != null) { newValue.SetIUnknown(_largeHighContrastImage); } } else if (key == RibbonProperties.SmallHighContrastImage) { if (_smallHighContrastImage != null) { newValue.SetIUnknown(_smallHighContrastImage); } } return HRESULT.S_OK; }
public override int PerformExecute(CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { return _command.PerformExecute(verb, key, currentValue, commandExecutionProperties); }
public override int PerformExecute(CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { decimal spinnerValue = Convert.ToDecimal(currentValue.PropVariant.Value, CultureInfo.InvariantCulture); PerformExecuteWithArgs(verb, new ExecuteEventHandlerArgs(CommandId.ToString(), spinnerValue)); return HRESULT.S_OK; }
public int OverrideProperty(uint commandId, ref PropertyKey key, PropVariantRef overrideValue) { return contentEditor.CommandManager.OverrideProperty(commandId, ref key, overrideValue); }
public override int UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { return _command.UpdateProperty(ref key, currentValue, out newValue); }
public HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.ItemsSource) { if (_itemsSource != null) { IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value; itemsSource.Clear(); uint count; _itemsSource.GetCount(out count); for (uint i = 0; i < count; ++i) { object item; _itemsSource.GetItem(i, out item); itemsSource.Add(item); } } } return HRESULT.S_OK; }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.ContextAvailable) { if (_contextAvailable.HasValue) { newValue.SetUInt((uint)_contextAvailable.Value); } } return HRESULT.S_OK; }
public virtual void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.Enabled) { value.SetBool(Enabled); } else if (key == PropertyKeys.SmallImage) { RibbonHelper.CreateImagePropVariant(SmallImage, out value); } else if (key == PropertyKeys.SmallHighContrastImage) { // If in High Contrast White mode or a disabled icon in High Contrast Black, use regular image RibbonHelper.CreateImagePropVariant(ApplicationEnvironment.IsHighContrastWhite || (ApplicationEnvironment.IsHighContrastBlack && !Enabled) ? SmallImage : SmallHighContrastImage, out value); } else if (key == PropertyKeys.LargeImage) { RibbonHelper.CreateImagePropVariant(LargeImage, out value); } else if (key == PropertyKeys.LargeHighContrastImage) { // If in High Contrast White mode or a disabled icon in High Contrast Black, use regular image RibbonHelper.CreateImagePropVariant(ApplicationEnvironment.IsHighContrastWhite || (ApplicationEnvironment.IsHighContrastBlack && !Enabled) ? LargeImage : LargeHighContrastImage, out value); } else if (key == PropertyKeys.Label) { value.SetString(LabelTitle ?? String.Empty); } else if (key == PropertyKeys.LabelDescription) { value.SetString(LabelDescription ?? String.Empty); } else if (key == PropertyKeys.TooltipTitle) { // In order to eliminate some duplicate strings in our localization we will // return the LabelTitle for the TooltipTitle if the TooltipTitle is missing in the markup. value.SetString(TooltipTitle ?? (LabelTitle ?? String.Empty)); } else if (key == PropertyKeys.TooltipDescription) { value.SetString(TooltipDescription ?? String.Empty); } else if (key == PropertyKeys.Keytip) { value.SetString(Keytip ?? String.Empty); } else if (key == PropertyKeys.ContextAvailable) { value.SetUInt(Enabled ? (uint)ContextAvailability.Active : (uint)ContextAvailability.NotAvailable); } else if (key == PropertyKeys.RepresentativeString) { IRepresentativeString rs = (IRepresentativeString)this; value.SetString(rs.RepresentativeString); } else if (key == PropertyKeys.BooleanValue) { value.SetBool(Latched); } else { Trace.Fail("Didn't properly update property for " + key + " on command " + CommandId); throw new Exception("Failed to get PropVariant for " + key); } }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.StringValue) { if (_stringValue != null) { newValue.SetString(_stringValue); } } return HRESULT.S_OK; }
public int Execute(uint commandId, CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { return contentEditor.CommandManager.Execute(commandId, verb, key, currentValue, commandExecutionProperties); }
public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { return contentEditor.CommandManager.UpdateProperty(commandId, ref key, currentValue, out newValue); }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.TooltipTitle) { if (_tooltipTitle != null) { newValue.SetString(_tooltipTitle); } } else if (key == RibbonProperties.TooltipDescription) { if (_tooltipDescription != null) { newValue.SetString(_tooltipDescription); } } return HRESULT.S_OK; }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { if (key == PropertyKeys.DecimalValue) { value.SetDecimal(Value); } else if (key == PropertyKeys.MinValue) { value.SetDecimal(MinValue); } else if (key == PropertyKeys.MaxValue) { value.SetDecimal(MaxValue); } else if (key == PropertyKeys.Increment) { value.SetDecimal(Increment); } else if (key == PropertyKeys.DecimalPlaces) { value.SetUInt(DecimalPlaces); } else if (key == PropertyKeys.FormatString) { value.SetString(FormatString); } else base.GetPropVariant(key, currentValue, ref value); }
public virtual int UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { Debug.Assert(!_flushing, "UpdateProperty called while flushing pending invalidations!"); try { newValue = new PropVariant(); GetPropVariant(key, currentValue, ref newValue); // Remove key from dictionary since we have updated it. pendingInvalidations.Remove(key); if (newValue.IsNull()) { Trace.Fail("Didn't properly update property for " + PropertyKeys.GetName(key) + " on command " + CommandId); newValue = new PropVariant(); } } catch (Exception ex) { UpdateInvalidationState(key, InvalidationState.Error); Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + CommandId + ": " + ex); newValue = new PropVariant(); } if (newValue.VarType == VarEnum.VT_ERROR) { // Returning an error tells the Ribbon to ignore this property. return HRESULT.E_NOTIMPL; } return HRESULT.S_OK; }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.AutomaticColorLabel) { if (_automaticColorLabel != null) { newValue.SetString(_automaticColorLabel); } } else if (key == RibbonProperties.Color) { if (_color.HasValue) { newValue.SetUInt((uint)ColorTranslator.ToWin32(_color.Value)); } } else if (key == RibbonProperties.ColorType) { if (_colorType.HasValue) { newValue.SetUInt((uint)_colorType.Value); } } else if (key == RibbonProperties.MoreColorsLabel) { if (_moreColorsLabel != null) { newValue.SetString(_moreColorsLabel); } } else if (key == RibbonProperties.NoColorLabel) { if (_noColorLabel != null) { newValue.SetString(_noColorLabel); } } else if (key == RibbonProperties.RecentColorsCategoryLabel) { if (_recentColorsCategoryLabel != null) { newValue.SetString(_recentColorsCategoryLabel); } } else if (key == RibbonProperties.StandardColors) { if (_standardColors != null) { int[] intStandardColors = Array.ConvertAll<Color, int>(_standardColors, new Converter<Color, int>(ColorTranslator.ToWin32)); uint[] uintStandardColors = Array.ConvertAll<int, uint>(intStandardColors, new Converter<int, uint>(Convert.ToUInt32)); newValue.SetUIntVector(uintStandardColors); } } else if (key == RibbonProperties.StandardColorsCategoryLabel) { if (_standardColorsCategoryLabel != null) { newValue.SetString(_standardColorsCategoryLabel); } } else if (key == RibbonProperties.StandardColorsTooltips) { if (_standardColorsTooltips != null) { newValue.SetStringVector(_standardColorsTooltips); } } else if (key == RibbonProperties.ThemeColors) { if (_themeColors != null) { int[] intThemeColors = Array.ConvertAll<Color, int>(_themeColors, new Converter<Color, int>(ColorTranslator.ToWin32)); uint[] uintThemeColors = Array.ConvertAll<int, uint>(intThemeColors, new Converter<int, uint>(Convert.ToUInt32)); newValue.SetUIntVector(uintThemeColors); } } else if (key == RibbonProperties.ThemeColorsCategoryLabel) { if (_themeColorsCategoryLabel != null) { newValue.SetString(_themeColorsCategoryLabel); } } else if (key == RibbonProperties.ThemeColorsTooltips) { if (_themeColorsTooltips != null) { newValue.SetStringVector(_themeColorsTooltips); } } return HRESULT.S_OK; }
public virtual int PerformExecute(CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { switch (verb) { case CommandExecutionVerb.Execute: PerformExecute(); break; case CommandExecutionVerb.Preview: Debug.Fail("Preview is not implemented for " + CommandId); break; case CommandExecutionVerb.CancelPreview: Debug.Fail("CancelPreview is not implemented for " + CommandId); break; default: Debug.Fail("Unexpected CommandExecutionVerb."); break; } return HRESULT.S_OK; }
/// <summary> /// Implementation of IUICommandHandler.Execute /// Responds to execute events on Commands bound to the Command handler /// </summary> /// <param name="commandID">the command that has been executed</param> /// <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> /// <remarks>This method is used internally by the Ribbon class and should not be called by the user.</remarks> public virtual HRESULT Execute(uint commandID, ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { #if DEBUG Debug.WriteLine(string.Format("Execute verb: {0} for command {1}", verb, commandID)); #endif if (_mapRibbonControls.ContainsKey(commandID)) { return _mapRibbonControls[commandID].Execute(verb, key, currentValue, commandExecutionProperties); } return HRESULT.S_OK; }
public int Execute(uint commandId, CommandExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { try { Command command = Get((CommandId)commandId); if (verb != CommandExecutionVerb.Execute) return HRESULT.S_OK; FireBeforeExecute((CommandId)commandId); int result; try { result = command.PerformExecute(verb, key, currentValue, commandExecutionProperties); } finally { FireAfterExecute((CommandId)commandId); } return result; } catch (Exception ex) { Trace.Fail("Exception thrown when executing " + (CommandId)commandId + ": " + ex); } return HRESULT.S_OK; }
public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value) { _command.GetPropVariant(key, currentValue, ref value); }
public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { try { Command command = Get((CommandId)commandId); if (command == null) { return genericCommandHandler.NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue); } return command.UpdateProperty(ref key, currentValue, out newValue); } catch (Exception ex) { Debug.Fail("Exception throw in CommandManager.UpdateProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key)); throw; } }
public HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties) { return HRESULT.S_OK; }
public int OverrideProperty(uint commandId, ref PropertyKey key, PropVariantRef overrideValue) { try { IOverridableCommand overridableCommand = Get((CommandId)commandId) as IOverridableCommand; if (overridableCommand == null) return HRESULT.E_INVALIDARG; return overridableCommand.OverrideProperty(ref key, overrideValue); } catch (Exception ex) { Debug.Fail("Exception throw in CommandManager.OverrideProperty: " + ex + "\r\n\r\nCommand: " + commandId + " Key: " + PropertyKeys.GetName(key)); throw; } }
/// <summary> /// Handles IUICommandHandler.UpdateProperty function for the supported properties /// </summary> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { if (key == RibbonProperties.BooleanValue) { if (_booleanValue.HasValue) { newValue.SetBool(_booleanValue.Value); } } return HRESULT.S_OK; }
/// <summary> /// Implementation of IUICommandHandler.UpdateProperty /// Responds to property update requests from the Windows Ribbon (Ribbon) framework. /// </summary> /// <param name="commandID">The ID for the Command, which is specified in the Markup resource file</param> /// <param name="key">The Property Key to update</param> /// <param name="currentValue">A pointer to the current value for key. This parameter can be NULL</param> /// <param name="newValue">When this method returns, contains a pointer to the new value for key</param> /// <returns>Returns S_OK if successful, or an error value otherwise</returns> /// <remarks>This method is used internally by the Ribbon class and should not be called by the user.</remarks> public virtual HRESULT UpdateProperty(uint commandID, ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue) { #if DEBUG Debug.WriteLine(string.Format("UpdateProperty key: {0} for command {1}", RibbonProperties.GetPropertyKeyName(ref key), commandID)); #endif if (_mapRibbonControls.ContainsKey(commandID)) { return _mapRibbonControls[commandID].UpdateProperty(ref key, currentValue, ref newValue); } return HRESULT.S_OK; }