private IniFile(string[] Content) : this() { string CurrentHeader = null; foreach (string ActiveLine in Content) { if (CurrentHeader == null && ActiveLine.StartsWith("[") && ActiveLine.EndsWith("]")) { CurrentHeader = ActiveLine.Remove(ActiveLine.Length - 1, 1).Substring(1); DicFieldValueByHeader.Add(CurrentHeader, new Dictionary <string, string>()); } else if (string.IsNullOrWhiteSpace(ActiveLine)) { CurrentHeader = null; } else { int IndexOfEquals = ActiveLine.IndexOf("="); string Key = ActiveLine.Substring(0, IndexOfEquals); string Value = ActiveLine.Substring(IndexOfEquals + 1); DicFieldValueByHeader[CurrentHeader].Add(Key, Value); } } }
public override void Draw(CustomSpriteBatch g) { g.End(); g.Begin(SpriteSortMode.Immediate, null); float YOffset = 0; int XPos = 320; if (TextAlign == TextAligns.Left) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { GameScreen.DrawText(g, ActiveLine, new Microsoft.Xna.Framework.Vector2(XPos, 630 + Progression + YOffset), Microsoft.Xna.Framework.Color.White); YOffset += GameScreen.fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Right) { XPos += TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { GameScreen.DrawTextRightAligned(g, ActiveLine, new Microsoft.Xna.Framework.Vector2(XPos, 630 + Progression + YOffset), Microsoft.Xna.Framework.Color.White); YOffset += GameScreen.fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Center) { foreach (string ActiveLine in ListText) { GameScreen.DrawTextMiddleAligned(g, ActiveLine, new Microsoft.Xna.Framework.Vector2(XPos, 630 + Progression + YOffset), Microsoft.Xna.Framework.Color.White); YOffset += GameScreen.fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Justified) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { float TextWidth = GameScreen.fntShadowFont.MeasureString(ActiveLine).X; float ScaleFactor = TextMaxWidthInPixel / TextWidth; for (int C = 0; C < ActiveLine.Length; ++C) { float Offset = GameScreen.fntShadowFont.MeasureString(ActiveLine.Substring(0, C)).X; GameScreen.DrawText(g, ActiveLine[C].ToString(), new Microsoft.Xna.Framework.Vector2(XPos + Offset * ScaleFactor, 630 + Progression + YOffset), Microsoft.Xna.Framework.Color.White); } YOffset += GameScreen.fntShadowFont.LineSpacing; } } g.End(); g.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); }
public static void DrawTextMultiline(CustomSpriteBatch g, SpriteFont TextFont, List <string> ListText, TextAligns TextAlign, float XPos, float YPos, int TextMaxWidthInPixel) { float YOffset = 0; if (TextAlign == TextAligns.Left) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { g.DrawString(TextFont, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White); YOffset += TextFont.LineSpacing; } } else if (TextAlign == TextAligns.Right) { XPos += TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { int TextWidth = (int)TextFont.MeasureString(ActiveLine).X; g.DrawString(TextFont, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White, 0f, new Vector2(TextWidth, 0), 1f, SpriteEffects.None, 0f); YOffset += TextFont.LineSpacing; } } else if (TextAlign == TextAligns.Center) { foreach (string ActiveLine in ListText) { int TextWidth = (int)TextFont.MeasureString(ActiveLine).X / 2; g.DrawString(TextFont, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White, 0f, new Vector2(TextWidth, 0), 1f, SpriteEffects.None, 0f); YOffset += TextFont.LineSpacing; } } else if (TextAlign == TextAligns.Justified) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { float TextWidth = TextFont.MeasureString(ActiveLine).X; float ScaleFactor = TextMaxWidthInPixel / TextWidth; for (int C = 0; C < ActiveLine.Length; ++C) { float Offset = TextFont.MeasureString(ActiveLine.Substring(0, C)).X; g.DrawString(TextFont, ActiveLine[C].ToString(), new Vector2(XPos + Offset * ScaleFactor, YPos + YOffset), Color.White); } YOffset += TextFont.LineSpacing; } } }
public static void DrawTextMultiline(CustomSpriteBatch g, List <string> ListText, TextAligns TextAlign, float XPos, float YPos, int TextMaxWidthInPixel) { float YOffset = 0; if (TextAlign == TextAligns.Left) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { DrawText(g, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White); YOffset += fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Right) { XPos += TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { DrawTextRightAligned(g, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White); YOffset += fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Center) { foreach (string ActiveLine in ListText) { DrawTextMiddleAligned(g, ActiveLine, new Vector2(XPos, YPos + YOffset), Color.White); YOffset += fntShadowFont.LineSpacing; } } else if (TextAlign == TextAligns.Justified) { XPos -= TextMaxWidthInPixel / 2; foreach (string ActiveLine in ListText) { float TextWidth = fntShadowFont.MeasureString(ActiveLine).X; float ScaleFactor = TextMaxWidthInPixel / TextWidth; for (int C = 0; C < ActiveLine.Length; ++C) { float Offset = fntShadowFont.MeasureString(ActiveLine.Substring(0, C)).X; DrawText(g, ActiveLine[C].ToString(), new Vector2(XPos + Offset * ScaleFactor, YPos + YOffset), Color.White); } YOffset += fntShadowFont.LineSpacing; } } }