當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。