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


C# Text.GetRect方法代码示例

本文整理汇总了C#中SFML.Graphics.Text.GetRect方法的典型用法代码示例。如果您正苦于以下问题:C# Text.GetRect方法的具体用法?C# Text.GetRect怎么用?C# Text.GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFML.Graphics.Text的用法示例。


在下文中一共展示了Text.GetRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public void Draw(RenderTarget rt)
        {
            DateTime now = DateTime.Now;

            Text message = new Text("", myFont);
            message.CharacterSize = 14;

            int removeCount = 0;
            foreach(KeyValuePair<DateTime, String> pair in msgList){
             	message.DisplayedString += pair.Value + "\n";
                if((now - pair.Key).TotalSeconds > messageLifeTime)
                    removeCount++;
            }

            msgList.RemoveRange(0, removeCount);
            message.Position = new Vector2f(14, rt.Height - 54 - message.GetRect().Height);
            rt.Draw(message);

            if(writing){
                Text display = new Text("say : " + toWrite + "_", myFont);
                display.CharacterSize = 14;
                display.Position = new Vector2f(14, rt.Height - 36 - display.GetRect().Height);
                rt.Draw(display);
            }
        }
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:25,代码来源:Chat.cs

示例2: FormatMessage

        bool FormatMessage()
        {
            FormattedMessage.Clear();

            if (Words.Count <= 0)
                return false;

            Text text = new Text(string.Empty, Info.Font, Info.Size);
            text.Style = Info.Styles;
            int wordCount = 0;

            text.DisplayedString += Words[wordCount++];
            if (text.GetRect().Height > Info.MaxDimension.Y)
                return false;

            if (text.GetRect().Width > Info.MaxDimension.X)
                return CutWord(0);

            while (wordCount < Words.Count)
            {
                text.DisplayedString += (text.DisplayedString == string.Empty ? "" : " ") + Words[wordCount];

                if (text.GetRect().Width > Info.MaxDimension.X)
                {
                    text.DisplayedString =
                        text.DisplayedString.Substring(
                        0,
                        text.DisplayedString.Length - (Words[wordCount].Length + (text.DisplayedString.Length <= Words[wordCount].Length ? 0 : 1)));
                    text.DisplayedString += "\n" + Words[wordCount];

                    if (text.GetRect().Height > Info.MaxDimension.Y)
                    {
                        text.DisplayedString = text.DisplayedString.Substring(
                            0,
                            text.DisplayedString.Length - (Words[wordCount].Length + 1));

                        FormattedMessage.Add(text.DisplayedString);

                        text.DisplayedString = string.Empty;
                        continue;
                    }
                }

                if (text.GetRect().Width > Info.MaxDimension.X)
                    return CutWord(wordCount);

                ++wordCount;
            }

            if (text.DisplayedString != string.Empty)
                FormattedMessage.Add(text.DisplayedString);

            return true;
        }
开发者ID:eickegao,项目名称:Blazera,代码行数:54,代码来源:MessageBuilder.cs

示例3: CutWord

        /// <summary>
        /// Cut a word that does not fit in one row placing a '-' at the limit.
        /// </summary>
        /// <param name="wordIndex">Index of word that must be cut.</param>
        /// <returns>True if the operation is successful.</returns>
        bool CutWord(int wordIndex)
        {
            string word = Words[wordIndex];
            Text text = new Text(word, Info.Font, Info.Size);
            text.Style = Info.Styles;

            int count = 0;
            while (text.GetRect().Width > Info.MaxDimension.X)
            {
                if (count > 0)
                    text.DisplayedString = text.DisplayedString.Substring(0, text.DisplayedString.Length - 1);

                text.DisplayedString = text.DisplayedString.Substring(0, word.Length - ++count);
                text.DisplayedString += "-";
            }

            Words.Insert(wordIndex, text.DisplayedString);
            Words[wordIndex + 1] = word.Substring(word.Length - count);

            FormatMessage();

            return true;
        }
开发者ID:eickegao,项目名称:Blazera,代码行数:28,代码来源:MessageBuilder.cs

示例4: DrawPlayersPseudo

 //UTILS
 private void DrawPlayersPseudo()
 {
     foreach (NetworkClient c in otherClients.Values){
         Text pseudo = new Text(c.Pseudo, myFont);
         pseudo.CharacterSize = 12;
         pseudo.Color = Color.White;
         pseudo.Position = c.Player.Position - new Vector2f(pseudo.GetRect().Width / 2 - c.Player.Bbox.Width / 2, 20);
         world.Draw(pseudo);
     }
 }
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:11,代码来源:Client.cs

