Esempio n. 1
0
        internal override void OnRange(UnsafeNativeMethods.ITfProperty property, int ecReadOnly, UnsafeNativeMethods.ITfRange range)
        {
            int int32Value = this.GetInt32Value(ecReadOnly, property, range);

            if (int32Value != 0)
            {
                TextServicesDisplayAttribute displayAttribute = TextServicesDisplayAttributePropertyRanges.GetDisplayAttribute(int32Value);
                if (displayAttribute != null)
                {
                    ITextPointer start;
                    ITextPointer end;
                    base.ConvertToTextPosition(range, out start, out end);
                    displayAttribute.Apply(start, end);
                }
            }
        }
Esempio n. 2
0
        internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context, int ecReadOnly, UnsafeNativeMethods.ITfEditRecord editRecord)
        {
            if (this._compositionAdorner != null)
            {
                this._compositionAdorner.Uninitialize();
                this._compositionAdorner = null;
            }
            Guid guid = base.Guid;

            UnsafeNativeMethods.ITfProperty tfProperty;
            context.GetProperty(ref guid, out tfProperty);
            UnsafeNativeMethods.IEnumTfRanges enumTfRanges;
            if (tfProperty.EnumRanges(ecReadOnly, out enumTfRanges, null) == 0)
            {
                UnsafeNativeMethods.ITfRange[] array = new UnsafeNativeMethods.ITfRange[1];
                int num;
                while (enumTfRanges.Next(1, array, out num) == 0)
                {
                    int int32Value = this.GetInt32Value(ecReadOnly, tfProperty, array[0]);
                    TextServicesDisplayAttribute displayAttribute = TextServicesDisplayAttributePropertyRanges.GetDisplayAttribute(int32Value);
                    if (displayAttribute != null && !displayAttribute.IsEmptyAttribute())
                    {
                        ITextPointer textPointer;
                        ITextPointer end;
                        base.ConvertToTextPosition(array[0], out textPointer, out end);
                        if (textPointer != null)
                        {
                            if (this._compositionAdorner == null)
                            {
                                this._compositionAdorner = new CompositionAdorner(base.TextStore.TextView);
                                this._compositionAdorner.Initialize(base.TextStore.TextView);
                            }
                            this._compositionAdorner.AddAttributeRange(textPointer, end, displayAttribute);
                        }
                    }
                    Marshal.ReleaseComObject(array[0]);
                }
                if (this._compositionAdorner != null)
                {
                    base.TextStore.RenderScope.UpdateLayout();
                    this._compositionAdorner.InvalidateAdorner();
                }
                Marshal.ReleaseComObject(enumTfRanges);
            }
            Marshal.ReleaseComObject(tfProperty);
        }