public void PageDefCreateIsSuccessful() { var pg = new PageDef(1, 20); Assert.AreEqual(1, pg.PageNum, "Page not 1"); Assert.AreEqual(20, pg.NumItemsPerPage, "# of Page items not 20"); Assert.AreEqual(0, pg.SkipCount, "skip count not 0"); }
public void PageDefCalcsNumPagesCorrectly() { var pg = new PageDef(1, 20); Assert.AreEqual(1, pg.CalcTotPages(20), "calc of 20 isn't 1"); Assert.AreEqual(2, pg.CalcTotPages(21), "calc of 21 isn't 2"); Assert.AreEqual(1, pg.CalcTotPages(1), "calc of 1 isn't 1"); Assert.AreEqual(1, pg.CalcTotPages(0), "calc of 0 isn't 1"); }
protected void Page_Load(object sender, EventArgs e) { PageBaseControl page = null; if (PageId > 0) { PortalPage pPage = db.PortalPages.SingleOrDefault <PortalPage>(p => p.Id == PageId); if (pPage != null) { PageDef def = db.PageDefs.SingleOrDefault <PageDef>(pd => pd.Id == pPage.PageDef); if (def != null) { page = (PageBaseControl)LoadControl(def.PageDefViewControl); } page.CurrentPage = pPage; } } else if (Request.QueryString["pn"] != null) { PortalPage pPage = db.PortalPages.SingleOrDefault <PortalPage>(p => p.PageKey == Request.QueryString["pn"]); if (pPage != null) { PageDef def = db.PageDefs.SingleOrDefault <PageDef>(pd => pd.Id == pPage.PageDef); if (def != null) { page = (PageBaseControl)LoadControl(def.PageDefViewControl); } page.CurrentPage = pPage; } } if (page == null) { PortalPage pPage = db.PortalPages.SingleOrDefault <PortalPage>(p => p.IsHomepage == true); if (pPage != null) { PageDef def = db.PageDefs.SingleOrDefault <PageDef>(pd => pd.Id == pPage.PageDef); if (def != null) { page = (PageBaseControl)LoadControl(def.PageDefViewControl); } page.CurrentPage = pPage; } } this.site_wrapper.Controls.Add(page); }
//private PageDef[] m_Blox; public BloxDef(TBSystem _sys, string _szOutputDir) { string sysDir = _szOutputDir; sysDir += _sys.SystemName.Substring(0, _sys.SystemName.Length - 4); m_szOutputDir = sysDir; m_System = _sys; Directory.CreateDirectory(sysDir); pages = new PageDef[3]; string bla = Environment.CurrentDirectory; pages[0] = new PageDef("Main", "Main", "main.html", new XHTMLGenerator(sysDir + "\\")); pages[1] = new PageDef("BloxList", "List of Blox", "bloxlist.html", new XHTMLGenerator(sysDir + "\\")); pages[2] = new PageDef("VarList", "List of all Variables", "varlist.html", new XHTMLGenerator(sysDir + "\\")); for (int i = 0; i < 3; i++) Pages.getInstance().addPage(pages[i]); m_pMain = pages[0]; m_pBloxList = pages[1]; m_pVarList = pages[2]; }
public void PageDefCreateWithZeroItemsPPRaisesException() { var pg = new PageDef(1, 0); }
public void PageDefCreateWithNegativeItemsPPRaisesException() { var pg = new PageDef(1, -1); }
public void PageDefCreateWithZeroPageNumRaisesException() { var pg = new PageDef(0); }
public void PageDefCreateWithNegativePageNumRaisesException() { var pg = new PageDef(-1); }
/// <summary> /// Print one row of the DataGridView. Most printing format info is retrieved /// from the DataGridView. /// </summary> /// <param name="g">Graphics Context to print within</param> /// <param name="pos">Track vertical space used; 'y' location</param> /// <param name="row">The row that will be printed</param> /// <param name="pageset">Current Pageset - defines columns and margins</param> private void printrow(Graphics g, ref float pos, DataGridViewRow row, PageDef pageset) { // track printing location accross the page float xcoord = pageset.margins.Left; // set the pen for drawing the grid lines Pen lines = new Pen(dgv.GridColor, 1); //----------------------------------------------------------------- // Print Row background //----------------------------------------------------------------- // get current row style, start with header style DataGridViewCellStyle rowstyle = row.InheritedStyle; // calc row width, account for columns larger than the print area! float rowwidth = (pageset.coltotalwidth > printWidth ? printWidth : pageset.coltotalwidth); // define print rectangle RectangleF printarea = new RectangleF(xcoord, pos, rowwidth, rowheights[lastrowprinted]); // fill in the row background g.FillRectangle(new SolidBrush(rowstyle.BackColor), printarea); //----------------------------------------------------------------- // Print the Row Headers, if they are visible //----------------------------------------------------------------- if (dgv.RowHeadersVisible) { // get current row style, start with header style DataGridViewCellStyle headerstyle = row.HeaderCell.InheritedStyle; // set print area for this individual cell RectangleF headercellprintarea = new RectangleF(xcoord, pos, rowheaderwidth, rowheights[lastrowprinted]); // fill in the row header background g.FillRectangle(new SolidBrush(headerstyle.BackColor), headercellprintarea); // set printing format for the row headers StringFormat rowheaderformat = managestringformat(headercellalignment, headercellformatflags, headerstyle, overridecellheaderformat); // draw the text for the row header cell g.DrawString(row.HeaderCell.EditedFormattedValue.ToString(), headerstyle.Font, new SolidBrush(headerstyle.ForeColor), headercellprintarea, rowheaderformat); // draw the borders - default to the dgv's border setting if (dgv.RowHeadersBorderStyle != DataGridViewHeaderBorderStyle.None) g.DrawRectangle(lines, xcoord, pos, rowheaderwidth, rowheights[lastrowprinted]); // track horizontal space used xcoord += rowheaderwidth; } //----------------------------------------------------------------- // Print the row: write and draw each cell //----------------------------------------------------------------- DataGridViewColumn col; for (int i = 0; i < pageset.colstoprint.Count; i++) { // access the column being printed col = (DataGridViewColumn)pageset.colstoprint[i]; // calc cell width, account for columns larger than the print area! float cellwidth = (pageset.colwidths[i] > printWidth - rowheaderwidth ? printWidth - rowheaderwidth : pageset.colwidths[i]); // get column style DataGridViewCellStyle colstyle = col.InheritedStyle; // set print area for this individual cell RectangleF cellprintarea = new RectangleF(xcoord, pos, cellwidth, rowheights[lastrowprinted]); // fill in the cell background - NOTE: we're using the row background because // the alternating row color settings does NOT change the cell background! // g.FillRectangle(new SolidBrush(colstyle.BackColor), cellprintarea); // set individual column format if it's provided StringFormat colformat = managestringformat(cellalignment, cellformatflags, colstyle, overridecellformat); // draw the text for the cell at the row / col intersection g.DrawString(row.Cells[col.Index].EditedFormattedValue.ToString(), colstyle.Font, new SolidBrush(colstyle.ForeColor), cellprintarea, colformat); // draw the borders - default to the dgv's border setting if (dgv.BorderStyle != BorderStyle.None) g.DrawRectangle(lines, xcoord, pos, cellwidth, rowheights[lastrowprinted]); // track horizontal space used xcoord += pageset.colwidths[i]; } //----------------------------------------------------------------- // All done with this row, consume "used" vertical space //----------------------------------------------------------------- pos += rowheights[lastrowprinted]; }
/// <summary> /// Print the column headers. Most printing format info is retrieved from the /// source DataGridView. /// </summary> /// <param name="g">Graphics Context to print within</param> /// <param name="pos">Track vertical space used; 'y' location</param> /// <param name="pageset">Current pageset - defines columns and margins</param> private void printcolumnheaders(Graphics g, ref float pos, PageDef pageset) { // track printing location accross the page. start position is hard left, // adjusted for the row headers. Note rowheaderwidth is 0 if row headers are not printed float xcoord = pageset.margins.Left + rowheaderwidth; // set the pen for drawing the grid lines Pen lines = new Pen(dgv.GridColor, 1); //----------------------------------------------------------------- // Print the column headers //----------------------------------------------------------------- DataGridViewColumn col; for (int i = 0; i < pageset.colstoprint.Count; i++) { col = (DataGridViewColumn)pageset.colstoprint[i]; // calc cell width, account for columns larger than the print area! float cellwidth = (pageset.colwidths[i] > printWidth - rowheaderwidth ? printWidth - rowheaderwidth : pageset.colwidths[i]); // get column style DataGridViewCellStyle style = col.HeaderCell.InheritedStyle; // set print area for this individual cell, account for cells larger // than the print area! RectangleF cellprintarea = new RectangleF(xcoord, pos, cellwidth, colheaderheight); // print column header background g.FillRectangle(new SolidBrush(style.BackColor), cellprintarea); // set individual column format if it's provided StringFormat colformat = managestringformat(headercellalignment, headercellformatflags, style, overridecellheaderformat); // draw the text g.DrawString(col.HeaderText, style.Font, new SolidBrush(style.ForeColor), cellprintarea, colformat); // draw the borders - default to the dgv's border setting; account for // columns larger than the print width if (dgv.ColumnHeadersBorderStyle != DataGridViewHeaderBorderStyle.None) g.DrawRectangle(lines, xcoord, pos, cellwidth, colheaderheight); xcoord += pageset.colwidths[i]; } // all done, consume "used" vertical space, including space for border lines pos += colheaderheight + (dgv.ColumnHeadersBorderStyle != DataGridViewHeaderBorderStyle.None ? lines.Width : 0); }
/// <summary> /// Adjust column widths for fixed and porportional columns, set the /// margins to enforce the selected tablealignment. /// </summary> /// <param name="g">The graphics context for all measurements</param> /// <param name="pageset">The pageset to adjust</param> private void AdjustPageSets(Graphics g, PageDef pageset) { int i; float fixedcolwidth = rowheaderwidth; float remainingcolwidth = 0; float ratio; //----------------------------------------------------------------- // Adjust the column widths in the page set to their final values, // accounting for overridden widths and porportional column stretching //----------------------------------------------------------------- // calculate the amount of space reserved for fixed width columns for (i = 0; i < pageset.colwidthsoverride.Count; i++) if (pageset.colwidthsoverride[i] >= 0) fixedcolwidth += pageset.colwidthsoverride[i]; // calculate the amount space for non-overridden columns for (i = 0; i < pageset.colwidths.Count; i++) if (pageset.colwidthsoverride[i] < 0) remainingcolwidth += pageset.colwidths[i]; // calculate the ratio for porportional colums, use 1 for no // non-overridden columns or not porportional if (porportionalcolumns && 0 < remainingcolwidth) ratio = ((float)printWidth - fixedcolwidth) / (float)remainingcolwidth; else ratio = (float)1.0; // reset all column widths for override and/or porportionality. coltotalwidth // for each pageset should be <= pageWidth pageset.coltotalwidth = rowheaderwidth; for (i = 0; i < pageset.colwidths.Count; i++) { if (pageset.colwidthsoverride[i] >= 0) pageset.colwidths[i] = pageset.colwidthsoverride[i]; else pageset.colwidths[i] = pageset.colwidths[i] * ratio; pageset.coltotalwidth += pageset.colwidths[i]; } //----------------------------------------------------------------- // Table Alignment - now that we have the column widths established // we can reset the table margins to get left, right and centered // for the table on the page //----------------------------------------------------------------- // Reset Print Margins based on table alignment if (Alignment.Left == tablealignment) { // Bias table to the left by setting "right" value pageset.margins.Right = pageWidth - pageset.margins.Left - (int)pageset.coltotalwidth; if (0 > pageset.margins.Right) pageset.margins.Right = 0; } else if (Alignment.Right == tablealignment) { // Bias table to the right by setting "left" value pageset.margins.Left = pageWidth - pageset.margins.Right - (int)pageset.coltotalwidth; if (0 > pageset.margins.Left) pageset.margins.Left = 0; } else if (Alignment.Center == tablealignment) { // Bias the table to the center by setting left and right equal pageset.margins.Left = (pageWidth - (int)pageset.coltotalwidth) / 2; if (0 > pageset.margins.Left) pageset.margins.Left = 0; pageset.margins.Right = pageset.margins.Left; } }
private void createHeader(PageDef _page) { //Create Link List PageLayoutList linkList = new PageLayoutList(null); PageLayoutListItem item; PageLayoutLink link; PageLayoutText span; for (int i = 0; i < 3; i++) { span = new PageLayoutText(null,PageLayoutType.Span,pages[i].Title); link = new PageLayoutLink(null, pages[i].FileName, span); if(_page == pages[i]) item = new PageLayoutListItem(new string[]{ID_Current}, link); else item = new PageLayoutListItem(null, link); linkList.addListElem(item); } PageLayoutDiv div = new PageLayoutDiv(new string[]{Class_Tabs}, new PageLayout[] {linkList}); _page.addPageLayout(div); }
private void createBlox(Blox _blox) { PageDef page = new PageDef(_blox.Name, _blox.Name, _blox.Name + ".html", new XHTMLGenerator(m_szOutputDir + "\\")); createHeader(page); page.addPageLayout(new PageLayoutText(null, PageLayoutType.Section, _blox.Name + " Description")); page.addPageLayout(new PageLayoutText(null, PageLayoutType.Paragraph, "Here is a brief overview of all variables used in this block")); PageLayoutTable table = new PageLayoutTable(null); PageLayoutTableData tableRow; PageLayoutText name; PageLayoutText varType; PageLayoutText useType; PageLayoutText scope; PageLayoutText defaultValue; PageLayoutText external; PageLayoutText autoIndex; PageLayoutText SeriesSize; PageLayoutText plotName; table.addTableData(createBloxTableHeader()); //TODO: plot Eigenschaften der Variablen in die Tabelle schreiben foreach (BlockVar var in _blox.Vars) { name = new PageLayoutText(null, PageLayoutType.Plain, var.Name); varType = new PageLayoutText(null, PageLayoutType.Plain, var.VarType); useType = new PageLayoutText(null, PageLayoutType.Plain, var.UseType.ToString()); scope = new PageLayoutText(null, PageLayoutType.Plain, var.Scope.ToString()); defaultValue = new PageLayoutText(null, PageLayoutType.Plain, var.DefaultValue); external = new PageLayoutText(null,PageLayoutType.Plain,var.External.ToString()); if (var.VarType == "Series") { autoIndex = new PageLayoutText(null, PageLayoutType.Plain, var.AutoIndex.ToString()); SeriesSize = new PageLayoutText(null, PageLayoutType.Plain, var.SeriesSize.ToString()); } else { autoIndex = new PageLayoutText(null, PageLayoutType.Plain, "-"); SeriesSize = new PageLayoutText(null, PageLayoutType.Plain, "-"); } if (var.Plots == true) { plotName = new PageLayoutText(null, PageLayoutType.Plain, var.Plotname); } else { plotName = new PageLayoutText(null, PageLayoutType.Plain, "-"); } tableRow = new PageLayoutTableData(null, new PageLayout[] { name, varType, useType, scope, defaultValue, external, autoIndex, SeriesSize,plotName}); table.addTableData(tableRow); } page.addPageLayout(table); //Auskommentieren um auch Indikatoren auszugeben //Neue Tabelle mit Indikatoren erstellen, falls vorhanden in dem Block //if (_blox.Indicators.Count > 0) { // page.addPageLayout(createIndicatorTable(_blox)); //} Pages.getInstance().addPage(page); }