電子文宣,菜單循環換頁
This commit is contained in:
parent
aae7d22a20
commit
f95e7776db
@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace DualScreenDemo
|
namespace DualScreenDemo
|
||||||
{
|
{
|
||||||
public class PromotionsAndMenuPanel : Panel
|
public class PromotionsAndMenuPanel : Panel
|
||||||
{
|
{
|
||||||
public ImagePanel prevPagePanel;
|
//public ImagePanel prevPagePanel;
|
||||||
public ImagePanel currentPagePanel;
|
public ImagePanel currentPagePanel;
|
||||||
public ImagePanel nextPagePanel;
|
//public ImagePanel nextPagePanel;
|
||||||
|
|
||||||
private List<Image> promotionsAndMenuImages;
|
private List<Image> promotionsAndMenuImages;
|
||||||
private const int ImagesPerPage = 1;
|
private const int ImagesPerPage = 1;
|
||||||
@ -32,25 +34,25 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
private void InitializePages()
|
private void InitializePages()
|
||||||
{
|
{
|
||||||
prevPagePanel = new ImagePanel();
|
//prevPagePanel = new ImagePanel();
|
||||||
currentPagePanel = 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(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(currentPagePanel);
|
||||||
this.Controls.Add(nextPagePanel);
|
//this.Controls.Add(nextPagePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadImages(List<Image> images)
|
public void LoadImages(List<Image> images)
|
||||||
{
|
{
|
||||||
promotionsAndMenuImages = images;
|
promotionsAndMenuImages = images;
|
||||||
LoadPage(currentPageIndex - 1);
|
//LoadPage(currentPageIndex - 1);
|
||||||
LoadPage(currentPageIndex);
|
LoadPage(currentPageIndex);
|
||||||
LoadPage(currentPageIndex + 1);
|
//LoadPage(currentPageIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPage(int pageIndex)
|
private void LoadPage(int pageIndex)
|
||||||
@ -75,11 +77,11 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
private ImagePanel IdentifyTargetPanel(int pageIndex)
|
private ImagePanel IdentifyTargetPanel(int pageIndex)
|
||||||
{
|
{
|
||||||
if (pageIndex == currentPageIndex - 1)
|
//if (pageIndex == currentPageIndex - 1)
|
||||||
return prevPagePanel;
|
// return prevPagePanel;
|
||||||
else if (pageIndex == currentPageIndex + 1)
|
// else if (pageIndex == currentPageIndex + 1)
|
||||||
return nextPagePanel;
|
// return nextPagePanel;
|
||||||
else
|
// else
|
||||||
return currentPagePanel;
|
return currentPagePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +123,7 @@ namespace DualScreenDemo
|
|||||||
if (deltaX < maxNegativeDeltaX) maxNegativeDeltaX = deltaX;
|
if (deltaX < maxNegativeDeltaX) maxNegativeDeltaX = deltaX;
|
||||||
|
|
||||||
ShiftPages(deltaX);
|
ShiftPages(deltaX);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,9 +145,7 @@ namespace DualScreenDemo
|
|||||||
if (newLeft > 1440) newLeft = 1440;
|
if (newLeft > 1440) newLeft = 1440;
|
||||||
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.Invalidate();
|
||||||
this.Update();
|
this.Update();
|
||||||
@ -161,9 +162,7 @@ namespace DualScreenDemo
|
|||||||
LoadNextPage();
|
LoadNextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
prevPagePanel.Location = new Point(-1560, 0);
|
|
||||||
currentPagePanel.Location = new Point(0, 0);
|
|
||||||
nextPagePanel.Location = new Point(1440, 0);
|
|
||||||
|
|
||||||
maxPositiveDeltaX = 0;
|
maxPositiveDeltaX = 0;
|
||||||
maxNegativeDeltaX = 0;
|
maxNegativeDeltaX = 0;
|
||||||
@ -172,19 +171,34 @@ namespace DualScreenDemo
|
|||||||
public void LoadPreviousPage()
|
public void LoadPreviousPage()
|
||||||
{
|
{
|
||||||
if (currentPageIndex > 0)
|
if (currentPageIndex > 0)
|
||||||
|
{
|
||||||
currentPageIndex--;
|
currentPageIndex--;
|
||||||
LoadPage(currentPageIndex - 1);
|
//LoadPage(currentPageIndex - 1);
|
||||||
LoadPage(currentPageIndex);
|
LoadPage(currentPageIndex);
|
||||||
LoadPage(currentPageIndex + 1);
|
//LoadPage(currentPageIndex + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
currentPageIndex = promotionsAndMenuImages.Count-1;
|
||||||
|
LoadPage(currentPageIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadNextPage()
|
public void LoadNextPage()
|
||||||
{
|
{
|
||||||
if (currentPageIndex < (promotionsAndMenuImages.Count - 1) / ImagesPerPage)
|
if (currentPageIndex < (promotionsAndMenuImages.Count - 1) / ImagesPerPage)
|
||||||
|
{
|
||||||
currentPageIndex++;
|
currentPageIndex++;
|
||||||
LoadPage(currentPageIndex - 1);
|
//LoadPage(currentPageIndex - 1);
|
||||||
|
LoadPage(currentPageIndex);
|
||||||
|
//LoadPage(currentPageIndex + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
currentPageIndex = 0;
|
||||||
LoadPage(currentPageIndex);
|
LoadPage(currentPageIndex);
|
||||||
LoadPage(currentPageIndex + 1);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user