private bool LoadCommandSimplePropertySet(GalleryItem item, out SimplePropertySet sps) { Debug.Assert(item.Cookie != null && item.Cookie.CommandId != CommandId.None, "Command gallery item without a valid Command or Command.CommandId!"); sps = null; if (item.Cookie != null && item.Cookie.CommandId != CommandId.None) { sps = new SimplePropertySet(); if (item.Label != null) { sps.Add(PropertyKeys.Label, new PropVariant(item.Label)); } if (item.Image != null) { PropVariant image = new PropVariant(item.IUIImage); if (image.VarType == VarEnum.VT_UNKNOWN) { sps.Add(PropertyKeys.ItemImage, image); } } // Command type items require CommandId, CommandType and CategoryId UInt32 cmdId = (uint)(item.Cookie.CommandId); sps.Add(PropertyKeys.CommandId, new PropVariant(cmdId)); sps.Add(PropertyKeys.CommandType, new PropVariant((uint)CommandTypeID.UI_COMMANDTYPE_ACTION)); sps.Add(PropertyKeys.CategoryId, new PropVariant(item.CategoryIndex)); return(true); } return(false); }
public override int UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { if (key == PropertyKeys.RecentItems) { object[] currColl = (object[])currentValue.PropVariant.Value; // Clear out old items for (int i = 0; i < currColl.Length; i++) { currColl[i] = null; } for (int i = 0; i < Items.Count && i < MaxItems; i++) { TooltippedGalleryItem item = (TooltippedGalleryItem)Items[i]; SimplePropertySet sps = new SimplePropertySet(); Debug.Assert(item.Label != null); if (item.Label != null) { sps.Add(PropertyKeys.Label, new PropVariant(item.Label)); } // This is the item tooltip if (item.LabelDescription != null) { sps.Add(PropertyKeys.LabelDescription, new PropVariant(item.LabelDescription)); } currColl[i] = sps; } newValue = new PropVariant(); newValue.SetSafeArray(currColl); return(HRESULT.S_OK); } return(base.UpdateProperty(ref key, currentValue, out newValue)); }
protected void LoadSimplePropertySet(GalleryItem item, out SimplePropertySet sps) { sps = new SimplePropertySet(); Debug.Assert(item.Label != null || item.IUIImage != null); if (item.Label != null) { sps.Add(PropertyKeys.Label, new PropVariant(item.Label)); } if (item.IUIImage != null) { PropVariant image = new PropVariant(item.IUIImage); if (image.VarType == VarEnum.VT_UNKNOWN) { sps.Add(PropertyKeys.ItemImage, image); } } sps.Add(PropertyKeys.CategoryId, new PropVariant(item.CategoryIndex)); }