public void Clear() { switch (WindowType) { case GHWinType.Map: ClientGamePage.ClearMap(); break; } lock (PutStrsLock) { PutStrs.Clear(); } lock (_clientGame.WindowsLock) { _height = 0; _width = 0; _pixelWidth = 0; _pixelHeight = 0; CursX = 0; CursY = 0; } if (_winType == GHWinType.Menu || _winType == GHWinType.Text) { ConcurrentQueue <GHRequest> queue; if (ClientGame.RequestDictionary.TryGetValue(_clientGame, out queue)) { queue.Enqueue(new GHRequest(_clientGame, GHRequestType.ClearWindowView, _winId)); } } }
public void PutStrEx(int attributes, string str, int append, int color) { lock (PutStrsLock) { SKPaint textPaint = new SKPaint() { Typeface = Typeface, TextSize = TextSize }; if (CursY >= PutStrs.Count) { for (int i = 0; i < CursY - PutStrs.Count + 1; i++) { PutStrs.Add(new GHPutStrItem("")); } } if (CursY >= 0) { if (PutStrs[CursY] == null) { PutStrs[CursY] = new GHPutStrItem(""); } else if (PutStrs[CursY].Text == null) { PutStrs[CursY].Text = ""; } int len = str.Length; string curstr = PutStrs[CursY].Text; int curlen = curstr.Length; List <int> curattrs; List <int> curclrs; PutStrs[CursY].ConvertCurrentListToArrays(out curattrs, out curclrs); //if (append != 0) // CursX = PutStrs[CursY].Text.Length; int origCursX = CursX; if (CursX > curlen) { int n = CursX - curlen; string spaces = new String(' ', n); curstr = curstr + spaces; curlen = curstr.Length; } string leftstr = CursX <= 0 ? "" : curstr.Substring(0, CursX); //string rightstr = curstr.Length <= CursX + len ? "" : curstr.Substring(CursX + len, curlen - (CursX + len)); PutStrs[CursY].Text = leftstr + str; // + rightstr; CursX += str.Length; // Adjust TextSize property so text is 90% of screen width float textWidth = textPaint.MeasureText(PutStrs[CursY].Text); //.Replace(' ', '_')); textWidth += Padding.Left + Padding.Right; if (textWidth > _pixelWidth) { _pixelWidth = textWidth; } if (PutStrs[CursY].Text.Length > _width) { _width = PutStrs[CursY].Text.Length; } if (CursY + 1 > _height) { _height = CursY + 1; } int i; for (i = origCursX; i < CursX; i++) { while (i > curattrs.Count) { curattrs.Add(0); } while (i > curclrs.Count) { curclrs.Add((int)nhcolor.CLR_WHITE); } if (i == curattrs.Count) { curattrs.Add(attributes); } else if (i < curattrs.Count) { curattrs[i] = attributes; } if (i == curclrs.Count) { curclrs.Add(color); } else if (i < curattrs.Count) { curclrs[i] = color; } } PutStrs[CursY].ConvertCurrentListFromArrays(curattrs, curclrs); if (AutoCarriageReturn && append == 0) { CursY++; CursX = 0; } } float textHeight = textPaint.FontMetrics.Descent - textPaint.FontMetrics.Ascent; _pixelHeight = _height * textHeight + Padding.Top + Padding.Bottom; } }