Exemplo n.º 1
0
 private void Choose1_Click(object sender, RoutedEventArgs e)
 {
     if (!ifInit)
     {
         choose += "1";
     }
     ChattingViewModel.AddChattingItem(1, Choose1Text.Text, pageNickNamePath);
     saveProcess();
     LastMessage        = chattingItemHandle(Choose1Text.Text);
     Choose0.Visibility = Visibility.Collapsed;
     Choose1.Visibility = Visibility.Collapsed;
     this.DataContext   = ChattingViewModel;
     Timer.Start();
     Inputing.Text = "对方正在输入...";
 }
Exemplo n.º 2
0
 private void Choose0_Click(object sender, RoutedEventArgs e)
 {
     /*进入0支线*/
     if (!ifInit)
     {
         choose += "0";
     }
     /*将选项的文字作为"你"说的话,添加到页面的viewmodel里*/
     ChattingViewModel.AddChattingItem(1, Choose0Text.Text, pageNickNamePath);
     saveProcess();
     LastMessage = chattingItemHandle(Choose0Text.Text);
     /*隐藏两个按钮*/
     Choose0.Visibility = Visibility.Collapsed;
     Choose1.Visibility = Visibility.Collapsed;
     /*更新dataContext*/
     this.DataContext = ChattingViewModel;
     Timer.Start();
     Inputing.Text = "对方正在输入...";
 }
Exemplo n.º 3
0
 /*Run every 6 sec*/
 private void loadMessage(object sender, object e)
 {
     if (count >= branchLength)
     {
         count = 0;
         loadABranchStoryData();
         Inputing.Text = "";
     }
     else
     {
         if (aBranch[count].Next == "time")
         {
             string timeShow = DateTime.Now.ToString("MM月dd日 HH:mm");
             ChattingViewModel.AddChattingItem(5, timeShow, pageNickNamePath);
             ++count;
             this.DataContext = ChattingViewModel;
             saveProcess();
         }
         Inputing.Text = "对方正在输入...";
         if (aBranch[count].Next == "on")
         {
             Inputing.Text = "";
             ChattingViewModel.AddChattingItem(2, "对方已上线", pageNickNamePath);
             ++count;
             this.DataContext = ChattingViewModel;
             saveProcess();
         }
         else if (aBranch[count].Next == "off")
         {
             Inputing.Text = "";
             ChattingViewModel.AddChattingItem(3, "对方已下线", pageNickNamePath);
             ++count;
             this.DataContext = ChattingViewModel;
             saveProcess();
         }
         /*问题的标志,需要调取下面两个作为回答选项*/
         else if (aBranch[count].Next == "choose")
         {
             saveProcess();
             ifInit             = false;
             Choose0.Visibility = Visibility.Visible;
             Choose0Text.Text   = aBranch[count++].Msg;
             Choose1.Visibility = Visibility.Visible;
             Choose1Text.Text   = aBranch[count++].Msg;
             Inputing.Text      = "";
             Timer.Stop();
         }
         /*直接进行*/
         else if (aBranch[count].Next == "choose0")
         {
             saveProcess();
             ifInit             = true;
             Choose0.Visibility = Visibility.Visible;
             Choose0Text.Text   = aBranch[count++].Msg;
             Choose1.Visibility = Visibility.Visible;
             Choose1Text.Text   = aBranch[count++].Msg;
             Inputing.Text      = "";
             Timer.Stop();
         }
         /*需要延迟*/
         else if (aBranch[count].Next == "delay")
         {
             Inputing.Text = "";
             int delayLong = (int)(speedUp * int.Parse(aBranch[count++].Msg));
             runTime = DateTime.Now.AddMinutes(delayLong);
             saveProcess();
             Timer.Stop();
             delayTimer.Start();
         }
         /*新闻*/
         else if (aBranch[count].Next == "news")
         {
             Inputing.Text = "";
             ++UnReadNews;
             LastNews = chattingItemHandle(aBranch[count].Msg);
             NewsViewModel.AddNewsItem(aBranch[count++].Msg);
             saveProcess();
         }
         /*Bad end*/
         else if (aBranch[count].Next == "die")
         {
             choose = "X1";
             count  = 0;
             using (var conn = Process.ProcessDatabase.GetDbConnection()) {
                 var processInfo = conn.Table <Process.Process>();
                 foreach (var item in processInfo)
                 {
                     conn.Delete(item);
                 }
             }
             this.ChattingViewModel.Clear();
             this.NewsViewModel.Clear();
             this.MomentViewModels.Clear();
             Timer.Stop();
             this.Frame.Navigate(typeof(BadEnd));
         }
         /*发朋友圈的图片地址*/
         else if (aBranch[count].Next.Length > 6)
         {
             this.MomentViewModels.AddMomentItem(aBranch[count].Msg, aBranch[count].Next);
             ChattingViewModel.AddChattingItem(4, "朋友圈已更新", pageNickNamePath);
             this.DataContext = ChattingViewModel;
             ++count;
             saveProcess();
         }
         /*不是choose,只可能是跳转database的标志,赋值choose为next即可*/
         else if (aBranch[count].Next.Length != 0)
         {
             ChattingViewModel.AddChattingItem(0, aBranch[count].Msg, pageNickNamePath);
             ++UnRead;
             LastMessage      = chattingItemHandle(aBranch[count].Msg);
             this.DataContext = ChattingViewModel;
             choose           = aBranch[count++].Next;
             saveProcess();
         }
         /*普通消息,直接展示*/
         else
         {
             ChattingViewModel.AddChattingItem(0, aBranch[count].Msg, pageNickNamePath);
             ++UnRead;
             LastMessage      = chattingItemHandle(aBranch[count++].Msg);
             this.DataContext = ChattingViewModel;
             saveProcess();
         }
     }
     if (runTime < DateTime.Now)
     {
         runTime = DateTime.Now;
     }
 }