diff --git a/PromotionsAndMenuPanel.cs b/PromotionsAndMenuPanel.cs index c2df301..395320f 100644 --- a/PromotionsAndMenuPanel.cs +++ b/PromotionsAndMenuPanel.cs @@ -1,10 +1,12 @@ + + namespace DualScreenDemo { public class PromotionsAndMenuPanel : Panel { - public ImagePanel prevPagePanel; + //public ImagePanel prevPagePanel; public ImagePanel currentPagePanel; - public ImagePanel nextPagePanel; + //public ImagePanel nextPagePanel; private List promotionsAndMenuImages; private const int ImagesPerPage = 1; @@ -32,25 +34,25 @@ namespace DualScreenDemo private void InitializePages() { - prevPagePanel = new ImagePanel(); + //prevPagePanel = new ImagePanel(); currentPagePanel = new ImagePanel(); - nextPagePanel = new ImagePanel(); + // nextPagePanel = new ImagePanel(); - PrimaryForm.ResizeAndPositionControl(prevPagePanel, -1440, 0, 1440, 900); + // PrimaryForm.ResizeAndPositionControl(prevPagePanel, -1440, 0, 1440, 900); PrimaryForm.ResizeAndPositionControl(currentPagePanel, 0, 0, 1440, 900); - PrimaryForm.ResizeAndPositionControl(nextPagePanel, 1440, 0, 1440, 900); + // PrimaryForm.ResizeAndPositionControl(nextPagePanel, 1440, 0, 1440, 900); - this.Controls.Add(prevPagePanel); + //this.Controls.Add(prevPagePanel); this.Controls.Add(currentPagePanel); - this.Controls.Add(nextPagePanel); + //this.Controls.Add(nextPagePanel); } public void LoadImages(List images) { promotionsAndMenuImages = images; - LoadPage(currentPageIndex - 1); + //LoadPage(currentPageIndex - 1); LoadPage(currentPageIndex); - LoadPage(currentPageIndex + 1); + //LoadPage(currentPageIndex + 1); } private void LoadPage(int pageIndex) @@ -75,11 +77,11 @@ namespace DualScreenDemo private ImagePanel IdentifyTargetPanel(int pageIndex) { - if (pageIndex == currentPageIndex - 1) - return prevPagePanel; - else if (pageIndex == currentPageIndex + 1) - return nextPagePanel; - else + //if (pageIndex == currentPageIndex - 1) + // return prevPagePanel; + // else if (pageIndex == currentPageIndex + 1) + // return nextPagePanel; + // else return currentPagePanel; } @@ -121,6 +123,7 @@ namespace DualScreenDemo if (deltaX < maxNegativeDeltaX) maxNegativeDeltaX = deltaX; ShiftPages(deltaX); + } } @@ -142,9 +145,7 @@ namespace DualScreenDemo if (newLeft > 1440) newLeft = 1440; if (newLeft < -1440) newLeft = -1440; - prevPagePanel.Location = new Point(newLeft - 1440, 0); - currentPagePanel.Location = new Point(newLeft, 0); - nextPagePanel.Location = new Point(newLeft + 1440, 0); + this.Invalidate(); this.Update(); @@ -161,9 +162,7 @@ namespace DualScreenDemo LoadNextPage(); } - prevPagePanel.Location = new Point(-1560, 0); - currentPagePanel.Location = new Point(0, 0); - nextPagePanel.Location = new Point(1440, 0); + maxPositiveDeltaX = 0; maxNegativeDeltaX = 0; @@ -172,19 +171,34 @@ namespace DualScreenDemo public void LoadPreviousPage() { if (currentPageIndex > 0) + { currentPageIndex--; - LoadPage(currentPageIndex - 1); - LoadPage(currentPageIndex); - LoadPage(currentPageIndex + 1); + //LoadPage(currentPageIndex - 1); + LoadPage(currentPageIndex); + //LoadPage(currentPageIndex + 1); + } + else + { + + currentPageIndex = promotionsAndMenuImages.Count-1; + LoadPage(currentPageIndex); + } } public void LoadNextPage() { if (currentPageIndex < (promotionsAndMenuImages.Count - 1) / ImagesPerPage) + { currentPageIndex++; - LoadPage(currentPageIndex - 1); - LoadPage(currentPageIndex); - LoadPage(currentPageIndex + 1); + //LoadPage(currentPageIndex - 1); + LoadPage(currentPageIndex); + //LoadPage(currentPageIndex + 1); + } + else { + + currentPageIndex = 0; + LoadPage(currentPageIndex); + } } } } \ No newline at end of file