private async void selectImageButton_Tapped(object sender, RoutedEventArgs e) { FileOpenPicker picker = new FileOpenPicker(); picker.CommitButtonText = "发送"; picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); picker.FileTypeFilter.Add(".png"); var file = await picker.PickSingleFileAsync(); if (file != null) { var prop = await file.GetBasicPropertiesAsync(); if (prop.Size > GlobalConfigs.MaxUploadFileSize) { showFileTooLarge(); return; } var arg = new SentContentEventArgs() { Type = MessageType.image, Language = null, File = file }; DidSentContent?.Invoke(this, arg); } }
private void sendText() { TextInputBox.TextDocument.GetText(Windows.UI.Text.TextGetOptions.UseLf, out string text); if (text.IsNullOrEmpty()) { return; } var arg = new SentContentEventArgs() { Type = MessageType.text, Language = null, Content = text.Trim() }; DidSentContent?.Invoke(this, arg); TextInputBox.TextDocument.SetText(Windows.UI.Text.TextSetOptions.None, ""); }
private void SendCodePanel_DidSendCode(string lang, string code) { if (code.IsNullOrEmpty()) { return; } var arg = new SentContentEventArgs() { Type = MessageType.code, Language = lang, Content = code }; DidSentContent?.Invoke(this, arg); sendCodeButton.Flyout.Hide(); }