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


C# Drawing.CharacterRange类代码示例

本文整理汇总了C#中System.Drawing.CharacterRange的典型用法代码示例。如果您正苦于以下问题:C# CharacterRange类的具体用法?C# CharacterRange怎么用?C# CharacterRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CharacterRange类属于System.Drawing命名空间,在下文中一共展示了CharacterRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DwellOnIdentifierEventArgs

 /// <summary>
 /// Creates DwellOnIdentifierEventArgs instance with read-only values set
 /// </summary>
 /// <param name="identifier"></param>
 /// <param name="identifierRange"></param>
 /// <param name="visibleRange"></param>
 /// <param name="visibleText"></param>
 public DwellOnIdentifierEventArgs(string identifier, CharacterRange identifierRange, CharacterRange visibleRange, string visibleText)
 {
     Identifier = identifier;
     IdentifierRange = identifierRange;
     VisibleRange = visibleRange;
     VisibleText = visibleText;
 }
开发者ID:HTD,项目名称:TraxCodeEditor,代码行数:14,代码来源:DwellOnIdentifierEventArgs.cs

示例2: MeasureString

        public static SizeF MeasureString(Graphics g, string str, Font font, Rectangle rect, StringFormat sf)
        {
            var sfTemp = sf.Clone() as StringFormat;
            var ranges = new CharacterRange[] { new CharacterRange(0, str.Length) };
            sfTemp.SetMeasurableCharacterRanges(ranges);

            var regions = g.MeasureCharacterRanges(str, font, rect, sfTemp);
            if (regions != null && regions.Length > 0) return regions[0].GetBounds(g).Size;
            return new SizeF();
        }
开发者ID:cmrazek,项目名称:ProbeNpp,代码行数:10,代码来源:Util.cs

示例3: Word

            public Word(CharacterRange range, string text)
            {
                if (text == null)
                    throw new ArgumentNullException("text");

                Debug.Assert(text.Length > 0);

                _range = range;
                _text = text;
            }
开发者ID:modulexcite,项目名称:NTranslate,代码行数:10,代码来源:SpellCheckTextBox.Word.cs

示例4: findCharacterPositionInPart

        private int findCharacterPositionInPart(DocumentRow row, StylizedRowElement atom, float offset)
        {
            int farLength = atom.range.Length;
            int nearLength = 0;

            CharacterRange range = new CharacterRange(0, farLength);
            string test = row.Raw.Substring(range.First, range.Length);

            float nearSize = 0;
            float farSize = MeasureStringPart(range, test, atom.style).Size.Width;

            if (nearSize > offset) return nearLength;
            if (farSize < offset) return farLength - 1;

            while (farLength > nearLength)
            {
                if (farSize < offset)
                {
                    break;
                }

                if (nearSize > offset)
                {
                    farLength = nearLength;
                    break;
                }

                range = new CharacterRange(0, nearLength + (farLength - nearLength) / 2);
                test = row.Raw.Substring(range.First, range.Length);
                float middle = MeasureStringPart(range, test, atom.style).Size.Width;

                if (middle < offset)
                {
                    if (nearLength == range.Length)
                    {
                        return farSize - middle > middle - nearSize ? nearLength : farLength;
                    }

                    nearLength = range.Length;
                    nearSize = middle;
                }
                else
                {
                    if (farLength == range.Length)
                    {
                        return farSize - middle > middle - nearSize ? nearLength : farLength;
                    }

                    farLength = range.Length;
                    farSize = middle;
                }
            }

            return farLength;
        }
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:55,代码来源:DocumentView.mouse.cs

