public void ResizeAllPages(int newWidth, int newHeight) { physicalCanvasCollection.Dispose(); physicalCanvasCollection.ResizeAllPages(newWidth, newHeight); render_parts = 0; if (pageA != null) { pageA.IsUnused = true; pageA = null; } if (pageB != null) { pageB.IsUnused = true; pageB = null; } if (pageC != null) { pageC.IsUnused = true; pageC = null; } if (pageD != null) { pageD.IsUnused = true; pageD = null; } }
public GdiPlusDrawBoard GetCanvasPage(int hPageNum, int vPageNum) { int j = cachePages.Count; for (int i = j - 1; i > -1; i--) { GdiPlusDrawBoard page = cachePages[i]; if (page.IsPageNumber(hPageNum, vPageNum)) { cachePages.RemoveAt(i); if (page.DimensionInvalid) { page.Reset(hPageNum, vPageNum, eachPageWidth, eachPageHeight); page.IsUnused = false; } return(page); } } if (j >= numOfCachePages) { GdiPlusDrawBoard page = cachePages[0]; cachePages.RemoveAt(0); page.IsUnused = false; if (page.DimensionInvalid) { page.Reset(hPageNum, vPageNum, eachPageWidth, eachPageHeight); } else { page.Reuse(hPageNum, vPageNum); } Rectangle rect = page.Rect; page.Invalidate(rect); return(page); } else { return(new GdiPlusDrawBoard(0, 0, eachPageWidth, eachPageHeight)); //return (MyGdiPlusCanvas)LayoutFarm.UI.GdiPlus.MyWinGdiPortal.P.CreateCanvas( // 0, 0, eachPageWidth, eachPageHeight); //PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform //return new MyGdiPlusCanvas( // hPageNum, // vPageNum, // hPageNum * eachPageWidth, // eachPageHeight * vPageNum, // eachPageWidth, // eachPageHeight); } }
static void UpdateInvalidArea(GdiPlusDrawBoard mycanvas, IRenderElement rootElement) { mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top); Rectangle rect = mycanvas.InvalidateArea; rootElement.DrawToThisCanvas(mycanvas, rect); #if DEBUG rootElement.dbugShowRenderPart(mycanvas, rect); #endif mycanvas.IsContentReady = true; mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top); }
static void UpdateAllArea(GdiPlusDrawBoard mycanvas, IRenderElement topWindowRenderBox) { mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top); Rectangle rect = mycanvas.Rect; topWindowRenderBox.DrawToThisCanvas(mycanvas, rect); #if DEBUG topWindowRenderBox.dbugShowRenderPart(mycanvas, rect); #endif mycanvas.IsContentReady = true; mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top); }
public void ReleasePage(GdiPlusDrawBoard page) { page.IsUnused = true; cachePages.Add(page); }
public void CalculateCanvasPages(int viewportX, int viewportY, int viewportWidth, int viewportHeight) { int firstVerticalPageNum = viewportY / physicalCanvasCollection.EachPageHeight; int firstHorizontalPageNum = viewportX / physicalCanvasCollection.EachPageWidth; render_parts = PAGE_A; if (pageA == null) { pageA = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum, firstVerticalPageNum); } else { if (!pageA.IsPageNumber(firstHorizontalPageNum, firstVerticalPageNum)) { physicalCanvasCollection.ReleasePage(pageA); pageA = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum, firstVerticalPageNum); } } if (pageA.Right >= viewportX + viewportWidth) { if (pageC != null) { physicalCanvasCollection.ReleasePage(pageC); pageC = null; } } else { if (pageC == null) { pageC = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum + 1, firstVerticalPageNum); } else { if (!pageC.IsPageNumber(firstHorizontalPageNum + 1, firstVerticalPageNum)) { physicalCanvasCollection.ReleasePage(pageC); pageC = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum + 1, firstVerticalPageNum); } } render_parts |= PAGE_AC; } if (pageA.Bottom >= viewportY + viewportHeight) { if (pageB != null) { physicalCanvasCollection.ReleasePage(pageB); pageB = null; } } else { render_parts |= PAGE_AB; if (pageB == null) { pageB = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum, firstVerticalPageNum + 1); } else { if (!pageB.IsPageNumber(firstHorizontalPageNum, firstVerticalPageNum + 1)) { physicalCanvasCollection.ReleasePage(pageB); pageB = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum, firstVerticalPageNum + 1); } } if (pageC != null) { render_parts = PAGE_ABCD; if (pageD == null) { pageD = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum + 1, firstVerticalPageNum + 1); } else { if (!pageD.IsPageNumber(firstHorizontalPageNum + 1, firstVerticalPageNum + 1)) { physicalCanvasCollection.ReleasePage(pageD); pageD = physicalCanvasCollection.GetCanvasPage(firstHorizontalPageNum + 1, firstVerticalPageNum + 1); } } } else { if (pageD != null) { physicalCanvasCollection.ReleasePage(pageD); pageD = null; } } } }