示例5: Render

 private static void Render(RenderTarget r)
 {
     if (!NeedsRedraw)
     {
         return;
     }
     for (int i = 0; i < Walls.GetLength(0); i++)
         for (int j = 0; j < Walls.GetLength(1); j++)
             if (!Walls[i, j] && !VisitedWalls[i, j])
                 target.SetPixel((uint) i + 1, (uint) j + 1, ForegroundColor);
             else
                 target.SetPixel((uint) i + 1, (uint) j + 1, BackgroundColor);
     if (!Solving)
         target.SetPixel((uint) CurrentCell.X*2 + 1, (uint) CurrentCell.Y*2 + 1, CurrentCellColor);
     if (FinishedGenerating)
         target.SetPixel((uint) EndCell.X*2 + 1, (uint) EndCell.Y*2 + 1, EndCellColor);
     if (Solving)
     {
         for (int i = 0; i < VisitedWalls.GetLength(0); i++)
             for (int j = 0; j < VisitedWalls.GetLength(1); j++)
                 if (VisitedWalls[i, j])
                     target.SetPixel((uint) i + 1, (uint) j + 1, VisitedCellColor);
         foreach (IntPair i in CellStack)
             target.SetPixel((uint) i.X + 1, (uint) i.Y + 1, PathColor);
         target.SetPixel((uint) (CurrentCell.X*(Solving ? 1 : 2) + 1), (uint) CurrentCell.Y + 1, CurrentCellColor);
     }
     target.SetPixel((uint) StartCell.X*2 + 1, (uint) StartCell.Y*2 + 1, BeginCellColor);
     var celltext = new Text((1/((RenderWindow) r).GetFrameTime()).ToString());
     celltext.Position = new Vector2(0, r.Height - celltext.GetRect().Height);
     celltext.Color = BackgroundColor;
     r.Draw(new Sprite {Image = target, Scale = new Vector2(10, 10)});
     r.Draw(Shape.Rectangle(celltext.GetRect(), ForegroundColor));
     r.Draw(celltext);
 }
开发者ID:Phyxius,项目名称:Maze-Gen,代码行数:34,代码来源:Program.cs

示例6: Draw

        //TODO Clean with a drawtext method
        public void Draw(RenderTarget rt)
        {
            float maxX = 0;
            Vector2f position = new Vector2f(2,0);
            Text text = new Text("", Screen.ARIAL);

            if(current == null)
                text.DisplayedString = "Logical Drives";
            else
                text.DisplayedString = current.FullName;

            text.CharacterSize = 12;
            rt.Draw(text);
            position.Y += text.GetRect().Height + 4;
            float startY = position.Y;

            int index = 0;
            foreach(DirectoryInfo d in directories){

                if(index == cursor)
                    text.Color = Color.Yellow;
                else
                    text.Color = Color.White;
                if(current == null)
                    text.DisplayedString = d.Name;
                else
                    text.DisplayedString = "\\" + d.Name;

                if(text.GetRect().Top + text.GetRect().Height > rt.Height - 10){
                    position.X += maxX + 2;
                    position.Y = startY;
                    maxX = 0;
                }

                text.Position = position;
                rt.Draw(text);
                position.Y += text.GetRect().Height + 4;
                index++;

                maxX = Math.Max(maxX, text.GetRect().Width);
            }

            if(!load && current != null){

                if(index == cursor)
                    text.Color = Color.Yellow;
                else
                    text.Color = Color.White;

                if(editMode == NEWDIRECTORY)
                    text.DisplayedString = newName + "_";
                else
                    text.DisplayedString = "New directory";

                if(text.GetRect().Top + text.GetRect().Height > rt.Height - 10){
                    position.X += maxX + 2;
                    position.Y = startY;
                    maxX = 0;
                }

                text.Position = position;
                rt.Draw(text);
                position.Y += text.GetRect().Height + 4;
                index++;

                maxX = Math.Max(maxX, text.GetRect().Width);

            }

            foreach(FileInfo f in files){

                if(index == cursor)
                    text.Color = Color.Yellow;
                else
                    text.Color = Color.White;

                text.DisplayedString = f.Name;

                if(text.GetRect().Top + text.GetRect().Height > rt.Height - 10){
                    position.X += maxX + 2;
                    position.Y = startY;
                    maxX = 0;
                }

                text.Position = position;
                rt.Draw(text);
                position.Y += text.GetRect().Height + 4;
                index++;

                maxX = Math.Max(maxX, text.GetRect().Width);
            }

            if(!load && current != null){

                if(index == cursor)
                    text.Color = Color.Yellow;
                else
                    text.Color = Color.White;

//.........这里部分代码省略.........
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:101,代码来源:FileLister.cs


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