silcerlight翻页

 
LeftPage.cs文件代码:
  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Media.Imaging;
  11. using System.Windows.Shapes;

  12. namespace SilverlightClient.TypePage
  13. {
  14.   public class LeftPage : Canvas
  15.   {
  16.     //定义将在页面上显示的元素
  17.     private Image imgPhoto;
  18.     private Button btnPrevious;
  19.     private Rectangle RecBorder;
  20.     private TextBlock PageNum;
  21.    
  22.     //构造函数
  23.     public LeftPage()
  24.     {
  25.       //页面的设置
  26.       this.Width = 452;
  27.       this.Height = 630;
  28.       this.Background = new SolidColorBrush(Colors.White);
  29.       Canvas.SetLeft(this, 0);
  30.       Canvas.SetTop(this, 0);
  31.       //页面边框的设置
  32.       RecBorder = new Rectangle();
  33.       RecBorder.Width = 452;
  34.       RecBorder.Height = 630;
  35.       Canvas.SetLeft(RecBorder, 0);//设置页面边框在Canvas中的位置,下同。
  36.       Canvas.SetTop(RecBorder, 0);
  37.       RecBorder.Stroke = new SolidColorBrush(Colors.Black);
  38.       RecBorder.StrokeThickness = 0;
  39.       this.Children.Add(RecBorder);
  40.       //照片的设置
  41.       imgPhoto = new Image();
  42.       imgPhoto.Width = 450;
  43.       imgPhoto.Height = 600;
  44.       Canvas.SetLeft(imgPhoto, 1);
  45.       Canvas.SetTop(imgPhoto, 1);
  46.       this.Children.Add(imgPhoto);
  47.       //“前一页”按钮的设置
  48.       btnPrevious = new Button();
  49.       btnPrevious.Width = 150;
  50.       btnPrevious.Height = 20;
  51.       btnPrevious.Content = "<< 前一页";
  52.       btnPrevious.HorizontalContentAlignment = HorizontalAlignment.Center;
  53.       btnPrevious.VerticalContentAlignment = VerticalAlignment.Center;
  54.       btnPrevious.Cursor = Cursors.Hand;
  55.       Canvas.SetLeft(btnPrevious, 151);
  56.       Canvas.SetTop(btnPrevious, 605);
  57.       this.Children.Add(btnPrevious);
  58.       //页码文本的设置
  59.       PageNum = new TextBlock();
  60.       PageNum.Width = 100;
  61.       PageNum.Height = 20;
  62.       PageNum.Text = "00 / 00";
  63.       PageNum.TextAlignment = TextAlignment.Left;
  64.       PageNum.VerticalAlignment = VerticalAlignment.Center;
  65.       PageNum.FontFamily = new FontFamily("Comic sans MS");
  66.       Canvas.SetLeft(PageNum, 10);
  67.       Canvas.SetTop(PageNum, 607);
  68.       this.Children.Add(PageNum);
  69.     }
  70.     //设置图片路径
  71.     public void setterimgPhoto(string path)
  72.     {
  73.       BitmapImage btm = new BitmapImage();
  74.       btm.UriSource = new Uri(path, UriKind.Relative);
  75.       imgPhoto.Source = btm;
  76.     }
  77.     //设置按钮是否可见
  78.     public void setterDisplayBtnPrevious(bool YesNo)
  79.     {
  80.       if (YesNo)
  81.       {
  82.         btnPrevious.Visibility = Visibility.Visible;
  83.       }
  84.       else {
  85.         btnPrevious.Visibility = Visibility.Collapsed;
  86.       }
  87.     }
  88.     //设置页码
  89.     public void setterPageNumber(string currentPageNum, string TotalPageNum) {
  90.         PageNum.Text = currentPageNum + " / " + TotalPageNum;
  91.     }
  92.     //返回按钮单击事件关联
  93.     public Button getbtnPrevious()
  94.     {
  95.       return btnPrevious;
  96.     }

  97.   }
  98. }