示例5: GetTextSize

 private static SizeF GetTextSize(string str, Graphics g, bool fTitle) {
     SizeF empty = SizeF.Empty;
     CharacterRange[] ranges = new CharacterRange[] { new CharacterRange(0, str.Length) };
     sfMeasure.SetMeasurableCharacterRanges(ranges);
     Region[] regionArray = g.MeasureCharacterRanges(str, fTitle ? font : fontSubText, rctMeasure, sfMeasure);
     using(regionArray[0]) {
         empty = regionArray[0].GetBounds(g).Size;
         empty.Width += 6f;
     }
     return empty;
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:11,代码来源:QTabItemBase.cs

示例6: EMFStringFormat

        private EMFStringFormat(byte[] RecordData)        
        {
            ObjectType = EmfObjectType.stringformat;
            myStringFormat = new System.Drawing.StringFormat();
            //put the Data into a stream and use a binary reader to read the data
            MemoryStream _ms = new MemoryStream(RecordData);
            BinaryReader _br = new BinaryReader(_ms);           
            _br.ReadUInt32(); //Who cares about version..not me!            
            myStringFormat.FormatFlags = (StringFormatFlags)_br.ReadUInt32();
            _br.ReadBytes(4);//Language...Ignore for now!
            myStringFormat.LineAlignment = (StringAlignment)_br.ReadUInt32();
            myStringFormat.Alignment = (StringAlignment)_br.ReadUInt32();
            UInt32 DigitSubstitutionMethod = _br.ReadUInt32();
            UInt32 DigitSubstitutionLanguage = _br.ReadUInt32();
            myStringFormat.SetDigitSubstitution((int)DigitSubstitutionLanguage, (StringDigitSubstitute)DigitSubstitutionMethod);
            
            Single FirstTabOffSet = _br.ReadSingle();

            myStringFormat.HotkeyPrefix = (System.Drawing.Text.HotkeyPrefix) _br.ReadInt32();

             _br.ReadSingle();//leading Margin
             _br.ReadSingle();//trailingMargin           
             _br.ReadSingle();//tracking
            myStringFormat.Trimming = (StringTrimming)_br.ReadUInt32();           
            Int32 TabStopCount = _br.ReadInt32();
            Int32 RangeCount = _br.ReadInt32();
            //Next is stringformatdata...
            Single[] TabStopArray;           
            System.Drawing.CharacterRange[] RangeArray;

            if (TabStopCount > 0)
            {
                TabStopArray = new Single[TabStopCount];
                for (int i = 0; i < TabStopCount; i++)
                {
                    TabStopArray[i] = _br.ReadSingle();
                }
                myStringFormat.SetTabStops(FirstTabOffSet, TabStopArray);
            }

            if (RangeCount > 0)
            {
                RangeArray = new System.Drawing.CharacterRange[RangeCount];
                for (int i = 0; i < RangeCount; i++)
                {
                    RangeArray[i].First = _br.ReadInt32();
                    RangeArray[i].Length = _br.ReadInt32();
                }
                myStringFormat.SetMeasurableCharacterRanges(RangeArray);
            }
        }
开发者ID:JackWangCUMT,项目名称:rdlc.report.engine,代码行数:51,代码来源:EMFStringFormat.cs

示例7: GetTextSize

 public static Size GetTextSize(Graphics graphics, string text, Font font, Size size)
 {
    if (text.Length == 0)
    {
       return Size.Empty;
    }
    StringFormat stringFormat = new StringFormat();
    stringFormat.FormatFlags = StringFormatFlags.FitBlackBox;
    RectangleF layoutRect = new RectangleF(0f, 0f, size.Width, size.Height);
    CharacterRange[] ranges = new CharacterRange[] {new CharacterRange(0, text.Length)};
    Region[] regionArray = new Region[1];
    stringFormat.SetMeasurableCharacterRanges(ranges);
    Rectangle rectangle =
       Rectangle.Round(graphics.MeasureCharacterRanges(text, font, layoutRect, stringFormat)[0].GetBounds(graphics));
    return new Size(rectangle.Width, rectangle.Height);
 }
开发者ID:NanQi,项目名称:demo,代码行数:16,代码来源:TextUtil.cs

示例8: GetCharacterXPositions

        public float[] GetCharacterXPositions( Graphics g, string str )
        {
            // Setup the StringFormat with proper CharacterRange references.
            StringFormat testFormat = new StringFormat();
            CharacterRange[] ranges = new CharacterRange[ str.Length ];
            for ( int i=0; i < str.Length; i++ )
                ranges[i] = new CharacterRange( i, 1 );

            testFormat.SetMeasurableCharacterRanges( ranges );

            // Measure into Regions
            Region[] regions = g.MeasureCharacterRanges( str, _font, new Rectangle( 0, 0, 1000, 1000 ), testFormat );

            // Convert Regions to Rects, then X coords.
            float[] xCoords = regions.Select( region => region.GetBounds( g ).X ).ToArray();
            return xCoords;
        }
开发者ID:SudoMike,项目名称:SudoFont,代码行数:17,代码来源:DotNetFontSystem.cs

示例9: getDrawLength

 private static int getDrawLength(Graphics g, Font fnt, RectangleF rect, StringFormat sf, int maxLen)
 {
     CharacterRange[] ranges = new CharacterRange[] { new CharacterRange(0, 1) };
     float num = 1f;
     float width = 0f;
     int num3 = 2;
     string text = StrFunc.CreateInstance().MakeCycleStr(maxLen, "X");
     while ((num3 <= maxLen) && (width != num))
     {
         num = width;
         ranges[0].Length = num3;
         sf.SetMeasurableCharacterRanges(ranges);
         width = g.MeasureCharacterRanges(text, fnt, rect, sf)[0].GetBounds(g).Width;
         num3++;
     }
     if (num3 == maxLen)
     {
         return maxLen;
     }
     return (num3 - 1);
 }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:21,代码来源:ComponentProperty.cs

示例10: FaceApplied

 public FaceApplied(string face, CharacterRange range)
 {
     this.face = face;
     this.range = range;
 }
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:5,代码来源:Document.style.cs

示例11: intersect

 private static bool intersect(CharacterRange lhs, CharacterRange rhs)
 {
     var min = Math.Max(lhs.First, rhs.First);
     var max = Math.Min(lhs.First + lhs.Length, rhs.First + rhs.Length);
     return min < max;
 }
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:6,代码来源:Document.style.cs

示例12: combine

        private StylizedRowElement[] combine(DocumentRow row, ICollection<FaceApplied> styles)
        {
            if (styles == null || styles.Count == 0)
            {
                var result = new StylizedRowElement[1];
                result[0] = new StylizedRowElement(new CharacterRange(0, row.Length), style);
                return result;
            }

            var elements = new List<CharacterRange>
            {
                new CharacterRange(0, row.Length)
            };

            foreach (var styleApplied in styles)
            {
                var faceRange = styleApplied.Range;

                for (var i = 0; i < elements.Count; ++i)
                {
                    CharacterRange element = elements[i];

                    //if we are before range needed
                    if (element == faceRange)
                    {
                        continue;
                    }

                    if (element.First + element.Length < faceRange.First)
                    {
                        continue;
                    }

                    // if we are after range needed
                    if (element.First >= faceRange.First + faceRange.Length)
                    {
                        break;
                    }

                    // if face range after element start
                    if (element.First < faceRange.First)
                    {
                        var preFace = new CharacterRange(element.First, faceRange.First - element.First);

                        element.Length -= preFace.Length;
                        element.First += preFace.Length;
                        elements[i] = element;

                        elements.Insert(i++, preFace);
                    }

                    if (element.First + element.Length <= faceRange.First + faceRange.Length)
                    {
                        continue;
                    }

                    var afterOffset = faceRange.First + faceRange.Length;
                    var afterOffsetLength = element.First + element.Length - afterOffset;

                    element.Length -= afterOffsetLength;
                    elements[i] = element;

                    elements.Insert(++i, new CharacterRange(afterOffset, afterOffsetLength));
                }
            }

            var els = new List<StylizedRowElement>();
            foreach (var range in elements)
            {
                var rangeStyle = Style;
                foreach (var face in styles)
                {
                    if (!intersect(face.Range, range))
                        continue;
                    rangeStyle = rangeStyle.Combine(FindFace(face.Face).FaceStyle);
                }

                els.Add(new StylizedRowElement(range, rangeStyle));
            }

            return els.ToArray();
        }
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:82,代码来源:Document.style.cs

示例13: StylizedRowElement

 public StylizedRowElement(CharacterRange range, Style style)
 {
     this.range = range;
     this.style = style;
 }
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:5,代码来源:Document.style.cs

示例14: TextSize

        /// <summary>
        /// Calculate widthLimit/height of a text (
        /// </summary>
        public static SizeF TextSize(Graphics g, string aText, Font aFont)
        {
            if (aText.Trim() == "") return new SizeF(0, 0);
            if (aText[aText.Length - 1] == ' ') { aText = aText.Substring(0, aText.Length - 1) + "/"; }
            #if CF
            return TextSize2(g, aText, aFont);
            #else
            try
            {
                if (aFont.Style == FontStyle.Bold)
                { return TextSize2(g, aText, aFont); } //MeasureCharacterRanges return wrong value if bold.

                StringFormat aFormat = StringFormat.GenericTypographic;
                //aFormat.Trimming = System.Drawing.StringTrimming.Character;
                //aFormat.FormatFlags += 16384;
                //aFormat.FormatFlags = aFormat.FormatFlags & StringFormatFlags.NoClip;

                CharacterRange[] cr = new CharacterRange[1];
                cr[0] = new CharacterRange(0, aText.Length);

                aFormat.SetMeasurableCharacterRanges(cr);

                RectangleF aRect = Screen.PrimaryScreen.Bounds;
                aRect = g.MeasureCharacterRanges(aText, aFont, aRect, aFormat)[0].GetBounds(g);
                return new SizeF(aRect.Right - aRect.Left, aRect.Height);
            }
            catch
            {
                return TextSize2(g, aText, aFont);
            }

            #endif
        }
开发者ID:sinelaw,项目名称:HtmlTextBlock,代码行数:36,代码来源:Utils.cs

示例15: RenderRowView

        private void RenderRowView(
            Graphics g,
            DocumentRowView view,
            float offset,
            CharacterRange selectionRange)
        {
            for (int i = 0; i < view.parts.Length; ++i)
            {
                StylizedRowElement atom = view.parts[i];
                string atomRaw = view.partRaws[i];

                CharacterRangeTrio trio = intersectAtomWithSelection(atom.range, selectionRange);
                if (trio.first.Length > 0)
                {
                    trio.first.First -= atom.range.First;

                    offset += DrawStringPart(trio.first, g, atomRaw, atom.style, offset).Width;
                }

                if (trio.second.Length > 0)
                {
                    trio.second.First -= atom.range.First;

                    Style thisStyle = atom.style.combine(selectionStyle);

                    offset += DrawStringPart(trio.second, g, atomRaw, thisStyle, offset).Width;
                }

                if (trio.third.Length > 0)
                {
                    trio.third.First -= atom.range.First;

                    offset += DrawStringPart(trio.third, g, atomRaw, atom.style, offset).Width;
                }
            }
            renderStuff.LineFrame = offset;
        }
开发者ID:killbug2004,项目名称:partcover-fork,代码行数:37,代码来源:DocumentView.draw.cs


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