private void Upload(object sender, RoutedEventArgs e) { if (ShoppingCart.Count > 0) { TimeSpan scaleDuration = new TimeSpan(0, 0, 0, 0, ShoppingCart.Count * 200); DoubleAnimation ProgressAnimation = new DoubleAnimation(0, 100, scaleDuration, FillBehavior.Stop); UploadProgressBar.BeginAnimation(ProgressBar.ValueProperty, ProgressAnimation); // MessageBox.Show(ShoppingCart.Count.ToString()); foreach (var imageCart in ShoppingCart) { BitmapSource imageForCust = imageCart.Photo; CurrentPhoto.Source = imageForCust; MessageBox.Show(imageForCust.ToString()); using (var fileStream = new FileStream("..\\..\\photosCust", FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(imageForCust)); encoder.Save(fileStream); } } ShoppingCart.Clear(); UploadButton.IsEnabled = false; if (true == RemoveButton.IsEnabled) RemoveButton.IsEnabled = false; } }
/// <summary> /// Gets the image filename. /// </summary> /// <param name="bitmapSource">The bitmap source.</param> internal static string GetImageFilename(BitmapSource bitmapSource) { string filename = bitmapSource.ToString(); filename = UrlDecodeStringFromStringInternal(filename); if (filename.StartsWith("file:///")) { filename = filename.Substring(8); // Remove all 3 slashes! } else if (filename.StartsWith("file://")) { filename = filename.Substring(5); // Keep 2 slashes (UNC path) } return(filename); }
private static BitmapImage BitmapFromSource(BitmapSource bitmapsource) { Console.WriteLine("bitmapsource" + bitmapsource.ToString()); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); MemoryStream memoryStream = new MemoryStream(); BitmapImage bImg = new BitmapImage(); encoder.Frames.Add(BitmapFrame.Create(bitmapsource)); encoder.Save(memoryStream); memoryStream.Position = 0; bImg.BeginInit(); bImg.StreamSource = memoryStream; bImg.EndInit(); memoryStream.Close(); return(bImg); }
private void SetImageInfo(BitmapSource bitmapSource) { this.m_lblPictureInfoName.Content = this.m_lblPictureInfoSize.Content = String.Empty; if (null == bitmapSource) { return; } string strImagePath = bitmapSource.ToString(); int iImageName = strImagePath.LastIndexOf('/'); if (-1 != iImageName) { this.m_lblPictureInfoName.Content = strImagePath.Substring(iImageName + 1); } this.ImagePath = strImagePath; this.m_lblPictureInfoSize.Content = String.Format("{0:0.##} x {1:0.##} (šířka x výška v pixelech)", bitmapSource.Width, bitmapSource.Height); this.m_strHyperlink = (null != this.Image.Tag ? (string)this.Image.Tag : ""); }
/// <summary> /// SetDefaults button click handler /// </summary> private void OnSetDefaultsClick(object sender, RoutedEventArgs e) { //AcmBitmapImageHolder acmBitmapImageHolder = new AcmBitmapImageHolder(this.Image,((BitmapImage)this.Image.Source).UriSource); try { BitmapSource bitmapSource = this.Image.Source as BitmapSource; if (null != bitmapSource) { AcmBitmapImageHolder acmBitmapImageHolder = new AcmBitmapImageHolder(this.Image, new Uri(bitmapSource.ToString())); } } catch (Exception ex) { Debug.WriteLine("OnSetDefaultsClick ex: " + ex); } //this.BindImage(acmBitmapImageHolder.Image); }
/// <summary> /// Gets the image filename. /// </summary> /// <param name="bitmapSource">The bitmap source.</param> internal static string GetImageFilename(BitmapSource bitmapSource) { string filename = bitmapSource.ToString(); filename = UrlDecodeStringFromStringInternal(filename); if (filename.StartsWith("file:///")) filename = filename.Substring(8); // Remove all 3 slashes! else if (filename.StartsWith("file://")) filename = filename.Substring(5); // Keep 2 slashes (UNC path) return filename; }