本文整理匯總了C#中Qyoto.QByteArray.ToBase64方法的典型用法代碼示例。如果您正苦於以下問題:C# QByteArray.ToBase64方法的具體用法?C# QByteArray.ToBase64怎麽用?C# QByteArray.ToBase64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Qyoto.QByteArray
的用法示例。
在下文中一共展示了QByteArray.ToBase64方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ToHtml
public string ToHtml()
{
var builder = new StringBuilder();
var document = base.Document();
bool isFirstBlock = true;
var block = document.Begin();
while (block.IsValid()) {
if (!isFirstBlock)
builder.Append("<br/>");
isFirstBlock = false;
QTextBlock.iterator it;
//for (it = block.Begin(); !it.AtEnd(); it = it++) {
for (it = block.Begin(); !it.AtEnd(); it = it.Next()) {
var fragment = it.Fragment();
var format = fragment.CharFormat();
if (format.IsImageFormat()) {
var imageFormat = format.ToImageFormat();
var name = imageFormat.Name();
var data = document.Resource((int)QTextDocument.ResourceType.ImageResource, new QUrl(name));
if (data.type() == QVariant.TypeOf.Pixmap) {
var pixmap = (QPixmap)data;
var tempArray = new QByteArray();
var tempBuffer = new QBuffer(tempArray);
pixmap.Save(tempBuffer, "PNG");
string imageString = tempArray.ToBase64().ConstData();
builder.AppendFormat("<img alt=\"[embeded image]\" src=\"data:image/png;base64,{0}\" />", imageString);
}
} else {
var link = format.AnchorHref();
var bold = (format.FontWeight() == (int)QFont.Weight.Bold);
var underline = format.FontUnderline() && String.IsNullOrEmpty(link);
var italic = format.FontItalic();
var strike = format.FontStrikeOut();
if (!String.IsNullOrEmpty(link)) {
link = Util.EscapeHtml(link);
builder.AppendFormat("<a href=\"{0}\" title=\"{0}\">", link);
}
if (bold) builder.Append("<b>");
if (underline) builder.Append("<u>");
if (italic) builder.Append("<i>");
if (strike) builder.Append("<s>");
var text = fragment.Text();
text = Util.EscapeHtml(text);
text = text.Replace(" ", " ");
text = text.Replace("\t", "    ");
text = text.Replace("\r\n", "<br/>");
text = text.Replace("\r", "<br/>");
text = text.Replace("\n", "<br/>");
text = text.Replace("\u2028", "<br/>");
builder.Append(text);
if (strike) builder.Append("</s>");
if (italic) builder.Append("</i>");
if (underline) builder.Append("</u>");
if (bold) builder.Append("</b>");
if (!String.IsNullOrEmpty(link))
builder.Append("</a>");
}
}
block = block.Next();
}
return builder.ToString();
}