// Token: 0x06002B51 RID: 11089 RVA: 0x000C5F3C File Offset: 0x000C413C internal void AddAttributeRange(ITextPointer start, ITextPointer end, TextServicesDisplayAttribute textServiceDisplayAttribute) { ITextPointer start2 = start.CreatePointer(LogicalDirection.Forward); ITextPointer end2 = end.CreatePointer(LogicalDirection.Backward); this._attributeRanges.Add(new CompositionAdorner.AttributeRange(this._textView, start2, end2, textServiceDisplayAttribute)); }
// Token: 0x06003C78 RID: 15480 RVA: 0x00117784 File Offset: 0x00115984 private static Color GetSystemColor(int index) { int sysColor = SafeNativeMethods.GetSysColor(index); uint num = (uint)TextServicesDisplayAttribute.FromWin32Value(sysColor); return(Color.FromArgb((byte)((num & 4278190080U) >> 24), (byte)((num & 16711680U) >> 16), (byte)((num & 65280U) >> 8), (byte)(num & 255U))); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Add the composition attribute range that will be rendered. /// Used in TextServicesDisplayAttributePropertyRanges (for composition display attribute) /// </summary> internal void AddAttributeRange(ITextPointer start, ITextPointer end, TextServicesDisplayAttribute textServiceDisplayAttribute) { // Set the range start/end point's logical direction ITextPointer rangeStart = start.CreatePointer(LogicalDirection.Forward); ITextPointer rangeEnd = end.CreatePointer(LogicalDirection.Backward); // Add the composition attribute range _attributeRanges.Add(new AttributeRange(_textView, rangeStart, rangeEnd, textServiceDisplayAttribute)); }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors internal AttributeRange(ITextView textView, ITextPointer start, ITextPointer end, TextServicesDisplayAttribute textServicesDisplayAttribute) { _textView = textView; _startOffset = start.Offset; _endOffset = end.Offset; _textServicesDisplayAttribute = textServicesDisplayAttribute; _compositionLines = new ArrayList(1); }
private static TextServicesDisplayAttribute GetDisplayAttribute(int guidatom) { if (TextServicesDisplayAttributePropertyRanges._attributes == null) { TextServicesDisplayAttributePropertyRanges._attributes = new Hashtable(); } TextServicesDisplayAttribute textServicesDisplayAttribute = (TextServicesDisplayAttribute)TextServicesDisplayAttributePropertyRanges._attributes[guidatom]; if (textServicesDisplayAttribute != null) { return(textServicesDisplayAttribute); } UnsafeNativeMethods.ITfCategoryMgr tfCategoryMgr; if (UnsafeNativeMethods.TF_CreateCategoryMgr(out tfCategoryMgr) != 0) { return(null); } if (tfCategoryMgr == null) { return(null); } Guid guid; tfCategoryMgr.GetGUID(guidatom, out guid); Marshal.ReleaseComObject(tfCategoryMgr); if (guid.Equals(UnsafeNativeMethods.Guid_Null)) { return(null); } UnsafeNativeMethods.ITfDisplayAttributeMgr tfDisplayAttributeMgr; if (UnsafeNativeMethods.TF_CreateDisplayAttributeMgr(out tfDisplayAttributeMgr) != 0) { return(null); } if (tfDisplayAttributeMgr == null) { return(null); } UnsafeNativeMethods.ITfDisplayAttributeInfo tfDisplayAttributeInfo; Guid guid2; tfDisplayAttributeMgr.GetDisplayAttributeInfo(ref guid, out tfDisplayAttributeInfo, out guid2); if (tfDisplayAttributeInfo != null) { UnsafeNativeMethods.TF_DISPLAYATTRIBUTE attr; tfDisplayAttributeInfo.GetAttributeInfo(out attr); textServicesDisplayAttribute = new TextServicesDisplayAttribute(attr); Marshal.ReleaseComObject(tfDisplayAttributeInfo); TextServicesDisplayAttributePropertyRanges._attributes[guidatom] = textServicesDisplayAttribute; } Marshal.ReleaseComObject(tfDisplayAttributeMgr); return(textServicesDisplayAttribute); }
// Token: 0x06003C71 RID: 15473 RVA: 0x00117698 File Offset: 0x00115898 internal static Color GetColor(UnsafeNativeMethods.TF_DA_COLOR dacolor, ITextPointer position) { if (dacolor.type == UnsafeNativeMethods.TF_DA_COLORTYPE.TF_CT_SYSCOLOR) { return(TextServicesDisplayAttribute.GetSystemColor(dacolor.indexOrColorRef)); } if (dacolor.type == UnsafeNativeMethods.TF_DA_COLORTYPE.TF_CT_COLORREF) { int indexOrColorRef = dacolor.indexOrColorRef; uint num = (uint)TextServicesDisplayAttribute.FromWin32Value(indexOrColorRef); return(Color.FromArgb((byte)((num & 4278190080U) >> 24), (byte)((num & 16711680U) >> 16), (byte)((num & 65280U) >> 8), (byte)(num & 255U))); } Invariant.Assert(position != null, "position can't be null"); return(((SolidColorBrush)position.GetValue(TextElement.ForegroundProperty)).Color); }
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 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); }
// Token: 0x06003C77 RID: 15479 RVA: 0x0011775C File Offset: 0x0011595C private static int FromWin32Value(int value) { return(TextServicesDisplayAttribute.Encode(255, value & 255, value >> 8 & 255, value >> 16 & 255)); }
// Token: 0x06003C72 RID: 15474 RVA: 0x00117722 File Offset: 0x00115922 internal Color GetLineColor(ITextPointer position) { return(TextServicesDisplayAttribute.GetColor(this._attr.crLine, position)); }
private static TextServicesDisplayAttribute GetDisplayAttribute(Int32 guidatom) { TextServicesDisplayAttribute attr = null; // Demand create the cache. if (_attributes == null) { _attributes = new Hashtable(); } attr = (TextServicesDisplayAttribute)_attributes[guidatom]; if (attr != null) return attr; // // Use category manager to convert guidatom to GUID. // UnsafeNativeMethods.ITfCategoryMgr catmgr; if (UnsafeNativeMethods.TF_CreateCategoryMgr(out catmgr) != NativeMethods.S_OK) return null; if (catmgr == null) return null; Guid guid; catmgr.GetGUID(guidatom, out guid); Marshal.ReleaseComObject(catmgr); // GetGUID could fail and reutrn GUID_NULL. if (guid.Equals(UnsafeNativeMethods.Guid_Null)) return null; // // Use DisplayAttributeMgr to get TF_DISPLAYATTRIBUTE. // UnsafeNativeMethods.ITfDisplayAttributeMgr dam; UnsafeNativeMethods.ITfDisplayAttributeInfo dai; UnsafeNativeMethods.TF_DISPLAYATTRIBUTE tfattr; if (UnsafeNativeMethods.TF_CreateDisplayAttributeMgr(out dam) != NativeMethods.S_OK) return null; if (dam == null) return null; Guid clsid; dam.GetDisplayAttributeInfo(ref guid, out dai, out clsid); if (dai != null) { dai.GetAttributeInfo(out tfattr); attr = new TextServicesDisplayAttribute(tfattr); Marshal.ReleaseComObject(dai); // // cache this into our hashtable. // _attributes[guidatom] = attr; } Marshal.ReleaseComObject(dam); return attr; }
// Decorates the composition with IME specified underlining. private void SetCompositionAdorner(int[] clauseInfo, byte[] attributes) { if ((clauseInfo != null) && (attributes != null)) { for (int i = 0; i < clauseInfo.Length - 1; i++) { ITextPointer startClause = _startComposition.CreatePointer(clauseInfo[i], LogicalDirection.Backward); ITextPointer endClause = _startComposition.CreatePointer(clauseInfo[i + 1], LogicalDirection.Forward); if (_compositionAdorner == null) { _compositionAdorner = new CompositionAdorner(_editor.TextView); _compositionAdorner.Initialize(_editor.TextView); } // // UnsafeNativeMethods.TF_DISPLAYATTRIBUTE displayAttribute = new UnsafeNativeMethods.TF_DISPLAYATTRIBUTE(); displayAttribute.crLine.type = UnsafeNativeMethods.TF_DA_COLORTYPE.TF_CT_COLORREF; displayAttribute.crLine.indexOrColorRef = 0; displayAttribute.lsStyle = UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_NONE; displayAttribute.fBoldLine = false; switch (attributes[clauseInfo[i]]) { case NativeMethods.ATTR_INPUT: displayAttribute.lsStyle = UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DOT; break; case NativeMethods.ATTR_TARGET_CONVERTED: displayAttribute.lsStyle = UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID; displayAttribute.fBoldLine = true; break; case NativeMethods.ATTR_CONVERTED: displayAttribute.lsStyle = UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID; break; case NativeMethods.ATTR_TARGET_NOTCONVERTED: displayAttribute.lsStyle = UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID; break; case NativeMethods.ATTR_INPUT_ERROR: break; case NativeMethods.ATTR_FIXEDCONVERTED: break; } #if UNUSED_IME_HIGHLIGHT_LAYER // Demand create the highlight layer. if (_highlightLayer == null) { _highlightLayer = new DisplayAttributeHighlightLayer(); } // ToDo: Need to pass the foreground and background color of the composition _highlightLayer.Add(startClause, endClause, /*TextDecorationCollection:*/null); #endif TextServicesDisplayAttribute textServiceDisplayAttribute = new TextServicesDisplayAttribute(displayAttribute); // Add the attribute range into CompositionAdorner. _compositionAdorner.AddAttributeRange(startClause, endClause, textServiceDisplayAttribute); } #if UNUSED_IME_HIGHLIGHT_LAYER if (_highlightLayer != null) { _editor.TextContainer.Highlights.AddLayer(_highlightLayer); } #endif if (_compositionAdorner != null) { // Update the layout to get the acurated rectangle from calling GetRectangleFromTextPosition _editor.TextView.RenderScope.UpdateLayout(); // Invalidate the composition adorner to apply the composition attribute ranges. _compositionAdorner.InvalidateAdorner(); } } }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods /// <summary> /// Access DisplayAttributeManager /// </summary> private static TextServicesDisplayAttribute GetDisplayAttribute(Int32 guidatom) { TextServicesDisplayAttribute attr = null; // Demand create the cache. if (_attributes == null) { _attributes = new Hashtable(); } attr = (TextServicesDisplayAttribute)_attributes[guidatom]; if (attr != null) { return(attr); } // // Use category manager to convert guidatom to GUID. // UnsafeNativeMethods.ITfCategoryMgr catmgr; if (UnsafeNativeMethods.TF_CreateCategoryMgr(out catmgr) != NativeMethods.S_OK) { return(null); } if (catmgr == null) { return(null); } Guid guid; catmgr.GetGUID(guidatom, out guid); Marshal.ReleaseComObject(catmgr); // GetGUID could fail and reutrn GUID_NULL. if (guid.Equals(UnsafeNativeMethods.Guid_Null)) { return(null); } // // Use DisplayAttributeMgr to get TF_DISPLAYATTRIBUTE. // UnsafeNativeMethods.ITfDisplayAttributeMgr dam; UnsafeNativeMethods.ITfDisplayAttributeInfo dai; UnsafeNativeMethods.TF_DISPLAYATTRIBUTE tfattr; if (UnsafeNativeMethods.TF_CreateDisplayAttributeMgr(out dam) != NativeMethods.S_OK) { return(null); } if (dam == null) { return(null); } Guid clsid; dam.GetDisplayAttributeInfo(ref guid, out dai, out clsid); if (dai != null) { dai.GetAttributeInfo(out tfattr); attr = new TextServicesDisplayAttribute(tfattr); Marshal.ReleaseComObject(dai); // // cache this into our hashtable. // _attributes[guidatom] = attr; } Marshal.ReleaseComObject(dam); return(attr); }