private FastString GetSpanText(TextObjectBase obj, FastString text, float top, float width, float ParagraphOffset) { FastString style = new FastString(); style.Append("display:block;border:0;width:").Append(Px(width * Zoom)); if (ParagraphOffset != 0) { style.Append("text-indent:").Append(Px(ParagraphOffset * Zoom)); } if (obj.Padding.Left != 0) { style.Append("padding-left:").Append(Px((obj.Padding.Left) * Zoom)); } if (obj.Padding.Right != 0) { style.Append("padding-right:").Append(Px(obj.Padding.Right * Zoom)); } if (top != 0) { style.Append("margin-top:").Append(Px(top * Zoom)); } // we need to apply border width in order to position our div perfectly float borderLeft; float borderRight; float borderTop; float borderBottom; if (HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom)) { style.Append("position:absolute;") .Append("left:").Append(Px(-1 * borderLeft / 2f)) .Append("top:").Append(Px(-1 * borderTop / 2f)); } FastString result = new FastString(128); result.Append("<div "). Append(GetStyleTag(UpdateCSSTable(style.ToString()))).Append(">"). Append(text).Append("</div>"); return(result); }
private void HTMLFontStyle(FastString FFontDesc, Font font, float LineHeight) { FFontDesc.Append((((font.Style & FontStyle.Bold) > 0) ? "font-weight:bold;" : String.Empty) + (((font.Style & FontStyle.Italic) > 0) ? "font-style:italic;" : "font-style:normal;")); if ((font.Style & FontStyle.Underline) > 0 && (font.Style & FontStyle.Strikeout) > 0) { FFontDesc.Append("text-decoration:underline|line-through;"); } else if ((font.Style & FontStyle.Underline) > 0) { FFontDesc.Append("text-decoration:underline;"); } else if ((font.Style & FontStyle.Strikeout) > 0) { FFontDesc.Append("text-decoration:line-through;"); } FFontDesc.Append("font-family:").Append(font.Name).Append(";"); FFontDesc.Append("font-size:").Append(Px(Math.Round(font.Size * 96 / 72))); if (LineHeight > 0) { FFontDesc.Append("line-height:").Append(Px(LineHeight)).Append(";"); } }
internal static string UInt16Tohex(UInt16 word) { FastString sb = new FastString(4); return(sb.Append(ByteToHex((byte)((word >> 8) & 0xFF))).Append(ByteToHex((byte)(word & 0xFF))).ToString()); }
private void HTMLBorder(FastString BorderDesc, Border border) { if (!layers) { BorderDesc.Append("border-collapse: separate;"); } if (border.Lines > 0) { // bottom if ((border.Lines & BorderLines.Bottom) > 0) { BorderDesc.Append("border-bottom-width:"). Append(HTMLBorderWidthPx(border.BottomLine)). Append("border-bottom-color:"). Append(ExportUtils.HTMLColor(border.BottomLine.Color)).Append(";border-bottom-style:"). Append(HTMLBorderStyle(border.BottomLine)).Append(";"); } else { BorderDesc.Append("border-bottom:none;"); } // top if ((border.Lines & BorderLines.Top) > 0) { BorderDesc.Append("border-top-width:"). Append(HTMLBorderWidthPx(border.TopLine)). Append("border-top-color:"). Append(ExportUtils.HTMLColor(border.TopLine.Color)).Append(";border-top-style:"). Append(HTMLBorderStyle(border.TopLine)).Append(";"); } else { BorderDesc.Append("border-top:none;"); } // left if ((border.Lines & BorderLines.Left) > 0) { BorderDesc.Append("border-left-width:"). Append(HTMLBorderWidthPx(border.LeftLine)). Append("border-left-color:"). Append(ExportUtils.HTMLColor(border.LeftLine.Color)).Append(";border-left-style:"). Append(HTMLBorderStyle(border.LeftLine)).Append(";"); } else { BorderDesc.Append("border-left:none;"); } // right if ((border.Lines & BorderLines.Right) > 0) { BorderDesc.Append("border-right-width:"). Append(HTMLBorderWidthPx(border.RightLine)). Append("border-right-color:"). Append(ExportUtils.HTMLColor(border.RightLine.Color)).Append(";border-right-style:"). Append(HTMLBorderStyle(border.RightLine)).Append(";"); } else { BorderDesc.Append("border-right:none;"); } } else { BorderDesc.Append("border:none;"); } }
private string HTMLGetImage(int PageNumber, int CurrentPage, int ImageNumber, string hash, bool Base, System.Drawing.Image Metafile, MemoryStream PictureStream, bool isSvg) { if (pictures) { System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Bmp; if (imageFormat == ImageFormat.Png) { format = System.Drawing.Imaging.ImageFormat.Png; } else if (imageFormat == ImageFormat.Jpeg) { format = System.Drawing.Imaging.ImageFormat.Jpeg; } else if (imageFormat == ImageFormat.Gif) { format = System.Drawing.Imaging.ImageFormat.Gif; } string formatNm = isSvg ? "svg" : format.ToString().ToLower(); string embedImgType = isSvg ? "svg+xml" : format.ToString(); string embedPreffix = "data:image/" + embedImgType + ";base64,"; FastString ImageFileNameBuilder = new FastString(48); string ImageFileName; if (!saveStreams) { ImageFileNameBuilder.Append(Path.GetFileName(targetFileName)).Append("."); } ImageFileNameBuilder.Append(hash). Append(".").Append(formatNm); ImageFileName = ImageFileNameBuilder.ToString(); if (!webMode && !(preview || print)) { if (Base) { if (Metafile != null && !EmbedPictures) { if (saveStreams) { MemoryStream ImageFileStream = new MemoryStream(); Metafile.Save(ImageFileStream, format); GeneratedUpdate(targetPath + ImageFileName, ImageFileStream); } else { using (FileStream ImageFileStream = new FileStream(targetPath + ImageFileName, FileMode.Create)) Metafile.Save(ImageFileStream, format); } } else if (PictureStream != null && !EmbedPictures) { if (this.format == HTMLExportFormat.HTML) { string fileName = targetPath + ImageFileName; FileInfo info = new FileInfo(fileName); if (!(info.Exists && info.Length == PictureStream.Length)) { if (saveStreams) { GeneratedUpdate(targetPath + ImageFileName, PictureStream); } else { using (FileStream ImageFileStream = new FileStream(fileName, FileMode.Create)) PictureStream.WriteTo(ImageFileStream); } } } else { PicsArchiveItem item; item.FileName = ImageFileName; item.Stream = PictureStream; bool founded = false; for (int i = 0; i < picsArchive.Count; i++) { if (item.FileName == picsArchive[i].FileName) { founded = true; break; } } if (!founded) { picsArchive.Add(item); } } } if (!saveStreams) { GeneratedFiles.Add(targetPath + ImageFileName); } } if (EmbedPictures && PictureStream != null) { return(embedPreffix + GetBase64Image(PictureStream, hash)); } else if (subFolder && singlePage && !navigator) { return(ExportUtils.HtmlURL(subFolderPath + ImageFileName)); } else { return(ExportUtils.HtmlURL(ImageFileName)); } } else { if (EmbedPictures) { return(embedPreffix + GetBase64Image(PictureStream, hash)); } else { if (print || preview) { printPageData.Pictures.Add(PictureStream); printPageData.Guids.Add(hash); } else if (Base) { pages[CurrentPage].Pictures.Add(PictureStream); pages[CurrentPage].Guids.Add(hash); } return(webImagePrefix + "=" + hash + webImageSuffix); } } } else { return(String.Empty); } }
private string HTMLGetAncor(string ancorName) { FastString ancor = new FastString(); return(ancor.Append("<a name=\"PageN").Append(ancorName).Append("\" style=\"padding:0;margin:0;font-size:1px;\"></a>").ToString()); }
private void HTMLAlign(FastString sb, HorzAlign horzAlign, VertAlign vertAlign, bool wordWrap) { sb.Append("text-align:"); if (horzAlign == HorzAlign.Left) { sb.Append("Left"); } else if (horzAlign == HorzAlign.Right) { sb.Append("Right"); } else if (horzAlign == HorzAlign.Center) { sb.Append("Center"); } else if (horzAlign == HorzAlign.Justify) { sb.Append("Justify"); } sb.Append(";vertical-align:"); if (vertAlign == VertAlign.Top) { sb.Append("Top"); } else if (vertAlign == VertAlign.Bottom) { sb.Append("Bottom"); } else if (vertAlign == VertAlign.Center) { sb.Append("Middle"); } if (wordWrap) { sb.Append(";word-wrap:break-word"); } sb.Append(";overflow:hidden;"); }
string CreateSelectQuery(bool isCount, params string[] columns) { var cmd = new FastString(CMD_INIT_BUFFER_SIZE); cmd.Append("SELECT "); if (isDistict) { cmd.Append("DISTINCT "); } if (isCount) { cmd.Append("count("); } if (columns == null || columns.Length < 1) { cmd.Append("*"); } else { var first = true; foreach (var c in columns) { if (first) { first = false; } else { cmd.Append(", "); } cmd.Append(c); } } if (isCount) { cmd.Append(")"); } cmd.Append(" FROM ").Append(tableName); if (!whereStr.IsEmpty()) { cmd.Append(" WHERE ").Append(whereStr); } if (!string.IsNullOrEmpty(groupBy)) { cmd.Append(" GROUP BY ").Append(groupBy); } if (!orderBy.IsEmpty()) { cmd.Append(" ORDER BY ").Append(orderBy.ToString()); } if (limit > 0) { cmd.Append(" LIMIT "); if (limitOffset > 0) { cmd.Append(limitOffset).Append(","); } cmd.Append(limit); } cmd.Append(";"); return(cmd.ToString()); }
private string FastString() { m_strCustom.Clear(); m_strCustom.Append("PI=").Append(Mathf.PI).Append("_373=").Append(373).Replace("373", "5428"); return(m_strCustom.ToString()); }
private void Layer(FastString Page, ReportComponentBase obj, float Left, float Top, float Width, float Height, FastString Text, string style, FastString addstyletag) { if (Page != null && obj != null) { string onclick = null; if (!String.IsNullOrEmpty(ReportID)) { if (!String.IsNullOrEmpty(obj.ClickEvent) || obj.HasClickListeners()) { onclick = "click"; } CheckBoxObject checkBoxObject = obj as CheckBoxObject; if (checkBoxObject != null && checkBoxObject.Editable) { onclick = "checkbox_click"; } TextObject textObject = obj as TextObject; if (textObject != null && textObject.Editable) { onclick = "text_edit"; } } // we need to adjust left, top, width and height values because borders take up space in html elements float borderLeft = 0; float borderRight = 0; float borderTop = 0; float borderBottom = 0; HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom); Page.Append("<div ").Append(style).Append(" style=\""). Append(onclick != null ? "cursor:pointer;" : ""). Append("left:").Append(Px((leftMargin + Left) * Zoom - borderLeft / 2f)). Append("top:").Append(Px((topMargin + Top) * Zoom - borderTop / 2f)). Append("width:").Append(Px(Width * Zoom - borderRight / 2f - borderLeft / 2f)). Append("height:").Append(Px(Height * Zoom - borderBottom / 2f - borderTop / 2f)); if (addstyletag != null) { Page.Append(addstyletag); } Page.Append("\""); if (onclick != null) { string eventParam = String.Format("{0},{1},{2},{3}", obj.Name, CurPage, obj.AbsLeft.ToString("#0"), obj.AbsTop.ToString("#0")); Page.Append(" onclick=\"") .AppendFormat(OnClickTemplate, ReportID, onclick, eventParam) .Append("\""); } Page.Append(">"); if (Text == null) { Page.Append(NBSP); } else { Page.Append(Text); } Page.AppendLine("</div>"); } }
public static void TestMathInConsole() { float fTest1; float fTest2; double dTest1; double dTest2; int iTest1; int iTest2; ulong ulTest1; ulong ulTest2; string sTest1; byte[] byarrTest1 = new byte[] { 1, 2, 3, 4 }; Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RetroEngineTests.TestMathInConsole"); Console.WriteLine(); Console.WriteLine("FastString class:"); FastString fstrTest1 = new FastString("be", 10); Console.WriteLine("fstrTest1=new FastString(\"be\",10):" + fstrTest1.ToString()); Console.WriteLine("fstrTest1.Length:" + fstrTest1.Length.ToString()); fstrTest1.Insert(1, "cfd"); Console.WriteLine("fstrTest1.Insert(1,\"cfd\"):" + fstrTest1.ToString()); fstrTest1.Remove(2, 1); Console.WriteLine("fstrTest1.Remove(2,1):" + fstrTest1.ToString()); fstrTest1.Append('f'); Console.WriteLine("fstrTest1.Append('f'):" + fstrTest1.ToString()); fstrTest1.Append("gh"); Console.WriteLine("fstrTest1.Append(\"gh\"):" + fstrTest1.ToString()); Console.WriteLine("fstrTest1.Length:" + fstrTest1.Length.ToString()); fstrTest1.Insert(fstrTest1.Length, "ij"); Console.WriteLine("fstrTest1.Insert(fstrTest1.Length,\"ij\"):" + fstrTest1.ToString()); fstrTest1.Insert(0, "ab"); Console.WriteLine("fstrTest1.Insert(0,\"ab\"):" + fstrTest1.ToString()); fstrTest1.Remove(1, 1); Console.WriteLine("fstrTest1.Remove(1,1):" + fstrTest1.ToString()); fstrTest1.Insert(0, '-'); Console.WriteLine("fstrTest1.Insert(0,'-'):" + fstrTest1.ToString()); Console.WriteLine(); Console.WriteLine("Percentage struct:"); Console.WriteLine("Percentage.ToWholeDivisor:" + Percentage.ToWholeDivisor.ToString()); Console.WriteLine("Percentage.Entire:" + Percentage.Entire.ToString()); Percentage percTest1 = new Percentage(); percTest1.Set_1As100Percent(.5d); Console.WriteLine("percTest1.Set_1As100Percent(val=.50):" + percTest1.ToString()); percTest1.Set(50.0d); Console.WriteLine("percTest1.Set(val=50):" + percTest1.ToString()); Console.WriteLine("percTest1.Multiply(val=800):" + percTest1.Multiply(800).ToString()); Percentage percTest2 = new Percentage(); percTest2.From(ref percTest1); Console.WriteLine("percTest2.From(val=percTest1):" + percTest2.ToString()); Console.WriteLine("percTest2.ToString():" + percTest2.ToString()); Console.WriteLine("percTest2.Equals(val=percTest1):" + ToString(percTest2.Equals(percTest1))); percTest2.Set_1As100Percent(1.0234); Console.WriteLine("percTest2.Set_1As100Percent(1.0234)" + percTest2.ToString()); Console.WriteLine("percTest2.ToString():" + percTest2.ToString()); Console.WriteLine("percTest2.ToString(iDecimalPlaces=-1):" + percTest2.ToString(-1)); Console.WriteLine("percTest2.ToString(iDecimalPlaces=0):" + percTest2.ToString(0)); Console.WriteLine("percTest2.ToString(iDecimalPlaces=1):" + percTest2.ToString(1)); Console.WriteLine("percTest2.ToString(iDecimalPlaces=2):" + percTest2.ToString(2)); Console.WriteLine("percTest2.ToString(iDecimalPlaces=3):" + percTest2.ToString(3)); percTest1.Set("100.2"); Console.WriteLine("percTest1.Set(string val=\"100.2\"):" + percTest1.ToString(2)); percTest1.Set("10000"); Console.WriteLine("percTest1.Set(string val=\"10000\"):" + percTest1.ToString(2)); percTest1.Set(".1%"); Console.WriteLine("percTest1.Set(string val=\".1%\"):" + percTest1.ToString(2)); percTest1.Set("10.1%"); Console.WriteLine("percTest1.Set(string val=\"10.1%\"):" + percTest1.ToString(2)); percTest1.Set("101%"); Console.WriteLine("percTest1.Set(string val=\"101%\"):" + percTest1.ToString(2)); Console.WriteLine(); Console.WriteLine("Base class static methods:"); Console.WriteLine("SafeDivideRound(val=1,valDivisor=0,valMax=100):" + SafeDivideRound(1, 0, 100).ToString()); Console.WriteLine("SafeDivideRound(val=2,valDivisor=0,valMax=100):" + SafeDivideRound(2, 0, 100).ToString()); Console.WriteLine("SafeDivideRound(val=1,valDivisor=0,valMax=200):" + SafeDivideRound(1, 0, 200).ToString()); Console.WriteLine("SafeDivideRound(val=-2,valDivisor=0,valMax=100):" + SafeDivideRound(-2, 0, 100).ToString()); Console.WriteLine("SafeDivideRound(val=-1,valDivisor=0,valMax=200):" + SafeDivideRound(-1, 0, 200).ToString()); Console.WriteLine("SafeDivideRound(val=100,valDivisor=2,valMax=200):" + SafeDivideRound(100, 2, 200).ToString()); Console.WriteLine("SafeDivideRound(val=2,valDivisor=3,valMax=200):" + SafeDivideRound(2, 3, 200).ToString()); Console.WriteLine("SafeDivideRound(val=1,valDivisor=3,valMax=200):" + SafeDivideRound(1, 3, 200).ToString()); Console.WriteLine("SafeDivideRound(val=100,valDivisor=3,valMax=200):" + SafeDivideRound(100, 3, 200).ToString()); Console.WriteLine("SafeDivideRound(val=200,valDivisor=300,valMax=200):" + SafeDivideRound(200, 300, 200).ToString()); Console.WriteLine("SafeDivideRound(val=200,valDivisor=3,valMax=200):" + SafeDivideRound(200, 3, 200).ToString()); Console.WriteLine(); iTest1 = int.MinValue; Console.WriteLine("iTest1=int.MinValue:" + iTest1.ToString()); CropAbsoluteValueToPosMax(ref iTest1); Console.WriteLine("CropAbsoluteValueToPosMax(ref val=iTest1):" + iTest1.ToString()); dTest1 = double.MinValue; Console.WriteLine("dTest1=double.MinValue:" + dTest1.ToString()); CropAbsoluteValueToPosMax(ref dTest1); Console.WriteLine("CropAbsoluteValueToPosMax(ref val=dTest1):" + dTest1.ToString()); Console.WriteLine("SafeAdd(dTest,dTest):" + SafeAdd(dTest1, dTest1).ToString()); Console.WriteLine("SafeAdd(-1*(dTest),-1*dTest):" + SafeAdd(-1 * dTest1, -1 * dTest1).ToString()); Console.WriteLine("SafeAdd(1f,1f):" + SafeAdd(1F, 1F).ToString()); Console.WriteLine("SafeAdd(-1f,-1f):" + SafeAdd(-1F, -1F).ToString()); Console.WriteLine("SafeAdd(1f,-1f):" + SafeAdd(1F, -1F).ToString()); Console.WriteLine("SafeAdd(-1f,1f):" + SafeAdd(-1F, 1F).ToString()); Console.WriteLine("SafeAdd(1d,1d):" + SafeAdd(1D, 1D).ToString()); Console.WriteLine("SafeAdd(-1d,-1d):" + SafeAdd(-1D, -1D).ToString()); Console.WriteLine("SafeAdd(1d,-1d):" + SafeAdd(1D, -1D).ToString()); Console.WriteLine("SafeAdd(-1d,1d):" + SafeAdd(-1D, 1D).ToString()); Console.WriteLine("SafeAdd((int)1,(int)1):" + SafeAdd((int)1, (int)1).ToString()); Console.WriteLine("SafeAdd((int)-1,(int)-1):" + SafeAdd((int)-1, (int)-1).ToString()); Console.WriteLine("SafeAdd((int)1,(int)-1):" + SafeAdd((int)1, (int)-1).ToString()); Console.WriteLine("SafeAdd((int)-1,(int)1):" + SafeAdd((int)-1, (int)1).ToString()); Console.WriteLine(); Console.WriteLine("SafeSubtract((ulong)1,(ulong)2):" + SafeSubtract((ulong)1, (ulong)2).ToString()); Console.WriteLine("SafeSubtract((ulong)2,(ulong)1):" + SafeSubtract((ulong)2, (ulong)1).ToString()); ulTest1 = ulong.MaxValue - 1; ulTest2 = 2; Console.WriteLine("ulong.MaxValue:" + ulong.MaxValue.ToString()); Console.WriteLine("SafeAdd((ulong)" + ulTest1.ToString() + ",(ulong)" + ulTest2.ToString() + "):" + SafeAdd(ulTest1, ulTest2).ToString()); ulTest2 = 1; Console.WriteLine("SafeAdd((ulong)" + ulTest1.ToString() + ",(ulong)" + ulTest2.ToString() + "):" + SafeAdd(ulTest1, ulTest2).ToString()); Console.WriteLine(); Console.WriteLine("SafeSubtract(1,1):" + SafeSubtract(1, 1).ToString()); Console.WriteLine("SafeSubtract(-1,-1):" + SafeSubtract(-1, -1).ToString()); Console.WriteLine("SafeSubtract(1,-1):" + SafeSubtract(1, -1).ToString()); Console.WriteLine("SafeSubtract(-1,1):" + SafeSubtract(-1, 1).ToString()); Console.WriteLine(); Console.WriteLine("byte SafeAdd(253,2):" + SafeAdd((byte)253, (byte)2).ToString()); Console.WriteLine("byte SafeAdd(254,2):" + SafeAdd((byte)254, (byte)2).ToString()); Console.WriteLine("byte SafeSubtract(2,2):" + SafeSubtract((byte)2, (byte)2).ToString()); Console.WriteLine("byte SafeSubtract(1,2):" + SafeSubtract((byte)1, (byte)2).ToString()); Console.WriteLine(); Console.WriteLine("byte SafeAddWrapped(253,2):" + SafeAddWrapped((byte)253, (byte)2).ToString()); Console.WriteLine("byte SafeAddWrapped(254,2):" + SafeAddWrapped((byte)254, (byte)2).ToString()); Console.WriteLine("byte SafeSubtractWrapped(2,2):" + SafeSubtractWrapped((byte)2, (byte)2).ToString()); Console.WriteLine("byte SafeSubtractWrapped(1,2):" + SafeSubtractWrapped((byte)1, (byte)2).ToString()); Console.WriteLine(); Console.WriteLine("SafeSqrt(9):" + SafeSqrt(9).ToString()); Console.WriteLine("SafeSqrt(13):" + SafeSqrt(13).ToString()); Console.WriteLine("SafeSqrt(19):" + SafeSqrt(19).ToString()); Console.WriteLine("SafeSqrt(-9):" + SafeSqrt(-9).ToString()); Console.WriteLine("SafeSqrt(-13):" + SafeSqrt(-13).ToString()); Console.WriteLine("SafeSqrt(-19):" + SafeSqrt(-19).ToString()); Console.WriteLine(); Console.WriteLine("FractionPartOf(2.22222f):" + FractionPartOf(2.22222f).ToString()); Console.WriteLine("FractionPartOf(2.22222d):" + FractionPartOf(2.22222d).ToString()); Console.WriteLine("FractionPartOf(1.23f):" + FractionPartOf(1.23f).ToString()); Console.WriteLine("FractionPartOf(1.23d):" + FractionPartOf(1.23d).ToString()); fTest1 = 1.23f; dTest1 = 1.23d; Floor(ref fTest1); Floor(ref dTest1); Console.WriteLine("Floor(1.93f):" + fTest1.ToString()); Console.WriteLine("Floor(1.93d):" + dTest1.ToString()); //Console.WriteLine("IFloor(1.93f):"+IFloor(1.93f).ToString()); //Console.WriteLine("IFloor(1.93d):"+IFloor(1.93d).ToString()); fTest1 = 1.23f; dTest1 = 1.23d; iTest1 = ICeiling(fTest1); iTest2 = ICeiling(dTest1); Console.WriteLine("ICeiling(1.23f):" + iTest1.ToString()); Console.WriteLine("ICeiling(1.23d):" + iTest2.ToString()); Console.WriteLine(); Console.WriteLine("byarrTest1:" + ToString(byarrTest1)); Console.WriteLine("SubArray(byarrTest1,0,-1):" + ToString(SubArray(byarrTest1, 0, -1))); Console.WriteLine("SubArray(byarrTest1,0,0):" + ToString(SubArray(byarrTest1, 0, 0))); Console.WriteLine("SubArray(byarrTest1,0,1):" + ToString(SubArray(byarrTest1, 0, 1))); Console.WriteLine("SubArray(byarrTest1,0,2):" + ToString(SubArray(byarrTest1, 0, 2))); Console.WriteLine("SubArray(byarrTest1,1,2):" + ToString(SubArray(byarrTest1, 1, 2))); Console.WriteLine("SubArray(byarrTest1,2,2):" + ToString(SubArray(byarrTest1, 2, 2))); Console.WriteLine("SubArray(byarrTest1,3,2):" + ToString(SubArray(byarrTest1, 3, 2))); Console.WriteLine("SubArray(byarrTest1,0,3):" + ToString(SubArray(byarrTest1, 0, 3))); Console.WriteLine("SubArray(byarrTest1,1,3):" + ToString(SubArray(byarrTest1, 1, 3))); Console.WriteLine("SubArray(byarrTest1,-1,4):" + ToString(SubArray(byarrTest1, -1, 4))); Console.WriteLine(); Console.WriteLine("SubArrayReversed(byarrTest1,0,-1):" + ToString(SubArrayReversed(byarrTest1, 0, -1))); Console.WriteLine("SubArrayReversed(byarrTest1,0,0):" + ToString(SubArrayReversed(byarrTest1, 0, 0))); Console.WriteLine("SubArrayReversed(byarrTest1,0,1):" + ToString(SubArrayReversed(byarrTest1, 0, 1))); Console.WriteLine("SubArrayReversed(byarrTest1,0,2):" + ToString(SubArrayReversed(byarrTest1, 0, 2))); Console.WriteLine("SubArrayReversed(byarrTest1,1,2):" + ToString(SubArrayReversed(byarrTest1, 1, 2))); Console.WriteLine("SubArrayReversed(byarrTest1,2,2):" + ToString(SubArrayReversed(byarrTest1, 2, 2))); Console.WriteLine("SubArrayReversed(byarrTest1,3,2):" + ToString(SubArrayReversed(byarrTest1, 3, 2))); Console.WriteLine("SubArrayReversed(byarrTest1,0,3):" + ToString(SubArrayReversed(byarrTest1, 0, 3))); Console.WriteLine("SubArrayReversed(byarrTest1,1,3):" + ToString(SubArrayReversed(byarrTest1, 1, 3))); Console.WriteLine("SubArrayReversed(byarrTest1,0,4):" + ToString(SubArrayReversed(byarrTest1, 0, 4))); Console.WriteLine("SubArrayReversed(byarrTest1,-1,4):" + ToString(SubArrayReversed(byarrTest1, -1, 4))); Console.WriteLint("ToByte(257):" + RConvert.ToByte((int)257).ToString()); Console.WriteLint("ToByte(-2):" + RConvert.ToByte((int)-1).ToString()); Console.WriteLint("ToByte(257.0d):" + RConvert.ToByte(257.0d).ToString()); Console.WriteLint("ToByte(-2.0d):" + RConvert.ToByte(-2.0d).ToString()); Console.WriteLint("ToByte(2.4d):" + RConvert.ToByte(2.4d).ToString()); Console.WriteLint("ToByte(2.5d):" + RConvert.ToByte(2.5d).ToString()); Console.WriteLint("ToByte(2.4f):" + RConvert.ToByte(2.4f).ToString()); Console.WriteLint("ToByte(2.5f):" + RConvert.ToByte(2.5f).ToString()); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); //SubArrayReversed(ref byarrTest1 } //end TestMathInConsole
internal static FastString HtmlString(string text, TextRenderType textRenderType, CRLF crlf, bool excel2007) { FastString Result = new FastString(text.Length); int len = text.Length; for (int i = 0; i < len; i++) { if (crlf != CRLF.xml && crlf != CRLF.odt && text[i] == ' ' && (text.Length == 1 || (i < (len - 1) && text[i + 1] == ' ') || (i > 0 && text[i - 1] == ' ') || i == len - 1)) { Result.Append(" "); } else if (text[i] == '<' && textRenderType == TextRenderType.HtmlTags && crlf == CRLF.odt) { i += text.IndexOf('>', i) - i; } else if (i < text.Length - 1 && text[i] == '\r' && text[i + 1] == '\n') { if (crlf == CRLF.xml) { Result.Append(" "); } else if (crlf == CRLF.odt) { Result.Append("<text:line-break />"); } else { Result.Append("<p style=\"margin-top:0px;margin-bottom:0px;\">"); } i++; } else if (text[i] == '\t' && crlf == CRLF.odt) { Result.Append("<text:tab/>"); } else if (text[i] == ' ' && crlf == CRLF.odt) { int spaces = 1; while (i < text.Length - 1) { if (text[i + 1] == ' ') { i++; spaces++; } else { break; } } Result.Append("<text:s text:c=\"" + spaces + "\"/>"); } else if (text[i] == '\\') { Result.Append("\"); } else if (text[i] == '~' && !excel2007) { Result.Append("˜"); } else if (text[i] == '€' && !excel2007) { Result.Append("€"); } else if (text[i] == '‹' && !excel2007) { Result.Append("‹"); } else if (text[i] == '›' && !excel2007) { Result.Append("›"); } else if (text[i] == 'ˆ' && !excel2007) { Result.Append("ˆ"); } else if (text[i] == '&' && textRenderType == TextRenderType.Default) { Result.Append("&"); } else if (text[i] == '"' && textRenderType == TextRenderType.Default) { Result.Append("""); } else if (text[i] == '<' && textRenderType == TextRenderType.Default) { Result.Append("<"); } else if (text[i] == '>' && textRenderType == TextRenderType.Default) { Result.Append(">"); } else if (text[i] == '\t' && excel2007) { continue; } else { Result.Append(text[i]); } } return(Result); }
internal static FastString HtmlString(string text, TextRenderType textRenderType, CRLF crlf, bool excel2007, string fontSize = "13px;") { FastString Result = new FastString(text.Length); int len = text.Length; int lineBreakCount = 0; if (textRenderType == TextRenderType.HtmlTags) { string wingdings = "<font face=\"Wingdings\">"; string webdings = "<font face=\"Webdings\">"; int ind1 = 0, ind2 = 0; if (text.Contains(wingdings)) { ind1 = text.IndexOf(wingdings) + wingdings.Length; ind2 = text.IndexOf('<', ind1); text = text.Substring(0, ind1) + WingdingsToUnicodeConverter.Convert(text.Substring(ind1, ind2 - ind1)) + text.Substring(ind2, text.Length - ind2); } else if (text.Contains(webdings)) { ind1 = text.IndexOf(webdings) + webdings.Length; ind2 = text.IndexOf('<', ind1); text = text.Substring(0, ind1) + WingdingsToUnicodeConverter.Convert(text.Substring(ind1, ind2 - ind1)) + text.Substring(ind2, text.Length - ind2); } } for (int i = 0; i < len; i++) { if (crlf != CRLF.xml && crlf != CRLF.odt && text[i] == ' ' && (text.Length == 1 || (i < (len - 1) && text[i + 1] == ' ') || (i > 0 && text[i - 1] == ' ') || i == len - 1)) { Result.Append(" "); } else if (text[i] == '<' && textRenderType == TextRenderType.HtmlTags && crlf == CRLF.odt) { i += text.IndexOf('>', i) - i; } else if (i < text.Length - 1 && text[i] == '\r' && text[i + 1] == '\n') { if (crlf == CRLF.xml) { Result.Append(" "); } else if (crlf == CRLF.odt) { Result.Append("<text:line-break />"); } else { if (lineBreakCount == 0) { Result.Append("<p style=\"margin-top:0px;margin-bottom:0px;\"></p>"); } else { Result.Append($"<p style=\"margin-top:0px;height:{fontSize}margin-bottom:0px\"></p>"); } lineBreakCount++; } i++; } else { lineBreakCount = 0; if (text[i] == '\t' && crlf == CRLF.odt) { Result.Append("<text:tab/>"); } else if (text[i] == ' ' && crlf == CRLF.odt) { int spaces = 1; while (i < text.Length - 1) { if (text[i + 1] == ' ') { i++; spaces++; } else { break; } } Result.Append("<text:s text:c=\"" + spaces + "\"/>"); } else if (text[i] == '\\') { Result.Append("\"); } else if (text[i] == '~' && !excel2007) { Result.Append("˜"); } else if (text[i] == '€' && !excel2007) { Result.Append("€"); } else if (text[i] == '‹' && !excel2007) { Result.Append("‹"); } else if (text[i] == '›' && !excel2007) { Result.Append("›"); } else if (text[i] == 'ˆ' && !excel2007) { Result.Append("ˆ"); } else if (text[i] == '&' && textRenderType == TextRenderType.Default) { Result.Append("&"); } else if (text[i] == '"' && textRenderType == TextRenderType.Default) { Result.Append("""); } else if (text[i] == '<' && textRenderType == TextRenderType.Default) { Result.Append("<"); } else if (text[i] == '>' && textRenderType == TextRenderType.Default) { Result.Append(">"); } else if (text[i] == '\t' && excel2007) { continue; } else { Result.Append(text[i]); } } } return(Result); }
public static JSONNode Parse(string aJSON) { Stack <JSONNode> stack = new Stack <JSONNode>(); JSONNode ctx = null; int i = 0, len = aJSON.Length; //string Token = ""; string TokenName = ""; bool QuoteMode = false; FastString Token = new FastString(128); while (i < len) { switch (aJSON[i]) { case '{': if (QuoteMode) { Token.Append(aJSON [i]); break; } stack.Push(new JSONClass()); if (ctx != null) { TokenName = TokenName.Trim(); if (ctx is JSONArray) { ctx.Add(stack.Peek()); } else if (TokenName != "") { ctx.Add(TokenName, stack.Peek()); } } TokenName = ""; Token.Clear(); ctx = stack.Peek(); break; case '[': if (QuoteMode) { Token.Append(aJSON[i]); break; } stack.Push(new JSONArray()); if (ctx != null) { TokenName = TokenName.Trim(); if (ctx is JSONArray) { ctx.Add(stack.Peek()); } else if (TokenName != "") { ctx.Add(TokenName, stack.Peek()); } } TokenName = ""; Token.Clear(); ctx = stack.Peek(); break; case '}': case ']': if (QuoteMode) { Token.Append(aJSON[i]); break; } if (stack.Count == 0) { throw new Exception("JSON Parse: Too many closing brackets"); } stack.Pop(); if (!Token.IsEmpty()) { TokenName = TokenName.Trim(); if (ctx is JSONArray) { ctx.Add(Token.ToString()); } else if (TokenName != "") { ctx.Add(TokenName, Token.ToString()); } } TokenName = ""; Token.Clear(); if (stack.Count > 0) { ctx = stack.Peek(); } break; case ':': if (QuoteMode) { Token.Append(aJSON[i]); break; } TokenName = Token.ToString(); Token.Clear(); break; case '"': QuoteMode ^= true; break; case ',': if (QuoteMode) { Token.Append(aJSON[i]); break; } if (!Token.IsEmpty()) { if (ctx is JSONArray) { ctx.Add(Token.ToString()); } else if (TokenName != "") { ctx.Add(TokenName, Token.ToString()); } } TokenName = ""; Token.Clear(); break; case '\r': case '\n': break; case ' ': case '\t': if (QuoteMode) { Token.Append(aJSON[i]); } break; case '\\': ++i; if (QuoteMode) { char C = aJSON[i]; switch (C) { case 't': Token.Append('\t'); break; case 'r': Token.Append('\r'); break; case 'n': Token.Append('\n'); break; case 'b': Token.Append('\b'); break; case 'f': Token.Append('\f'); break; case 'u': { string s = aJSON.Substring(i + 1, 4); Token.Append((char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier)); i += 4; break; } default: Token.Append(C); break; } } break; default: Token.Append(aJSON[i]); break; } ++i; } if (QuoteMode) { throw new Exception("JSON Parse: Quotation marks seems to be messed up."); } return(ctx); }
internal static FastString HtmlString(string text, TextRenderType textRenderType, CRLF crlf, bool excel2007) { FastString Result = new FastString(text.Length); int len = text.Length; for (int i = 0; i < len; i++) { if (crlf != CRLF.xml && crlf != CRLF.odt && text[i] == ' ' && (text.Length == 1 || (i < (len - 1) && text[i + 1] == ' ') || (i > 0 && text[i - 1] == ' ') || i == len - 1)) { Result.Append(" "); } else if (i < text.Length - 1 && text[i] == '\r' && text[i + 1] == '\n') { if (crlf == CRLF.xml) { Result.Append(" "); } else if (crlf == CRLF.odt) { Result.Append("<text:line-break />"); } else { Result.Append("<br />"); } i++; } else if (text[i] == '\\') { Result.Append("\"); } else if (text[i] == '~' && !excel2007) { Result.Append("˜"); } else if (text[i] == '€' && !excel2007) { Result.Append("€"); } else if (text[i] == '‹' && !excel2007) { Result.Append("‹"); } else if (text[i] == '›' && !excel2007) { Result.Append("›"); } else if (text[i] == 'ˆ' && !excel2007) { Result.Append("ˆ"); } else if (text[i] == '&' && textRenderType == TextRenderType.Default) { Result.Append("&"); } else if (text[i] == '"' && textRenderType == TextRenderType.Default) { Result.Append("""); } else if (text[i] == '<' && textRenderType == TextRenderType.Default) { Result.Append("<"); } else if (text[i] == '>' && textRenderType == TextRenderType.Default) { Result.Append(">"); } else if (text[i] == '\t' && excel2007) { continue; } else { Result.Append(text[i]); } } return(Result); }
private FastString GetSpanText(TextObjectBase obj, FastString text, float top, float width, float ParagraphOffset) { FastString style = new FastString(); style.Append("display:block;border:0;width:").Append(Px(width * Zoom)); if (ParagraphOffset != 0) { style.Append("text-indent:").Append(Px(ParagraphOffset * Zoom)); } if (obj.Padding.Left != 0) { style.Append("padding-left:").Append(Px((obj.Padding.Left) * Zoom)); } if (obj.Padding.Right != 0) { style.Append("padding-right:").Append(Px(obj.Padding.Right * Zoom)); } if (top != 0) { style.Append("margin-top:").Append(Px(top * Zoom)); } // we need to apply border width in order to position our div perfectly float borderLeft = 0; float borderRight = 0; float borderTop = 0; float borderBottom = 0; if (HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom)) { style.Append("position:absolute;") .Append("left:").Append(Px(-1 * borderLeft / 2f)) .Append("top:").Append(Px(-1 * borderTop / 2f)); } string href = String.Empty; if (!String.IsNullOrEmpty(obj.Hyperlink.Value)) { string hrefStyle = String.Empty; if (obj is TextObject) { TextObject textObject = obj as TextObject; hrefStyle = String.Format("style=\"color:{0}{1}\"", ExportUtils.HTMLColor(textObject.TextColor), !textObject.Font.Underline ? ";text-decoration:none" : String.Empty ); } string url = EncodeURL(obj.Hyperlink.Value); if (obj.Hyperlink.Kind == HyperlinkKind.URL) { href = String.Format("<a {0} href=\"{1}\"" + (obj.Hyperlink.OpenLinkInNewTab ? "target=\"_blank\"" : "") + ">", hrefStyle, obj.Hyperlink.Value); } else if (obj.Hyperlink.Kind == HyperlinkKind.DetailReport) { url = String.Format("{0},{1},{2}", EncodeURL(obj.Name), // object name for security reasons EncodeURL(obj.Hyperlink.ReportParameter), EncodeURL(obj.Hyperlink.Value)); string onClick = String.Format(OnClickTemplate, ReportID, "detailed_report", url); href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } else if (obj.Hyperlink.Kind == HyperlinkKind.DetailPage) { url = String.Format("{0},{1},{2}", EncodeURL(obj.Name), EncodeURL(obj.Hyperlink.ReportParameter), EncodeURL(obj.Hyperlink.Value)); string onClick = String.Format(OnClickTemplate, ReportID, "detailed_page", url); href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } else if (SinglePage) { if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark) { href = String.Format("<a {0} href=\"#{1}\">", hrefStyle, url); } else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber) { href = String.Format("<a {0} href=\"#PageN{1}\">", hrefStyle, url); } } else { string onClick = String.Empty; if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark) { onClick = String.Format(OnClickTemplate, ReportID, "bookmark", url); } else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber) { onClick = String.Format(OnClickTemplate, ReportID, "goto", url); } if (onClick != String.Empty) { href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } } } FastString result = new FastString(128); result.Append("<div "). Append(GetStyleTag(UpdateCSSTable(style.ToString()))).Append(">"). Append(href).Append(text).Append(href != String.Empty ? "</a>" : String.Empty). Append("</div>"); return(result); }
public static FastString AppendLine(this FastString fastString) { return(fastString.Append(Environment.NewLine)); }
private void ExportHTMLPageLayeredBegin(HTMLData d) { if (!singlePage && !WebMode) { cssStyles.Clear(); } css = new FastString(); htmlPage = new FastString(); ReportPage reportPage = d.page; if (reportPage != null) { maxWidth = ExportUtils.GetPageWidth(reportPage) * Units.Millimeters; maxHeight = ExportUtils.GetPageHeight(reportPage) * Units.Millimeters; if (enableMargins) { leftMargin = reportPage.LeftMargin * Units.Millimeters; topMargin = reportPage.TopMargin * Units.Millimeters; } else { maxWidth -= (reportPage.LeftMargin + reportPage.RightMargin) * Units.Millimeters; maxHeight -= (reportPage.TopMargin + reportPage.BottomMargin) * Units.Millimeters; leftMargin = 0; topMargin = 0; } currentPage = d.PageNumber - 1; ExportHTMLPageStart(htmlPage, d.PageNumber, d.CurrentPage); doPageBreak = (singlePage && pageBreaks); htmlPage.Append(HTMLGetAncor((d.PageNumber).ToString())); htmlPage.Append("<div ").Append(doPageBreak ? "class=\"frpage\"" : String.Empty). Append(" style=\"position:relative;width:").Append(Px(maxWidth * Zoom + 3)). Append("height:").Append(Px(maxHeight * Zoom)); if (reportPage.Fill is SolidFill) { SolidFill fill = reportPage.Fill as SolidFill; htmlPage.Append("; background-color:"). Append(fill.Color.A == 0 ? "transparent" : ExportUtils.HTMLColor(fill.Color)); } htmlPage.Append("\">"); if (!(reportPage.Fill is SolidFill)) { // to-do for picture background } if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowImageOnTop) { Watermark(htmlPage, reportPage, false); } if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowTextOnTop) { Watermark(htmlPage, reportPage, true); } } }
/// <summary> /// Highlight code in given string /// </summary> /// <param name="inStr">Input string</param> /// <param name="outStr">Output string</param> /// <param name="highlightSymbols">Highlight symbols</param> /// <returns>Highlighted code</returns> public static FastString HighlightCode(FastString inStr, FastString outStr, bool highlightSymbols = true) { var game = (DemoReel)RB.Game; var buf = inStr.Buf; outStr.Clear(); int lastColor = -1; for (int i = 0; i < inStr.Length; i++) { if (buf[i] == '@') { i++; switch (buf[i]) { case 'I': // Indexed color int colorIndex = ((int)(buf[i + 1] - '0') * 10) + (int)(buf[i + 2] - '0'); Color32 rgb = IndexToRGB(colorIndex); IndexToColorString(21, outStr).Append("new"); IndexToColorString(22, outStr).Append(" Color32"); IndexToColorString(3, outStr).Append("("); IndexToColorString(24, outStr).Append(rgb.r); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(rgb.g); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(rgb.b); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(255); IndexToColorString(3, outStr).Append(")"); i += 2; break; case 'K': // Keyword IndexToColorString(21, outStr); lastColor = 21; break; case 'M': // Class or Method IndexToColorString(22, outStr); lastColor = 22; break; case 'L': // Literal IndexToColorString(24, outStr); lastColor = 24; break; case 'C': // Comment IndexToColorString(25, outStr); lastColor = 25; break; case 'S': // String literal IndexToColorString(15, outStr); lastColor = 15; break; case 's': // String escape code IndexToColorString(14, outStr); lastColor = 14; break; case 'E': IndexToColorString(23, outStr); lastColor = 23; break; case 'N': // Normal/Other IndexToColorString(5, outStr); lastColor = 5; break; case 'D': // Dark IndexToColorString(3, outStr); lastColor = 3; break; case '@': outStr.Append("@@"); break; default: IndexToColorString(5, outStr); lastColor = 5; break; } } else { var c = buf[i]; var symbolFound = false; // Don't check for symbol color if in comment, or in string literal if (highlightSymbols && lastColor != 25 && lastColor != 15) { for (int j = 0; j < mSymbols.Length; j++) { if (c == mSymbols[j]) { symbolFound = true; break; } } } if (symbolFound) { IndexToColorString(3, outStr); outStr.Append(c); IndexToColorString(5, outStr); } else { outStr.Append(buf[i]); } } } return(outStr); }
/// <summary> /// Highlight code in given string /// </summary> /// <param name="inStr">Input string</param> /// <param name="outStr">Output string</param> /// <returns>Highlighted code</returns> public static FastString HighlightCode(FastString inStr, FastString outStr) { DemoReel game = (DemoReel)RB.Game; var buf = inStr.Buf; outStr.Clear(); for (int i = 0; i < inStr.Length; i++) { if (buf[i] == '@') { i++; switch (buf[i]) { case 'I': // Indexed color int colorIndex = ((int)(buf[i + 1] - '0') * 10) + (int)(buf[i + 2] - '0'); Color32 rgb = IndexToRGB(colorIndex); IndexToColorString(21, outStr).Append("new"); IndexToColorString(22, outStr).Append(" Color32"); IndexToColorString(5, outStr).Append("("); IndexToColorString(24, outStr).Append(rgb.r); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(rgb.g); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(rgb.b); IndexToColorString(5, outStr).Append(", "); IndexToColorString(24, outStr).Append(255); IndexToColorString(5, outStr).Append(")"); i += 2; break; case 'K': // Keyword IndexToColorString(21, outStr); break; case 'M': // Class or Method IndexToColorString(22, outStr); break; case 'L': // Literal IndexToColorString(24, outStr); break; case 'C': // Comment IndexToColorString(25, outStr); break; case 'S': // String literal IndexToColorString(15, outStr); break; case 's': // String escape code IndexToColorString(14, outStr); break; case 'E': IndexToColorString(23, outStr); break; case 'N': // Normal/Other IndexToColorString(5, outStr); break; case 'D': // Dark IndexToColorString(3, outStr); break; case '@': outStr.Append("@@"); break; default: IndexToColorString(5, outStr); break; } } else { outStr.Append(buf[i]); } } return(outStr); }