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


C# PropVariant.SetBool方法代码示例

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


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

示例1: 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.BooleanValue)
            {
                if (_booleanValue.HasValue)
                {
                    newValue.SetBool(_booleanValue.Value);
                }
            }

            return HRESULT.S_OK;
        }
开发者ID:taozhengbo,项目名称:sdrsharp_experimental,代码行数:19,代码来源:BooleanValuePropertyProvider.cs

示例2: CreateLeafCondition

        /// <summary>
        /// Creates a leaf condition node that represents a comparison of property value and Boolean value. 
        /// </summary>
        /// <param name="propertyName">The name of a property to be compared, or null for an unspecified property. 
        /// The locale name of the leaf node is LOCALE_NAME_USER_DEFAULT.</param>
        /// <param name="value">The Boolean value against which the property value should be compared.</param>
        /// <param name="operation">Specific condition to be used when comparing the actual value and the expected value of the given property</param>
        /// <returns>SearchCondition based on the given parameters</returns>
        /// <remarks>
        /// The search will only work for files that are indexed, as well as the specific properties are indexed. To find 
        /// the properties that are indexed, look for the specific property's property description and 
        /// <see cref="P:Microsoft.WindowsAPICodePack.Shell.PropertySystem.ShellPropertyDescription.TypeFlags"/> property for IsQueryable flag.
        /// </remarks>
        public static SearchCondition CreateLeafCondition(string propertyName, bool value, SearchConditionOperation operation)
        {
            PropVariant propVar = new PropVariant();
            propVar.SetBool(value);

            return CreateLeafCondition(propertyName, propVar, "System.StructuredQuery.CustomProperty.Boolean", operation);
        }
开发者ID:TanyaTPG,项目名称:Log2Console,代码行数:20,代码来源:SearchConditionFactory.cs

示例3: ParseStructuredQuery

        /// <summary>
        /// Parses an input string that contains Structured Query keywords (using Advanced Query Syntax 
        /// or Natural Query Syntax) and produces a SearchCondition object.
        /// </summary>
        /// <param name="query">The query to be parsed</param>
        /// <param name="cultureInfo">The culture used to select the localized language for keywords.</param>
        /// <returns>Search condition resulting from the query</returns>
        /// <remarks>For more information on structured query syntax, visit http://msdn.microsoft.com/en-us/library/bb233500.aspx and
        /// http://www.microsoft.com/windows/products/winfamily/desktopsearch/technicalresources/advquery.mspx</remarks>
        public static SearchCondition ParseStructuredQuery(string query, CultureInfo cultureInfo)
        {
            if (string.IsNullOrEmpty(query))
                throw new ArgumentNullException("query");
            else
            {
                IQueryParserManager nativeQueryParserManager = (IQueryParserManager)new QueryParserManagerCoClass();
                IQueryParser queryParser = null;
                IQuerySolution querySolution = null;
                ICondition result = null;

                IEntity mainType = null;

                try
                {
                    // First, try to create a new IQueryParser using IQueryParserManager
                    Guid guid = new Guid(ShellIIDGuid.IQueryParser);
                    HRESULT hr = nativeQueryParserManager.CreateLoadedParser(
                        "SystemIndex",
                        cultureInfo == null ? (ushort)0 : (ushort)cultureInfo.LCID,
                        ref guid,
                        out queryParser);

                    if (!CoreErrorHelper.Succeeded((int)hr))
                        throw Marshal.GetExceptionForHR((int)hr);

                    if (queryParser != null)
                    {
                        // If user specified natural query, set the option on the query parser
                        PropVariant optionValue = new PropVariant();
                        optionValue.SetBool(true);
                        hr = queryParser.SetOption(StructuredQuerySingleOption.NaturalSyntax, ref optionValue);

                        if (!CoreErrorHelper.Succeeded((int)hr))
                            throw Marshal.GetExceptionForHR((int)hr);

                        // Next, try to parse the query.
                        // Result would be IQuerySolution that we can use for getting the ICondition and other
                        // details about the parsed query.
                        hr = queryParser.Parse(query, null, out querySolution);

                        if (!CoreErrorHelper.Succeeded((int)hr))
                            throw Marshal.GetExceptionForHR((int)hr);

                        if (querySolution != null)
                        {
                            // Lastly, try to get the ICondition from this parsed query
                            hr = querySolution.GetQuery(out result, out mainType);

                            if (!CoreErrorHelper.Succeeded((int)hr))
                                throw Marshal.GetExceptionForHR((int)hr);
                        }
                    }

                    return new SearchCondition(result);
                }
                finally
                {
                    if (nativeQueryParserManager != null)
                        Marshal.ReleaseComObject(nativeQueryParserManager);

                    if (queryParser != null)
                        Marshal.ReleaseComObject(queryParser);

                    if (querySolution != null)
                        Marshal.ReleaseComObject(querySolution);

                    if (mainType != null)
                        Marshal.ReleaseComObject(mainType);
                }
            }
        }
开发者ID:TanyaTPG,项目名称:Log2Console,代码行数:81,代码来源:SearchConditionFactory.cs

示例4: GetPropVariant

 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);
     }
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:65,代码来源:Command.cs

示例5: GetProperty

        public int GetProperty(ItemPropId propID, ref PropVariant value)
        {
            value.Clear();

            if (_subArchiveMode)
            {
                if (propID == ItemPropId.Name)
                {
                    value.SetBString(_subArchiveName);
                }
            }
            else
            {
                switch (propID)
                {
                    case ItemPropId.Name:
                        if (!_streamMode)
                        {
                            value.SetBString(Path.GetFileName(_fileName));
                        }
                        break;
                    case ItemPropId.IsDirectory:
                        value.SetBool(_streamMode ? false : (byte)(new FileInfo(_fileName).Attributes & FileAttributes.Directory) != 0);
                        break;
                    case ItemPropId.Size:
                        value.SetULong((ulong)_currentVolumeSize);
                        break;
                    case ItemPropId.Attributes:
                        value.SetUInt(_streamMode ? (uint)0 : (uint)new FileInfo(_fileName).Attributes);
                        break;
                    case ItemPropId.CreationTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).CreationTime);
                        }
                        break;
                    case ItemPropId.LastAccessTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).LastAccessTime);
                        }
                        break;
                    case ItemPropId.LastWriteTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).LastWriteTime);
                        }
                        break;
                }
            }
            return HRESULT.S_OK;
        }
开发者ID:GEPWNAGE,项目名称:Steel,代码行数:52,代码来源:ArchiveOpenCallback.cs

示例6: 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


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