void Client_GetDiamondShoppingItemDetailImageBufferCompleted(object sender, Wcf.Clients.WebInvokeEventArgs <byte[][]> e) { try { App.BusyToken.CloseBusyWindow(); if (e.Error != null) { MyMessageBox.ShowInfo("加载钻石商品详细信息失败。原因为:" + e.Error.Message); return; } ListDetailImages.Clear(); ListDetailImageBuffers.Clear(); if (e.Result != null) { foreach (var item in e.Result) { ListDetailImageBuffers.Add(item); ListDetailImages.Add(MyImageConverter.GetIconSource(item)); } } this.IsEnabled = true; } catch (Exception exc) { MyMessageBox.ShowInfo("加载钻石商品详细信息异常。原因为:" + exc.Message); } }
private void btnAddDetailImage_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog openDig = new OpenFileDialog(); if (openDig.ShowDialog() == true) { string imgName = Guid.NewGuid().ToString(); byte[] buffer = null; using (FileStream stream = new FileStream(openDig.FileName, FileMode.Open)) { buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); } this.ListDetailImageNames.Add(imgName); this.ListDetailImageBuffers.Add(buffer); this.ListDetailImages.Add(MyImageConverter.GetIconSource(buffer)); } } catch (Exception exc) { MyMessageBox.ShowInfo(exc.Message); } }
private void btnUploadIcon_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog openDig = new OpenFileDialog(); if (openDig.ShowDialog() == true) { using (FileStream stream = new FileStream(openDig.FileName, FileMode.Open)) { _iconBuffer = new byte[stream.Length]; stream.Read(_iconBuffer, 0, (int)stream.Length); } this.imgIcon.Source = MyImageConverter.GetIconSource(_iconBuffer); } } catch (Exception exc) { } }
public void SetIcon(byte[] buffer) { this._parentObject.IconBuffer = buffer; this._icon = MyImageConverter.GetIconSource(buffer); }