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;
        }
            Image GetPic(string input)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("img/icon_files.png", UriKind.Relative));
                img.Width = 20;
                img.MaxWidth = 600;

                PicServiceClient client = new PicServiceClient();
                client.DownloadCompleted += (sender, e) =>
                {
                    Stream s = new MemoryStream(e.Result);
                    BitmapImage bi = new BitmapImage();
                    bi.SetSource(s);
                    img.Source = bi;
                    img.Width = bi.PixelWidth > 480 ? 480 : bi.PixelWidth;
                };
                client.DownloadAsync(input);

                return img;
            }
Example #3
0
 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);
 }