internal virtual void OnEndEdit(UnsafeNativeMethods.ITfContext context, int ecReadOnly, UnsafeNativeMethods.ITfEditRecord editRecord)
        {
            UnsafeNativeMethods.ITfProperty   tfProperty     = null;
            UnsafeNativeMethods.IEnumTfRanges propertyUpdate = this.GetPropertyUpdate(editRecord);
            UnsafeNativeMethods.ITfRange[]    array          = new UnsafeNativeMethods.ITfRange[1];
            int num;

            while (propertyUpdate.Next(1, array, out num) == 0)
            {
                ITextPointer textPointer;
                ITextPointer textPointer2;
                this.ConvertToTextPosition(array[0], out textPointer, out textPointer2);
                if (tfProperty == null)
                {
                    context.GetProperty(ref this._guid, out tfProperty);
                }
                UnsafeNativeMethods.IEnumTfRanges enumTfRanges;
                if (tfProperty.EnumRanges(ecReadOnly, out enumTfRanges, array[0]) == 0)
                {
                    UnsafeNativeMethods.ITfRange[] array2 = new UnsafeNativeMethods.ITfRange[1];
                    while (enumTfRanges.Next(1, array2, out num) == 0)
                    {
                        this.OnRange(tfProperty, ecReadOnly, array2[0]);
                        Marshal.ReleaseComObject(array2[0]);
                    }
                    Marshal.ReleaseComObject(enumTfRanges);
                }
                Marshal.ReleaseComObject(array[0]);
            }
            Marshal.ReleaseComObject(propertyUpdate);
            if (tfProperty != null)
            {
                Marshal.ReleaseComObject(tfProperty);
            }
        }
Esempio n. 2
0
        private int GetInt32Value(int ecReadOnly, UnsafeNativeMethods.ITfProperty property, UnsafeNativeMethods.ITfRange range)
        {
            object value = TextServicesPropertyRanges.GetValue(ecReadOnly, property, range);

            if (value == null)
            {
                return(0);
            }
            return((int)value);
        }
        private Int32 GetInt32Value(int ecReadOnly, UnsafeNativeMethods.ITfProperty property, UnsafeNativeMethods.ITfRange range)
        {
            Object obj = GetValue(ecReadOnly, property, range);

            if (obj == null)
            {
                return(0);
            }

            return((Int32)obj);
        }
        protected static object GetValue(int ecReadOnly, UnsafeNativeMethods.ITfProperty property, UnsafeNativeMethods.ITfRange range)
        {
            if (property == null)
            {
                return(null);
            }
            object result;

            property.GetValue(ecReadOnly, range, out result);
            return(result);
        }
        protected static Object GetValue(int ecReadOnly, UnsafeNativeMethods.ITfProperty property, UnsafeNativeMethods.ITfRange range)
        {
            if (property == null)
            {
                return(null);
            }

            Object obj;

            property.GetValue(ecReadOnly, range, out obj);

            return(obj);
        }
        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);
            }
        }
Esempio n. 7
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);
                }
            }
        }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        /// <summary>
        ///     Apply attribute for the range and display attribute property.
        /// </summary>
        internal override void OnRange(
            UnsafeNativeMethods.ITfProperty property,
            int ecReadOnly,
            UnsafeNativeMethods.ITfRange range)
        {
            Int32 guidatom = GetInt32Value(ecReadOnly, property, range);

            if (guidatom != 0)
            {
                TextServicesDisplayAttribute attr;
                attr = GetDisplayAttribute(guidatom);
                if (attr != null)
                {
                    ITextPointer start;
                    ITextPointer end;

                    ConvertToTextPosition(range, out start, out end);

                    attr.Apply(start, end);
                }
            }
        }
 internal virtual void OnRange(UnsafeNativeMethods.ITfProperty property,
                               int ecReadonly,
                               UnsafeNativeMethods.ITfRange range)
 {
 }