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


C# UIElement.Arrange方法代码示例

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


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

示例1: Arrange

		/// <summary>
		/// Arranges the adorner element on the specified adorner panel.
		/// </summary>
		public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
		{
			Point p = new Point(0, 0);
			if (shape is Line)
			{
				var s = shape as Line;
				double x, y;
				
				if (alignment == PlacementAlignment.BottomRight)
				{
					x = s.X2;
					y = s.Y2;
				}
				else
				{
					x = s.X1;
					y = s.Y1;
				}
				p = new Point(x, y);
			} else if (shape is Polygon) {
				var pg = shape as Polygon;
				p = pg.Points[Index];
			} else if (shape is Polyline) {
				var pg = shape as Polyline;
				p = pg.Points[Index];
			}

			var transform = shape.RenderedGeometry.Transform;
			p = transform.Transform(p);
			
			adorner.Arrange(new Rect(p.X - 3.5, p.Y - 3.5, 7, 7));
		}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:35,代码来源:PointTrackerPlacementSupport.cs

示例2: CreateCursor

    public static Cursor CreateCursor(UIElement element, int xHotSpot, 
        int yHotSpot)
    {
      element.Measure(new Size(double.PositiveInfinity, 
        double.PositiveInfinity));
      element.Arrange(new Rect(0, 0, element.DesiredSize.Width, 
        element.DesiredSize.Height));

      RenderTargetBitmap rtb = 
        new RenderTargetBitmap((int)element.DesiredSize.Width, 
          (int)element.DesiredSize.Height, 96, 96, PixelFormats.Pbgra32);
      rtb.Render(element);

      PngBitmapEncoder encoder = new PngBitmapEncoder();
      encoder.Frames.Add(BitmapFrame.Create(rtb));

      MemoryStream ms = new MemoryStream();
      encoder.Save(ms);

      System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);

      ms.Close();
      ms.Dispose();     

      Cursor cur = InternalCreateCursor(bmp, xHotSpot, yHotSpot);

      bmp.Dispose();

      return cur;
    }
开发者ID:heinzsack,项目名称:DEV,代码行数:30,代码来源:CursorHelper.cs

示例3: CreateElementScreenshot

		private static BitmapSource CreateElementScreenshot(UIElement uiElement)
		{
			bool measureValid = uiElement.IsMeasureValid;

			if (!measureValid)
			{
				double width = 300;
				double height = 300;

				FrameworkElement frElement = uiElement as FrameworkElement;
				if (frElement != null)
				{
					if (!Double.IsNaN(frElement.Width))
						width = frElement.Width;
					if (!Double.IsNaN(frElement.Height))
						height = frElement.Height;
				}

				Size size = new Size(width, height);
				uiElement.Measure(size);
				uiElement.Arrange(new Rect(size));
			}

			RenderTargetBitmap bmp = new RenderTargetBitmap(
				(int)uiElement.RenderSize.Width, (int)uiElement.RenderSize.Height,
				96, 96, PixelFormats.Default);

			// this is waiting for dispatcher to perform measure, arrange and render passes
			uiElement.Dispatcher.Invoke(((Action)(() => { })), DispatcherPriority.Background);

			bmp.Render(uiElement);

			return bmp;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:34,代码来源:ScreenshotHelper.cs

示例4: ToImageSource

        public static ImageSource ToImageSource(UIElement element, System.Windows.Size size)
        {
            element.Measure(size);
            element.Arrange(new Rect(size));

            var bmp = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Pbgra32);
            bmp.Render(element);
            return bmp;
        }
开发者ID:node-net,项目名称:Node.Net,代码行数:9,代码来源:UIElement.Extensions.cs

