当前位置: 首页>>代码示例>>C#>>正文


C# PropVariant.SetIUnknown方法代码示例

本文整理汇总了C#中PropVariant.SetIUnknown方法的典型用法代码示例。如果您正苦于以下问题:C# PropVariant.SetIUnknown方法的具体用法?C# PropVariant.SetIUnknown怎么用?C# PropVariant.SetIUnknown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropVariant的用法示例。


在下文中一共展示了PropVariant.SetIUnknown方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateImagePropVariant

        public static void CreateImagePropVariant(Image image, out PropVariant pv)
        {
            try
            {
                pv = new PropVariant();

                // Note that the missing image is a 32x32 png.
                if (image == null)
                    image = Images.Missing_LargeImage;

                pv.SetIUnknown(CreateImage(((Bitmap)image).GetHbitmap(), ImageCreationOptions.Transfer));
            }
            catch (Exception ex)
            {
                Trace.Fail("Failed to create image PropVariant: " + ex);
                pv = new PropVariant();
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:18,代码来源:RibbonHelper.cs

示例2: UpdateProperty

        /// <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;
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:40,代码来源:ImagePropertiesProvider.cs

示例3: NullCommandUpdateProperty

        public int NullCommandUpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {

            try
            {
                newValue = new PropVariant();
                if (key == PropertyKeys.Enabled)
                {
                    newValue.SetBool(false);
                }
                else if (key == PropertyKeys.SmallImage)
                {
                    Bitmap bitmap = CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "SmallImage");
                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.SmallHighContrastImage)
                {
                    Bitmap bitmap =
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(),
                                                                "SmallHighContrastImage") ??
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "SmallImage");

                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.LargeImage)
                {
                    Bitmap bitmap = CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "LargeImage");
                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.LargeHighContrastImage)
                {
                    Bitmap bitmap =
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(),
                                                                "LargeHighContrastImage") ??
                        CommandResourceLoader.LoadCommandBitmap(((CommandId)commandId).ToString(), "LargeImage");

                    RibbonHelper.CreateImagePropVariant(bitmap, out newValue);
                }
                else if (key == PropertyKeys.Label)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".LabelTitle";
                    newValue = new PropVariant(TextHelper.UnescapeNewlines(Res.GetProp(str)) ?? String.Empty);
                }
                else if (key == PropertyKeys.LabelDescription)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".LabelDescription";
                    newValue = new PropVariant(Res.GetProp(str) ?? String.Empty);
                }
                else if (key == PropertyKeys.TooltipTitle)
                {
                    string commandName = ((CommandId)commandId).ToString();
                    string str = "Command." + commandName + ".TooltipTitle";
                    newValue = new PropVariant(Res.GetProp(str) ?? (Res.GetProp("Command." + commandName + ".LabelTitle") ?? String.Empty));
                }
                else if (key == PropertyKeys.TooltipDescription)
                {
                    string str = "Command." + ((CommandId)commandId).ToString() + ".TooltipDescription";
                    newValue = new PropVariant(Res.GetProp(str) ?? String.Empty);
                }
                else if (key == PropertyKeys.Keytip)
                {
                    newValue = new PropVariant("XXX");
                }
                else if (key == PropertyKeys.ContextAvailable)
                {
                    newValue.SetUInt((uint)ContextAvailability.NotAvailable);
                }
                else if (key == PropertyKeys.Categories)
                {
                    newValue = new PropVariant();
                    newValue.SetIUnknown(currentValue);
                }
                else if (key == PropertyKeys.RecentItems)
                {
                    object[] currColl = (object[])currentValue.PropVariant.Value;
                    newValue = new PropVariant();
                    newValue.SetSafeArray(currColl);
                    return HRESULT.S_OK;

                }
                else if (key == PropertyKeys.ItemsSource)
                {
                    // This should only be necessary if you have created a gallery in the ribbon markup that you have not yet put into the command manager.
                    List<IUISimplePropertySet> list = new List<IUISimplePropertySet>();

                    OpenLiveWriter.Interop.Com.Ribbon.IEnumUnknown enumUnk = new BasicCollection(list);
                    newValue = new PropVariant();
                    newValue.SetIUnknown(enumUnk);
                    return HRESULT.S_OK;
                }
                else if (key == PropertyKeys.StringValue)
                {
                    newValue = new PropVariant(String.Empty);
                }
                else if (key == PropertyKeys.SelectedItem)
                {
                    newValue = new PropVariant(0);
                }
                else if (key == PropertyKeys.DecimalValue)
                {
//.........这里部分代码省略.........
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:101,代码来源:GenericCommandHandler.cs

示例4: UpdateProperty

        /// <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.FontProperties)
            {
                if (currentValue != null)
                {
                    // get current font properties
                    IPropertyStore fontProperties = (IPropertyStore)currentValue.PropVariant.Value;

                    // set family
                    if ( (_family == null) || (_family.Trim() == string.Empty) )
                    {
                        PropVariant propFamily = PropVariant.Empty;
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Family, ref propFamily);
                    }
                    else
                    {
                        PropVariant propFamily = PropVariant.FromObject(_family);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Family, ref propFamily);
                    }

                    // set size
                    if (_size.HasValue)
                    {
                        PropVariant propSize = PropVariant.FromObject(_size.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Size, ref propSize);
                    }

                    // set bold
                    if (_bold.HasValue)
                    {
                        PropVariant propBold = PropVariant.FromObject((uint)_bold.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Bold, ref propBold);
                    }

                    // set italic
                    if (_italic.HasValue)
                    {
                        PropVariant propItalic = PropVariant.FromObject((uint)_italic.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Italic, ref propItalic);
                    }

                    // set underline
                    if (_underline.HasValue)
                    {
                        PropVariant propUnderline = PropVariant.FromObject((uint)_underline.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Underline, ref propUnderline);
                    }

                    // set strikethrough
                    if (_strikethrough.HasValue)
                    {
                        PropVariant propStrikethrough = PropVariant.FromObject((uint)_strikethrough.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_Strikethrough, ref propStrikethrough);
                    }

                    // set foregroundColor
                    if (_foregroundColor.HasValue)
                    {
                        PropVariant propForegroundColor = PropVariant.FromObject((uint)ColorTranslator.ToWin32(_foregroundColor.Value));
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_ForegroundColor, ref propForegroundColor);
                    }

                    // set foregroundColorType
                    if (_foregroundColorType.HasValue)
                    {
                        PropVariant propForegroundColorType = PropVariant.FromObject((uint)_foregroundColorType.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_ForegroundColorType, ref propForegroundColorType);
                    }

                    // set backgroundColor
                    if (_backgroundColor.HasValue)
                    {
                        PropVariant propBackgroundColor = PropVariant.FromObject((uint)ColorTranslator.ToWin32(_backgroundColor.Value));
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_BackgroundColor, ref propBackgroundColor);
                    }

                    // set backgroundColorType
                    if (_backgroundColorType.HasValue)
                    {
                        PropVariant propBackgroundColorType = PropVariant.FromObject((uint)_backgroundColorType.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_BackgroundColorType, ref propBackgroundColorType);
                    }

                    // set verticalPositioning
                    if (_verticalPositioning.HasValue)
                    {
                        PropVariant propVerticalPositioning = PropVariant.FromObject((uint)_verticalPositioning.Value);
                        fontProperties.SetValue(ref RibbonProperties.FontProperties_VerticalPositioning, ref propVerticalPositioning);
                    }

                    // set new font properties
                    newValue.SetIUnknown(fontProperties);
//.........这里部分代码省略.........
开发者ID:taozhengbo,项目名称:sdrsharp_experimental,代码行数:101,代码来源:FontControlPropertiesProvider.cs


注:本文中的PropVariant.SetIUnknown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。