public void Paste() { IDataObject t = Clipboard.GetDataObject(); try { Object o = t.GetData(DataFormats.StringFormat.ToString()); String s = (String)o; byte[] bytes = Encoding.UTF8.GetBytes(s); int[] clipUTF32 = new int[bytes.Length]; int lenUTF32 = UniConversion.UTF32FromUTF8(clipUTF32, bytes.Length, bytes, bytes.Length); textArea.InsertUTF32(textArea.sr.Caret(), clipUTF32, lenUTF32); } catch (Exception) { } textArea.Invalidate(); }
public virtual void SetFont(FontDescription font_) { if (font != font_) { if ((font == null) || (!font.Equals(font_))) { font = font_; System.String fontName = "Verdana"; try { int maxSize = font.font.Length() * 3; byte[] nameBytes = new byte[maxSize]; int lenUTF8 = UniConversion.UTF8FromUTF32( nameBytes, nameBytes.Length, font.font.Data(), font.font.Length()); //~ byte[] nameBytes = font.font.Value(); fontName = System.Text.Encoding.UTF8.GetString(nameBytes, 0, lenUTF8); } catch (System.IO.IOException) { System.Console.Out.WriteLine("Failed to convert"); } catch (System.NullReferenceException) { System.Console.Out.WriteLine("Null to convert"); } //~ System.out.println("SetFont " + fontName + " " + font.height); int fs = 0; if (font.bold) { fs |= (int)FontStyle.Bold; } if (font.italics) { fs |= (int)FontStyle.Italic; } fontHandle = new Font(fontName, font.height, (FontStyle)fs); ascent = TextAscent(); } } }