示例5: ToBitmapStream

 public static MemoryStream ToBitmapStream(UIElement uiElement, double width, double height)
 {
     var renderTargetBitmap = new RenderTargetBitmap((int)width, (int)height, 96, 96, new PixelFormat());
     uiElement.Arrange(new Rect(0, 0, width, height));
     renderTargetBitmap.Render(uiElement);
     var bitmap = new PngBitmapEncoder();
     bitmap.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
     var bitmapStream = new MemoryStream();
     bitmap.Save(bitmapStream);
     return bitmapStream;
 }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:11,代码来源:BitmapConverter.cs

示例6: SaveElement

 public static bool SaveElement(UIElement element, Tile tile)
 {
     try
     {
         var side = (tile == Tile.Small) ? 159 : 336;
         element.Measure(new Size(side, side));
         element.Arrange(new Rect(0, 0, side, side));
         var bmp = new WriteableBitmap(side, side);
         bmp.Render(element, null);
         bmp.Invalidate();
         var name = tile.ToString() + Guid.NewGuid() + ".png";
         using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
         {
             if (!isf.DirectoryExists("/CustomLiveTiles"))
             {
                 isf.CreateDirectory("/CustomLiveTiles");
             }
             using (var myFileStream = isf.CreateFile("shared/shellcontent/" + name))
             {
                 // Encode WriteableBitmap object to a PNG stream.
                 bmp.WritePng(myFileStream);
             }
             var filesTodelete =
                      from f in isf.GetFileNames("shared/shellcontent/" + tile + "*").AsQueryable()
                      where !f.EndsWith(name)
                      select f;
             foreach (var file in filesTodelete)
             {
                 isf.DeleteFile("shared/shellcontent/" + file);
             }
         }
         SaveTilePart("isostore:/Shared/ShellContent/" + name, tile);
     }
     catch (Exception)
     {
         Thread.Sleep(1000);
         if (tile == Tile.Small)
         {
             SaveTilePart(GetDefaultSmallTile(), tile);
         }
         else
         {
             SaveTilePart((tile == Tile.Front) ? GetDefaultFrontTile() : GetDefaultBackTile(), tile);
         }
         return false;
     }
     return true;
 }
开发者ID:JanJoris,项目名称:VikingApp,代码行数:48,代码来源:Helper.cs

示例7: GenerateBitmapSource

        public static BitmapSource GenerateBitmapSource(UIElement element, double renderWidth, double renderHeight, bool performLayout)
        {
            if (performLayout)
            {
                element.Measure(new Size(renderWidth, renderHeight));
                element.Arrange(new Rect(new Size(renderWidth, renderHeight)));
            }

            var bmp = new RenderTargetBitmap((int)renderWidth, (int)renderHeight, 96, 96, PixelFormats.Pbgra32);
            var dv = new DrawingVisual();
            using (DrawingContext dc = dv.RenderOpen())
            {
                dc.DrawRectangle(new VisualBrush(element), null, new Rect(0, 0, renderWidth, renderHeight));
            }
            bmp.Render(dv);
            return bmp;
        }
开发者ID:MahApps,项目名称:MahApps.Metro,代码行数:17,代码来源:Utilities.Wpf.cs

示例8: RenderControlToBitmap

        private static void RenderControlToBitmap(UIElement control, [NotNull] string path, int scale = 1,
            double maxWidth = double.PositiveInfinity, double maxheight = double.PositiveInfinity)
        {
            var availableSize = new Size(maxWidth, maxheight);
            control.Measure(availableSize);
            var desiredSize = control.DesiredSize;
            control.Arrange(new Rect(desiredSize));
            var dpi = scale * 96;
            var bmp = new RenderTargetBitmap((int)desiredSize.Width * scale, (int)desiredSize.Height * scale, dpi, dpi, PixelFormats.Pbgra32);

            bmp.Render(control);

            var encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bmp));
            var dir = Path.GetDirectoryName(path);
            if (dir == null)
                throw new InvalidPathException(path);
            Directory.CreateDirectory(dir);
            using (Stream stm = File.Create(path))
                encoder.Save(stm);
        }
