private async void CheckMessage() { switch (TypingArea.Text) { case "": NotifyUser("You cannot send an empty message."); return; case "关闭解析": viewmodel.AddSelf(TypingArea.Text); TypingArea.Text = ""; viewmodel.AddEmilia("好的,JSON解析已关闭。不过这样哥哥还能看懂我说话吗?"); doParse = false; return; case "开启解析": viewmodel.AddSelf(TypingArea.Text); TypingArea.Text = ""; viewmodel.AddEmilia("好的,JSON解析已开启。不过人类的语言用着有些别扭呢=v="); doParse = true; return; case "放点音乐吧": viewmodel.AddSelf(TypingArea.Text); TypingArea.Text = ""; viewmodel.AddEmilia("好的,开启音乐播放器~"); (Parent as Frame).Navigate(typeof(PlayerPage), 0); return; default: break; } if (TypingArea.Text.Contains("播放")) { viewmodel.AddSelf(TypingArea.Text); string[] parse = TypingArea.Text.Split(' '); int index; TypingArea.Text = ""; if ((index = MusicVM.GetInstance().hasMedia(parse[1])) != -1) { viewmodel.AddEmilia("好的,即将为您播放 " + MusicVM.GetInstance().Musics[index].Title); (Parent as Frame).Navigate(typeof(PlayerPage), index); } else { viewmodel.AddEmilia("没有找到您要播放的曲子,是否是您输入的格式有误?\n Tips:发送 播放 【音乐名字】 以播放音乐"); } return; } string message = string.Copy(TypingArea.Text); TypingArea.Text = ""; viewmodel.AddSelf(message); MyScrollViewer.UpdateLayout(); MyScrollViewer.ChangeView(null, double.MaxValue, null); SendMessage(message); }
// Get instance method // Create (if haven't been created) and return it public static MusicVM GetInstance() { if (_instance == null) { _instance = new MusicVM(); } return(_instance); }
private void NavView_Loaded(object sender, RoutedEventArgs e) { // 动态添加item NavView.MenuItems.Add(new NavigationViewItemSeparator()); NavView.MenuItems.Add(new NavigationViewItem() { Content = "Chat Robot", Icon = new SymbolIcon(Symbol.Character), Tag = "Chat Robot" }); NavView.MenuItems.Add(new NavigationViewItem() { Content = "IP Query", Icon = new SymbolIcon(Symbol.Find), Tag = "IP Query" }); NavView.MenuItems.Add(new NavigationViewItemSeparator()); NavView.MenuItems.Add(new NavigationViewItemHeader() { Content = " Media" }); NavView.MenuItems.Add(new NavigationViewItem() { Content = "Media Player", Icon = new SymbolIcon(Symbol.MusicInfo), Tag = "Media Player" }); MusicVM music = MusicVM.GetInstance(); }