Beispiel #1
0
        public HResult GetType(out NiTextMarkerType type)
        {
            switch (_marker.TextMarkerType & ~TextMarkerType.ExtendToBorder)
            {
                case TextMarkerType.Invisible: type = NiTextMarkerType.Invisible; break;
                case TextMarkerType.SolidBlock: type = NiTextMarkerType.SolidBlock; break;
                case TextMarkerType.Underlined: type = NiTextMarkerType.Underline; break;
                case TextMarkerType.WaveLine: type = NiTextMarkerType.WaveLine; break;
                default: type = 0; break;
            }

            return HResult.OK;
        }
Beispiel #2
0
        private TextMarkerType GetTextMarkerType(NiTextMarkerType type, bool extendToBorder)
        {
            TextMarkerType result;

            switch (type)
            {
                case NiTextMarkerType.Invisible: result = TextMarkerType.Invisible; break;
                case NiTextMarkerType.SolidBlock: result = TextMarkerType.SolidBlock; break;
                case NiTextMarkerType.Underline: result = TextMarkerType.Underlined; break;
                case NiTextMarkerType.WaveLine: result = TextMarkerType.WaveLine; break;
                default: throw new ArgumentOutOfRangeException("type");
            }

            if (extendToBorder)
                result |= TextMarkerType.ExtendToBorder;

            return result;
        }
Beispiel #3
0
        public HResult CreateTextMarker(NiTextMarkerType type, NiTextMarkerHatchStyle hatchStyle, bool extendToBorder, int color, int foreColor, int startLine, int startIndex, int endLine, int endIndex, out INiTextMarker textMarker)
        {
            textMarker = null;

            try
            {
                var range = TranslateOffset(startLine, startIndex, endLine, endIndex);
                var nativeType = GetTextMarkerType(type, extendToBorder);
                var drawingColor = Color.FromArgb(color);
                var drawingForeColor = Color.FromArgb(foreColor);

                TextMarker nativeMarker;

                // The TextMarker interface is crap. We cannot simply call
                // the constructor with all the arguments, because calling
                // the constructor determines whether a property is available.

                if (hatchStyle != NiTextMarkerHatchStyle.Default)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor,
                        drawingForeColor,
                        Enum<HatchStyle>.Parse(hatchStyle.ToString())
                    );
                }
                else if (drawingForeColor.A != 0)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor,
                        drawingForeColor
                    );
                }
                else if (drawingColor.A != 0)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor
                    );
                }
                else
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType
                    );
                }

                OnBeginUpdate(EventArgs.Empty);

                try
                {
                    Document.MarkerStrategy.AddMarker(nativeMarker);
                }
                finally
                {
                    OnEndUpdate(EventArgs.Empty);
                }

                textMarker = new NiTextMarker(this, nativeMarker);

                return HResult.OK;
            }
            catch (Exception ex)
            {
                return ErrorUtil.GetHResult(ex);
            }
        }
Beispiel #4
0
        public HResult CreateTextMarker(NiTextMarkerType type, NiTextMarkerHatchStyle hatchStyle, bool extendToBorder, int color, int foreColor, int startLine, int startIndex, int endLine, int endIndex, out INiTextMarker textMarker)
        {
            textMarker = null;

            try
            {
                var range            = TranslateOffset(startLine, startIndex, endLine, endIndex);
                var nativeType       = GetTextMarkerType(type, extendToBorder);
                var drawingColor     = Color.FromArgb(color);
                var drawingForeColor = Color.FromArgb(foreColor);

                TextMarker nativeMarker;

                // The TextMarker interface is crap. We cannot simply call
                // the constructor with all the arguments, because calling
                // the constructor determines whether a property is available.

                if (hatchStyle != NiTextMarkerHatchStyle.Default)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor,
                        drawingForeColor,
                        Enum <HatchStyle> .Parse(hatchStyle.ToString())
                        );
                }
                else if (drawingForeColor.A != 0)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor,
                        drawingForeColor
                        );
                }
                else if (drawingColor.A != 0)
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType,
                        drawingColor
                        );
                }
                else
                {
                    nativeMarker = new TextMarker(
                        range.Offset,
                        range.Length,
                        nativeType
                        );
                }

                OnBeginUpdate(EventArgs.Empty);

                try
                {
                    Document.MarkerStrategy.AddMarker(nativeMarker);
                }
                finally
                {
                    OnEndUpdate(EventArgs.Empty);
                }

                textMarker = new NiTextMarker(this, nativeMarker);

                return(HResult.OK);
            }
            catch (Exception ex)
            {
                return(ErrorUtil.GetHResult(ex));
            }
        }