当前位置: 首页>>代码示例>>C#>>正文


C# Image.UpdateLayout方法代码示例

本文整理汇总了C#中System.Windows.Controls.Image.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Image.UpdateLayout方法的具体用法?C# Image.UpdateLayout怎么用?C# Image.UpdateLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Image的用法示例。


在下文中一共展示了Image.UpdateLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertCanvasPositionedIcons

		public Image InsertCanvasPositionedIcons (Canvas FramingCanvas, String IconFileName,
							double WidthPercentage, double HeightPercentage,
							double ImageWidthPercentage)
			{
			if (!File.Exists (IconFileName))
				return null;
			Image IconImage = new Image ();
			FramingCanvas.Children.Add (IconImage);
			FramingCanvas.UpdateLayout ();
			double ActCanvasHeight = FramingCanvas.ActualHeight;
			double ActCanvasWidth = FramingCanvas.ActualWidth;
			BitmapImage IconBitmap = new BitmapImage ();
			IconBitmap.BeginInit ();
			IconBitmap.UriSource = new Uri (IconFileName);
			IconBitmap.EndInit ();
			IconImage.Source = IconBitmap;
			IconImage.Width = ActCanvasWidth * ImageWidthPercentage / 100;
			IconImage.UpdateLayout ();
			double ActIconHeight = IconImage.ActualHeight;
			double ActIconWidth = IconImage.ActualWidth;
			Canvas.SetTop (IconImage, (((ActCanvasHeight * HeightPercentage) / 100) - (ActIconHeight / 2)));
			Canvas.SetLeft (IconImage, (((ActCanvasWidth * WidthPercentage) / 100) - (ActIconWidth / 2)));
			return IconImage;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:24,代码来源:XAMLHandling.cs

示例2: InsertCanvasPositionedPicture

		public Image InsertCanvasPositionedPicture (Canvas FramingCanvas, String Base64Input,
							double LeftPercentage,
							double TopPercentage,
							double ImageWidthPercentage,
							double ImageHeightPercentage)
			{
			Image PictureImage = new Image ();
			FramingCanvas.Children.Add (PictureImage);
			FramingCanvas.UpdateLayout ();
			double ActCanvasHeight = FramingCanvas.ActualHeight;
			double ActCanvasWidth = FramingCanvas.ActualWidth;
			byte [] ImageBytes = System.Convert.FromBase64String (Base64Input);
			MemoryStream ImageDataStream = new MemoryStream ();
			ImageDataStream.Write (ImageBytes, 0, ImageBytes.Length);
			ImageDataStream.Seek (0, SeekOrigin.Begin);
			BitmapImage DrawingBitmap = new BitmapImage ();
			//DrawingBitmap.CacheOption = BitmapCacheOption.OnLoad;
			DrawingBitmap.BeginInit ();
			DrawingBitmap.StreamSource = ImageDataStream;
			DrawingBitmap.EndInit ();
			if (ImageWidthPercentage > 0)
				{
				DrawingBitmap.DecodePixelWidth = (int)(ActCanvasWidth * ImageWidthPercentage / 100);
				PictureImage.Width = ActCanvasWidth * ImageWidthPercentage / 100;
				}
			if (ImageHeightPercentage > 0)
				{
				DrawingBitmap.DecodePixelHeight = (int)(ActCanvasHeight * ImageHeightPercentage / 100);
				PictureImage.Height = ActCanvasHeight * ImageHeightPercentage / 100;
				}
			PictureImage.Source = DrawingBitmap;
			//PictureImage.Width = ActCanvasWidth * ImageWidthPercentage / 100;
			PictureImage.UpdateLayout ();
			//double ActIconHeight = PictureImage.ActualHeight;
			//double ActIconWidth = PictureImage.ActualWidth;
			Canvas.SetTop (PictureImage, ((ActCanvasHeight * TopPercentage) / 100));
			Canvas.SetLeft (PictureImage, ((ActCanvasWidth * LeftPercentage) / 100));
			return PictureImage;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:39,代码来源:XAMLHandling.cs


注:本文中的System.Windows.Controls.Image.UpdateLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。