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 = "对方正在输入..."; }
private void CreateChattingShell(string strRoomSID) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(() => { var ChattingViewModel = new ChattingViewModel(strRoomSID, this); var ChattingView = new ChattingView(ChattingViewModel); var ChattingShellViewModel = new ChattingShellViewModel(strRoomSID, this); var ChattingShellView = new ChattingShellView(ChattingShellViewModel); ChattingShellView.ChattingViewModel = ChattingViewModel; ChattingShellView.Content = ChattingView; ChattingViewModel.ShellView = ChattingShellView; if (true == this.m_ChattingRoomsDictionary.Register(strRoomSID, ChattingShellView)) { ChattingShellView.ShowChattingShellView(); } })); }
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 = "对方正在输入..."; }
private async void NickNameBtn_Click(object sender, RoutedEventArgs e) { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".png"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read); BitmapDecoder decoder = await BitmapDecoder.CreateAsync(readStream); WriteableBitmap writeableImage = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight); writeableImage.SetSource(readStream); StorageFolder folder; folder = ApplicationData.Current.LocalFolder; string fileName = DateTimeOffset.UtcNow.ToString(); fileName = fileName.Replace(":", "").Replace("/", "").Replace("+", "").Replace(" ", ""); StorageFile saving = await folder.CreateFileAsync(fileName + file.FileType.ToString(), CreationCollisionOption.ReplaceExisting); await SaveWriteableBitmapImageFile(writeableImage, saving); pageNickNamePath = "ms-appdata:///local/" + fileName + file.FileType.ToString(); BitmapImage bitMap = new BitmapImage(new Uri(pageNickNamePath)); NickPic.Source = bitMap; ChattingViewModel.UpdateNick(pageNickNamePath); this.DataContext = ChattingViewModel; } }
private void AddChattingButton_Click(object sender, RoutedEventArgs e) { ChattingListViewModel.GetInstance().Add(new ChattingListViewModel() { Title = "한기대 알고리즘 " + stack + "분반 오픈카톡방입니다. 환영해요", Body = "아니 그게 아니라... 이건rㅂㅈㄷㅅㅂㅈㄷㅅㅂㅈㄷㄱㅂㅈㄷㅅㅂㅈㄱㅂㅈㄷㄱㅂㅈㄷㅂㅈㄷㅅ데", Date = "2021-04-25" }); ChattingViewModel vm = new ChattingViewModel(); vm.Title = "한기대 알고리즘 " + stack++ + "분반 오픈카톡방입니다. 환영해요"; vm.List.Add(new ChatListForm() { NickName = "바보!!", Body = "반갑습니다 바보라구 해용!", NowTime = "오후 10:53" }); vm.List.Add(new ChatListForm() { NickName = "운영자", Body = "안녕하십니까 꼭 필독사항(공지사항)을 읽어 주신 후 질문해주시길 바랍니다!!!", NowTime = "오후 10:54" }); vm.List.Add(new ChatListForm() { NickName = "유저유저", Body = "질문이있습니다!! WPF에 대한 MVVM정석이 알고싶습니다. 저는 그냥 동작만하는 비둘기 대가리가 돌아가서 날라는 것과 비슷해서 질문드립니다!!", NowTime = "오후 10:55" }); vm.List.Add(new ChatListForm() { NickName = "김루트", Body = "혹시 11시에 배그하실 분 계신가요?? 재미있게 배그할 사람 구해요~!!!!!", NowTime = "오후 10:55" }); vm.List.Add(new ChatListForm() { NickName = "롤은 질병겜", Body = "자랭하실분 구합니다.. 즐겁게 하실분 구해요!!! 즐겜파티~!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "착짱죽짱", Body = "짱깨처럼 핵 안쓰는 배그 하실 착한분들 구합니다~ 즐겁고 화끈하게 무한 리부트로 하실분 구해요~!!! 무조건 여포모드 ON!!!", NowTime = "오후 11:05" }); vm.List.Add(new ChatListForm() { NickName = "자1지훈", Body = "로리지훈 로리지훈 섹스 섹스 로리지훈 로리지훈 섹스 섹스", NowTime = "오후 11:05" }); vmlist.Add(vm); }
public ChattingMainWindow(ChattingViewModel vm) { InitializeComponent(); TitleTextBox.DataContext = vm; ChattingListSubWindow.ChatMsgList.ItemsSource = vm.List; }
public void SetViewModel(ChattingViewModel vm) { parentViewModel = vm; ConfigureView(); }
public ChattingView(ChattingViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; }
/*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; } }