public MainWindow()
        {
            InitializeComponent();
            //设置窗体大小
            double height = SystemParameters.PrimaryScreenHeight;
            double width  = SystemParameters.PrimaryScreenWidth;

            this.Width  = width * 6 / 7;
            this.Height = height * 8 / 9;


            //获取下一步按钮原来的颜色
            brushNext = NextBtn.Background;

            //获取购票进度的不同颜色
            ok   = selectLine.Background;
            noOk = selectTicketNum.Background;
            //创建车票对象
            ticket             = new Ticket();
            pages[0]           = new SelectLinePage(ticket);
            pages[1]           = new SelectTicketNum(ticket);
            pages[2]           = new Pay(ticket);
            pages[3]           = new PaySucceed(ticket);
            main_frame.Content = pages[0];
            //设置第一个页面的相关属性
            SelectLinePage selectLinePage = (SelectLinePage)pages[0];

            selectLinePage.setTicketFrameAndPage(main_frame, pages);

            //初始化计时器
            timerIsSelectLine          = new DispatcherTimer();
            timerIsSelectLine.Interval = TimeSpan.FromMilliseconds(100);
            timerIsSelectLine.Tick    += timerIsSelectLine_Tick;
            timerIsSelectLine.Start();
            //
        }
 /// <summary>
 /// 下一步按钮鼠标单击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NextBtn_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (main_frame.Content == pages[0])
     {     //进入选票数页面
         if (ticket.Destination.Equals("未选"))
         { //判断是否选择站点
             MessageBox.Show("请选择站点");
         }
         else
         {//已经选择站点
             main_frame.Content         = pages[1];
             selectTicketNum.Background = ok;
         }
     }
     else if (main_frame.Content == pages[1])
     {                      //进入购票页面
         Pay p = (Pay)pages[2];
         p.updatePayInfo(); //更新购票信息
         main_frame.Content = pages[2];
         //nextText.Text = "确认购票";
         pay.Background = ok;
     }
     else if (main_frame.Content == pages[2])
     {                            //进入支付成功页面
         Pay p2 = (Pay)pages[2];
         int cp = p2.buyTicket(); //得到购票返回的信息:-1余额不足,0异常出错,1购票成功,3验证码错误
         if (cp == 1)
         {
             main_frame.Content = pages[3];
             //nextText.Text = "返回";
             paySucceed.Background = ok;
             //启动出票计时器
             PaySucceed p = (PaySucceed)pages[3];
             p.startTimer(NextBtn, brushNext);
         }
         else if (cp == -1)
         {
             MessageBox.Show("用户余额不足!");
         }
         else if (cp == 0)
         {
             MessageBox.Show("系统异常,请联系管理人员!");
         }
         else if (cp == 3)
         {
             MessageBox.Show("验证码错误!");
         }
         else if (cp == 2)
         {
             MessageBox.Show("用户信息错误!");
         }
     }
     else if (main_frame.Content == pages[3])
     {//返回选路线页面
         //nextText.Text = "下一步";
         selectTicketNum.Background = noOk;
         pay.Background             = noOk;
         paySucceed.Background      = noOk;
         main_frame.NavigationService.RemoveBackEntry();
         //生成一个新的界面
         this.ticket        = new Ticket();//初始化新的票
         pages[0]           = new SelectLinePage(ticket);
         pages[1]           = new SelectTicketNum(ticket);
         pages[2]           = new Pay(ticket);
         pages[3]           = new PaySucceed(ticket);
         main_frame.Content = pages[0];
         //设置第一个页面的相关属性
         SelectLinePage selectLinePage = (SelectLinePage)pages[0];
         selectLinePage.setTicketFrameAndPage(main_frame, pages);
     }
 }