开发者ID:davidkron,项目名称:DevArch,代码行数:22,代码来源:BitmapRenderer.cs

示例9: ToImage

        private async Task ToImage(UIElement element, double width, double height)
        {
            element.Measure(new Size(width, height));
            element.Arrange(new Rect { Height = height, Width = width });
            element.UpdateLayout();

            var bitmap = new WriteableBitmap((int)width, (int)height);
            bitmap.Render(element, null);
            bitmap.Invalidate();

            await SaveTheImage(bitmap, WideTileUrl);
        }
开发者ID:Austin503,项目名称:Emby.WindowsPhone,代码行数:12,代码来源:TileService.cs

示例10: ToImage

        private async Task ToImage(UIElement element)
        {
            element.Measure(new Size(480, 800));
            element.Arrange(new Rect{ Height = 800, Width = 480});
            element.UpdateLayout();

            var bitmap = new WriteableBitmap(480, 800);
            bitmap.Render(element, null);
            bitmap.Invalidate();

            await SaveTheImage(bitmap);
        }
开发者ID:gep13,项目名称:Emby.WindowsPhone,代码行数:12,代码来源:LockScreenService.cs

示例11: Arrange

			public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
			{
				adorner.Arrange(new Rect(adornedElementSize));
			}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:AdornerPlacement.cs

示例12: ArrangeDecoratorChild

		public static Size ArrangeDecoratorChild (UIElement child, Size constraint, double borderThickness)
		{
			if (child != null) {
				double actualBorderThickness = Utility.GetActualDecoratorBorderThickness (borderThickness, constraint.Width, constraint.Height);
				child.Arrange (GetArrangeRectToPassToDecoratorChild (constraint, actualBorderThickness));
			}
			return constraint;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:8,代码来源:Utility.cs

示例13: DoLayout

        /// <summary>
        /// We initiate the layout on the tree rooted at the Visual to which VisualBrush points.
        /// </summary>
        private void DoLayout(UIElement element)
        {
            Debug.Assert(element != null);

            DependencyObject parent = VisualTreeHelper.GetParent(element);
            if (!(element.IsRootElement)
                && (parent == null || parent is Visual3D))
            {
                //
                // PropagateResumeLayout sets the LayoutSuspended flag to false if it were true.
                //
                UIElement.PropagateResumeLayout(null, element);
                element.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
                element.Arrange(new Rect(element.DesiredSize));
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:19,代码来源:VisualBrush.cs

示例14: CreateCursor

        public static Cursor CreateCursor(UIElement element, int xHotSpot, int yHotSpot,bool isTransparent)
        {
            try
            {
                element.Measure(new Size(double.PositiveInfinity,
                                double.PositiveInfinity));
                element.Arrange(new Rect(0, 0, element.DesiredSize.Width,
                  element.DesiredSize.Height));

                RenderTargetBitmap rtb =
                  new RenderTargetBitmap((int)element.DesiredSize.Width,
                    (int)element.DesiredSize.Height, 96, 96,
                    PixelFormats.Pbgra32);
                rtb.Render(element);

                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(rtb));

                MemoryStream ms = new MemoryStream();
                encoder.Save(ms);

                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);



                if (isTransparent)
                {

                    System.Drawing.Color backColor = bmp.GetPixel(1, 1);
                    bmp.MakeTransparent(backColor);
                }



                Cursor cur = InternalCreateCursor(bmp, xHotSpot, yHotSpot);

                ms.Close();
                ms.Dispose();


                //VictorDEBUG
                bmp.Dispose();

                return cur;
            }
            catch
            {
            }
            return null;

        }
开发者ID:ohadmanor,项目名称:TDS,代码行数:51,代码来源:CursorHelper.cs

示例15: Arrange

			public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
			{
				adorner.Arrange(new Rect(p.X, p.Y, adornedElementSize.Width, adornedElementSize.Height));
			}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:4,代码来源:PointThumb.cs


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