public ImageControlBaseInfo(ImageControl imageControl) { _isLockAspect = imageControl.IsLockAspect; _width = imageControl.Width; _height = imageControl.Height; var bitmapImage = (imageControl.Content as AnimatedGif)?.Source as BitmapImage; if (bitmapImage == null) { var bitmapSource = (imageControl.Content as AnimatedGif)?.Source as BitmapSource; if (bitmapSource != null) { bitmapImage = bitmapSource.GetBitmapImage(); } } var stream = bitmapImage?.StreamSource as MemoryStream; if (stream != null) { stream.Position = 0; _imageSource = Convert.ToBase64String(stream.ToArray()); } _renderTransform = XamlWriter.Save(imageControl.RenderTransform); }
/// <summary> /// 深度拷贝 /// </summary> /// <returns>返回一个副本</returns> public object Clone() { var animatedImage = new AnimatedGif { Source = (Content as AnimatedGif)?.Source, Stretch = Stretch.Fill }; var imageControl = new ImageControl(ControlManager) { IsLockAspect = IsLockAspect, Width = Width, Height = Height, Content = animatedImage, Template = Template, RenderTransform = RenderTransform.Clone(), }; return(imageControl); }