private void OpenFile(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog() { Filter = "图片 (*.jpg)|*.jpg", Multiselect = false //不允许多选 }; bool chooseFile = dialog.ShowDialog() == true; if (!chooseFile) { return; } cover.CanSee = true; Stream tStream = dialog.File.OpenRead(); byte[] t = new byte[tStream.Length]; tStream.Read(t, 0, (int)tStream.Length); PicServiceClient client = new PicServiceClient(); client.UploadCompleted += (_sender, _e) => { State = _e.Result; cover.CanSee = false; hadOpenFile = true; }; client.UploadAsync(t); Stream ts = new MemoryStream(t); BitmapImage bi = new BitmapImage(); bi.SetSource(ts); img.ImageSource = bi; }
public void AddScreenShot(object objectImage) { byte[] byteImage = (byte[])objectImage; PicServiceClient client = new PicServiceClient(); client.UploadCompleted += (sender, e) => { WaitSendContent = WaitSendContent + "[^pic]" + e.Result + "[$pic]"; }; client.UploadAsync(byteImage); }