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


C# UnsafeNativeMethods.GetProperty方法代码示例

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


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

示例1: OnEndEdit

        internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context,
                                        int ecReadOnly, 
                                        UnsafeNativeMethods.ITfEditRecord editRecord) 
        {
            Guid displayAttributeGuid;
            UnsafeNativeMethods.ITfProperty displayAttributeProperty;
            UnsafeNativeMethods.IEnumTfRanges attributeRangeEnumerator;
            UnsafeNativeMethods.ITfRange[] attributeRanges;
            int fetched;
            int guidAtom;
            TextServicesDisplayAttribute displayAttribute;
            ITextPointer start;
            ITextPointer end;

            //
            // Remove any existing display attribute highlights.
            //

#if UNUSED_IME_HIGHLIGHT_LAYER
            if (_highlightLayer != null)
            {
                this.TextStore.TextContainer.Highlights.RemoveLayer(_highlightLayer);
                _highlightLayer = null;
            }
#endif

            //
            // Remove any existing composition adorner for display attribute.
            //

            if (_compositionAdorner != null)
            {
                _compositionAdorner.Uninitialize();
                _compositionAdorner = null;
            }

            //
            // Look for new ones.
            //

            // Get the DisplayAttributeProperty.
            displayAttributeGuid = Guid;
            context.GetProperty(ref displayAttributeGuid, out displayAttributeProperty);
            // Get a range enumerator for the property.
            if (displayAttributeProperty.EnumRanges(ecReadOnly, out attributeRangeEnumerator, null) == NativeMethods.S_OK)
            {
                attributeRanges = new UnsafeNativeMethods.ITfRange[1];

                // Walk each range.
                while (attributeRangeEnumerator.Next(1, attributeRanges, out fetched) == NativeMethods.S_OK)
                {
                    // Get a DisplayAttribute for this range.
                    guidAtom = GetInt32Value(ecReadOnly, displayAttributeProperty, attributeRanges[0]);
                    displayAttribute = GetDisplayAttribute(guidAtom);

                    if (displayAttribute != null && !displayAttribute.IsEmptyAttribute())
                    {
                        // Set a matching highlight for the attribute range.
                        ConvertToTextPosition(attributeRanges[0], out start, out end);

                        if (start != null)
                        {
#if UNUSED_IME_HIGHLIGHT_LAYER
                        // Demand create the highlight layer.
                        if (_highlightLayer == null)
                        {
                            _highlightLayer = new DisplayAttributeHighlightLayer();
                        }
#endif

                            if (_compositionAdorner == null)
                            {
                                _compositionAdorner = new CompositionAdorner(this.TextStore.TextView);
                                _compositionAdorner.Initialize(this.TextStore.TextView);
                            }

#if UNUSED_IME_HIGHLIGHT_LAYER
                        // ToDo: Need to pass the foreground and background color of the composition
                        _highlightLayer.Add(start, end, /*TextDecorationCollection:*/null);
#endif

                            // Add the attribute range into CompositionAdorner.
                            _compositionAdorner.AddAttributeRange(start, end, displayAttribute);
                        }
                    }

                    Marshal.ReleaseComObject(attributeRanges[0]);
                }

#if UNUSED_IME_HIGHLIGHT_LAYER
                if (_highlightLayer != null)
                {
                    this.TextStore.TextContainer.Highlights.AddLayer(_highlightLayer);
                }
#endif

                if (_compositionAdorner != null)
                {
                    // Update the layout to get the acurated rectangle from calling GetRectangleFromTextPosition
                    this.TextStore.RenderScope.UpdateLayout();
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:TextServicesDisplayAttributePropertyRanges.cs

示例2: OnEndEdit

        internal virtual void OnEndEdit(UnsafeNativeMethods.ITfContext context,
                                        int ecReadOnly, 
                                        UnsafeNativeMethods.ITfEditRecord editRecord) 
        {
            int fetched;
            UnsafeNativeMethods.IEnumTfRanges ranges;
            UnsafeNativeMethods.ITfProperty prop = null;

            ranges = GetPropertyUpdate(editRecord);

            UnsafeNativeMethods.ITfRange [] outRanges;
            outRanges = new UnsafeNativeMethods.ITfRange[1];
            while (ranges.Next(1, outRanges, out fetched) == 0)
            {
                //
                // check the element has enabled dynamic property.
                //
                ITextPointer start;
                ITextPointer end;

                ConvertToTextPosition(outRanges[0], out start, out end);

                if (prop == null)
                    context.GetProperty(ref _guid, out prop);

                UnsafeNativeMethods.IEnumTfRanges rangesProp;

                if (prop.EnumRanges(ecReadOnly, out rangesProp, outRanges[0]) == 0)
                {
                    UnsafeNativeMethods.ITfRange [] outRangesProp;
                    outRangesProp = new UnsafeNativeMethods.ITfRange[1];
                    while (rangesProp.Next(1, outRangesProp, out fetched) == 0)
                    {
                        OnRange(prop, ecReadOnly, outRangesProp[0]);
                        Marshal.ReleaseComObject(outRangesProp[0]);
                    }
                    Marshal.ReleaseComObject(rangesProp);
                }

                Marshal.ReleaseComObject(outRanges[0]);

            }
            Marshal.ReleaseComObject(ranges);
            if (prop != null)
                Marshal.ReleaseComObject(prop);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:46,代码来源:TextServicesPropertyRanges.cs


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