public HtmlStyle Add(HtmlStyle c, string Id) { mht.Add(Id, c); KeyIndex.Add(Id); return(c); }
private void OverwriteStyle(HtmlStyle SOld, HtmlStyle SNew) { HtmlStyle DefaultStyle = new HtmlStyle(); if (!SNew.BackgroundColorSetted) { SNew.BackgroundColor = SOld.BackgroundColor; } if (!SNew.ColorSetted) { SNew.Color = SOld.Color; } string NameNew = SNew.FontNameSetted ? SNew.Font.Name : SOld.Font.Name; float SizeNew = SNew.FontSizeSetted ? SNew.Font.Size : SOld.Font.Size; FontStyle FontStyleNew = SNew.FontStyleSetted ? SNew.Font.Style : SOld.Font.Style; SNew.Font = new Font(NameNew, SizeNew, FontStyleNew); if (!SNew.FormatAlignmentSetted) { SNew.Format.Alignment = SOld.Format.Alignment; } if (!SNew.FormatTrimmingSetted) { SNew.Format.Trimming = SOld.Format.Trimming; } //Border 관련 스타일은 상속되지 않으므로 현재 값을 사용함. }
private void DrawOneLine(Graphics g, HAlign hAlign, float startx, float y, float drawableWidth, float textWidth, List <string> stackText, List <HtmlStyle> stackStyle, List <float> stackWidth) { float x = 0; switch (hAlign) { case HAlign.Left: x = startx; break; case HAlign.Center: x = startx + (drawableWidth - textWidth) / 2; break; case HAlign.Right: x = startx + (drawableWidth - textWidth); break; } for (int i = 0, i2 = stackText.Count; i < i2; i++) { string s = stackText[i]; HtmlStyle sty = stackStyle[i]; float width = stackWidth[i]; g.DrawString(s, sty.Font, new SolidBrush(sty.Color), new PointF(x, y), sty.Format); x += width; } }
public void PrintOut(Graphics g) { int y = mMargins.Top; HtmlStyle styBody = mHtmlStyles["BODY"]; if (styBody != null) { styCur = styBody; } for (int i = 0, i2 = mElements.Count; i < i2; i++) { object e = mElements[i]; Table t = e as Table; if (t != null) { PrintTable(g, t, 0, ref y, mMargins.Left, mClientPageWidth); continue; } Br b = e as Br; if (b != null) { PrintBr(g, ref y); continue; } P p = e as P; if (p != null) { PrintP(g, ref y); continue; } throw new Exception(e.ToString() + " 개체는 허용되지 않습니다."); } }
private void SetColWidthOverwriteStyle(Table table) { CRows rows = table.Rows; int ColSpanRest = 0; bool ColSpanStarted = false; int ColSpanWidthAvg = 0; int ColWidth = 0; for (int rw = 0, rw2 = rows.Count; rw < rw2; rw++) { CRow row = table.Rows[rw]; //.TABLE 스타일 있다면 적용. HtmlStyle styT = mHtmlStyles["TABLE"]; if (styT != null) { OverwriteStyle(styT, table.Style); } OverwriteStyle(table.Style, row.Style); //.TR 스타일 있다면 적용. HtmlStyle styTR = mHtmlStyles["TR"]; if (styTR != null) { OverwriteStyle(styTR, row.Style); } Columns cols = row.Columns; for (int cl = 0, cl2 = cols.Count; cl < cl2; cl++) { Column col = cols[cl]; OverwriteStyle(row.Style, col.Style); //.TD 스타일 있다면 적용. HtmlStyle styTD = mHtmlStyles["TD"]; if (styTD != null) { OverwriteStyle(styTD, col.Style); } for (int v = 0, v2 = col.Values.Count; v < v2; v++) { OverwriteStyle(col.Style, col.Values[v].Style); //if (col.Values[v].Text == "333333-3333333") // System.Diagnostics.Debug.Assert(false); } if (rw == 0) { if (col.ColSpan > 1) { ColSpanStarted = true; ColSpanRest = col.ColSpan - 1; ColWidth = col.Width; ColSpanWidthAvg = Convert.ToInt32(ColWidth / col.ColSpan); col.WidthBeforeSpan = ColSpanWidthAvg; } else if (ColSpanStarted) { ColSpanRest--; if (ColSpanRest == 0) { ColSpanStarted = false; } col.WidthBeforeSpan = ColSpanWidthAvg; col.Width = 0; } else { if (col.Width == 0) { //첫번째 행이면 테이블 너비 / 열 개수 col.Width = Convert.ToInt32(table.Width / row.Columns.Count); } } } else { if (col.ColSpan > 1) { ColSpanStarted = true; ColSpanRest = col.ColSpan - 1; col.WidthBeforeSpan = GetPrevColWidth(rows, rw, cl); if (col.Width == 0) { col.Width = GetPrevColWidth(rows, rw, cl, col.ColSpan); } } else if (ColSpanStarted) { ColSpanRest--; if (ColSpanRest == 0) { ColSpanStarted = false; } col.WidthBeforeSpan = GetPrevColWidth(rows, rw, cl); col.Width = 0; } else { if (col.Width == 0) { //두번째 행부터는 이전 행의 너비를 따름. col.Width = GetPrevColWidth(rows, rw, cl); } } } } } }