本文整理汇总了C#中System.Windows.Shapes.Rectangle.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Measure方法的具体用法?C# Rectangle.Measure怎么用?C# Rectangle.Measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Measure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScreenshot
/// <summary>Creates the screenshot of entire plotter element</summary>
/// <returns></returns>
internal static BitmapSource CreateScreenshot(UIElement uiElement, Int32Rect screenshotSource)
{
Window window = Window.GetWindow(uiElement);
if (window == null)
{
return CreateElementScreenshot(uiElement);
}
Size size = window.RenderSize;
//double dpiCoeff = 32 / SystemParameters.CursorWidth;
//int dpi = (int)(dpiCoeff * 96);
double dpiCoeff = 1;
int dpi = 96;
RenderTargetBitmap bmp = new RenderTargetBitmap(
(int)(size.Width * dpiCoeff), (int)(size.Height * dpiCoeff),
dpi, dpi, PixelFormats.Default);
// white background
Rectangle whiteRect = new Rectangle { Width = size.Width, Height = size.Height, Fill = Brushes.White };
whiteRect.Measure(size);
whiteRect.Arrange(new Rect(size));
bmp.Render(whiteRect);
// the very element
bmp.Render(uiElement);
CroppedBitmap croppedBmp = new CroppedBitmap(bmp, screenshotSource);
return croppedBmp;
}
示例2: MeasureTest1
public void MeasureTest1 ()
{
Rectangle r = new Rectangle ();
r.Width = 10;
r.Height = 20;
r.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), r.DesiredSize);
}
示例3: MeasureTest2
public void MeasureTest2 ()
{
Canvas c = new Canvas ();
Rectangle r = new Rectangle ();
r.Width = 10;
r.Height = 20;
r.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), r.DesiredSize);
c.Children.Add (r);
r.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), r.DesiredSize);
c.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), c.DesiredSize, "Canvas desired");
Assert.AreEqual (new Size (0, 0), r.DesiredSize, "Rectangle desired");
}
示例4: MeasureTest3
public void MeasureTest3 ()
{
Border c = new Border ();
Rectangle r = new Rectangle ();
r.Width = 10;
r.Height = 20;
r.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), r.DesiredSize);
c.Child = r;
c.Measure (new Size (50, 50));
Assert.AreEqual (new Size (10, 20), c.DesiredSize, "Border desired");
Assert.AreEqual (new Size (10, 20), r.DesiredSize, "Rectangle desired");
}
示例5: MeasureTest2_1
public void MeasureTest2_1 ()
{
Border b = new Border ();
Canvas c = new Canvas ();
Rectangle r = new Rectangle ();
r.Width = 10;
r.Height = 20;
r.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), r.DesiredSize);
b.Child = c;
c.Children.Add (r);
b.Width = 20;
b.Height = 10;
b.Measure (new Size (50, 50));
Assert.AreEqual (new Size (0, 0), c.DesiredSize, "Canvas desired");
Assert.AreEqual (new Size (0, 0), r.DesiredSize, "Rectangle desired");
Assert.AreEqual (new Size (20, 10), b.DesiredSize, "Border desired");
}
示例6: Apply
static void Apply(Shader shader, BitmapImage bitmap, string destImage)
{
Rectangle r = new Rectangle ();
r.Effect = shader;
shader.Input = new ImageBrush (bitmap);
/*The fill brush is ignored due to the effect been applied*/
r.Fill = new SolidColorBrush (Colors.Aquamarine);
Size size = new Size (bitmap.PixelWidth, bitmap.PixelHeight);
r.Measure (size);
r.Arrange (new Rect (size));
RenderTargetBitmap render = new RenderTargetBitmap (
bitmap.PixelWidth,
bitmap.PixelHeight,
96,
96,
PixelFormats.Pbgra32);
render.Render (r);
PngBitmapEncoder png = new PngBitmapEncoder ();
png.Frames.Add (BitmapFrame.Create (render));
using (Stream stm = File.Open (destImage, FileMode.OpenOrCreate)) {
png.Save (stm);
}
}
示例7: CreateHeatMap
protected override void CreateHeatMap()
{
intensityMap = new RenderTargetBitmap(500, 500, 96, 96, PixelFormats.Pbgra32);
AddativeBlendClear cleareffect = new AddativeBlendClear();
cleareffect.ClearColor = Color.FromArgb(0x01, 0xFF, 0xFF, 0xFF);
ClearIntensityMap();
Size sz = new Size(intensityMap.PixelWidth, intensityMap.PixelHeight);
// Create the clear rectangle, we need this to render a fade pass.
clearRectangle = new Rectangle();
clearRectangle.Fill = new ImageBrush(intensityMap);
clearRectangle.Effect = cleareffect;
clearRectangle.Measure(sz);
clearRectangle.Arrange(new Rect(sz));
// Connect the intensity map containing our heat to our image.
HeatMapImage.Source = intensityMap;
}
示例8: 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);
Size elementSize = uiElement.DesiredSize;
// white background
Rectangle whiteRect = new Rectangle { Width = elementSize.Width, Height = elementSize.Height, Fill = Brushes.White };
whiteRect.Measure(elementSize);
whiteRect.Arrange(new Rect(elementSize));
bmp.Render(whiteRect);
bmp.Render(uiElement);
return bmp;
}
示例9: SquaredArrow
public SquaredArrow()
{
Rectangle r = new Rectangle();
r.Measure(new Size(100, 100));
r.Arrange(new Rect(0, 0, 100, 100));
}