复制代码
RightPage.cs文件代码:
  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Media.Imaging;
  11. using System.Windows.Shapes;

  12. namespace SilverlightClient.TypePage
  13. {
  14.   public class RightPage : Canvas
  15.   {
  16.     //定义将在页面上显示的元素
  17.     private Image imgPhoto;
  18.     private Button btnNext;
  19.     private Rectangle RecBorder;
  20.     private TextBlock PageNum;
  21.    
  22.     //构造函数
  23.     public RightPage()
  24.     {
  25.       //页面的设置
  26.       this.Width = 452;
  27.       this.Height = 630;
  28.       this.Background = new SolidColorBrush(Colors.White);
  29.       Canvas.SetLeft(this, 0);//设置页面边框在Canvas中的位置,下同。
  30.       Canvas.SetTop(this, 0);
  31.       //页面边框的设置
  32.       RecBorder = new Rectangle();
  33.       RecBorder.Width = 452;
  34.       RecBorder.Height = 630;
  35.       Canvas.SetLeft(RecBorder, 0);
  36.       Canvas.SetTop(RecBorder, 0);
  37.       RecBorder.Stroke = new SolidColorBrush(Colors.Black);
  38.       RecBorder.StrokeThickness = 0;
  39.       this.Children.Add(RecBorder);
  40.       //照片的设置
  41.       imgPhoto = new Image();
  42.       imgPhoto.Width = 450;
  43.       imgPhoto.Height = 600;
  44.       Canvas.SetLeft(imgPhoto, 1);
  45.       Canvas.SetTop(imgPhoto, 1);
  46.       this.Children.Add(imgPhoto);
  47.       //“后一页”按钮的设置
  48.       btnNext = new Button();
  49.       btnNext.Width = 150;
  50.       btnNext.Height = 20;
  51.       btnNext.Content = "后一页 >>";
  52.       btnNext.HorizontalContentAlignment = HorizontalAlignment.Center;
  53.       btnNext.VerticalContentAlignment = VerticalAlignment.Center;
  54.       btnNext.Cursor = Cursors.Hand;
  55.       Canvas.SetLeft(btnNext, 151);
  56.       Canvas.SetTop(btnNext, 605);
  57.       this.Children.Add(btnNext);
  58.       //页码文本的设置
  59.       PageNum = new TextBlock();
  60.       PageNum.Width = 100;
  61.       PageNum.Height = 20;
  62.       PageNum.Text = "00 / 00";
  63.       PageNum.TextAlignment = TextAlignment.Right;
  64.       PageNum.VerticalAlignment = VerticalAlignment.Center;
  65.       PageNum.FontFamily = new FontFamily("Comic sans MS");
  66.       Canvas.SetLeft(PageNum, 340);
  67.       Canvas.SetTop(PageNum, 607);
  68.       this.Children.Add(PageNum);
  69.     }
  70.     //设置图片路径
  71.     public void setterimgPhoto(string path)
  72.     {
  73.         BitmapImage btm = new BitmapImage();
  74.         btm.UriSource = new Uri(path, UriKind.Relative);
  75.         imgPhoto.Source = btm;
  76.     }
  77.     //设置按钮是否可见
  78.     public void setterDisplayBtnNext(bool YesNo)
  79.     {
  80.         if (YesNo)
  81.         {
  82.             btnNext.Visibility = Visibility.Visible;
  83.         }
  84.         else
  85.         {
  86.             btnNext.Visibility = Visibility.Collapsed;
  87.         }
  88.     }
  89.     //设置页码
  90.     public void setterPageNumber(string currentPageNum, string TotalPageNum)
  91.     {
  92.         PageNum.Text = currentPageNum + " / " + TotalPageNum;
  93.     }
  94.     //返回按钮单击事件关联
  95.     public Button getbtnNext()
  96.     {
  97.         return btnNext;
  98.     }

  99.   }
  100. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值