本文整理汇总了C#中System.Windows.Controls.Border.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# Border.Measure方法的具体用法?C# Border.Measure怎么用?C# Border.Measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Border
的用法示例。
在下文中一共展示了Border.Measure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderFrame
protected override BitmapSource RenderFrame(DataRect dataRect, Rect output)
{
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
TextBlock lt = new TextBlock
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
Text = String.Format("({0},{1})", dataRect.XMin, dataRect.YMax)
};
grid.Children.Add(lt);
Grid.SetRow(lt, 0);
TextBlock rb = new TextBlock
{
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
Text = String.Format("({0},{1})", dataRect.XMax, dataRect.YMin)
};
grid.Children.Add(rb);
Grid.SetRow(rb, 1);
Border border = new Border();
border.BorderThickness = new Thickness(3);
border.BorderBrush = Brushes.Blue;
border.Child = grid;
RenderTargetBitmap rtb = new RenderTargetBitmap((int)output.Width, (int)output.Height, 96, 96, PixelFormats.Default);
border.Measure(new Size(output.Width, output.Height));
border.Arrange(output);
rtb.Render(border);
Thread.Sleep(1000);
return rtb;
}
示例2: SearchToolTipAdorner
public SearchToolTipAdorner(UIElement adornedElement, DesignerView designerView, string text)
: base(adornedElement)
{
this.scrollViewerToScreenDistance = designerView.ScrollViewer.PointToScreen(new Point(0, 0)).Y;;
tooltip = new Border
{
Background = new SolidColorBrush(WorkflowDesignerColors.DesignerViewBackgroundColor),
BorderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBorderColor),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(4),
Margin = new Thickness(10),
Child = new TextBlock
{
Foreground = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor),
Margin = new Thickness(4, 0, 4, 0),
MaxWidth = 300,
Text = text,
TextWrapping = TextWrapping.Wrap,
TextTrimming = TextTrimming.CharacterEllipsis
},
Effect = new DropShadowEffect
{
Color = Colors.Black,
BlurRadius = 4,
Opacity = 0.5
},
};
tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
}
示例3: BorderHitTestTest
public void BorderHitTestTest()
{
Border border = new Border
{
Width = 200,
Height = 100,
BorderThickness = new Thickness(10, 20, 30, 40),
IsRootElement = true,
};
border.Measure(Size.Infinity);
border.Arrange(new Rect(border.DesiredSize));
BackgroundHitTestTest(border, null);
BorderHitTestTest(border, null);
border.Background = Brushes.Transparent;
border.BorderBrush = null;
BackgroundHitTestTest(border, border);
BorderHitTestTest(border, border);
border.Background = null;
border.BorderBrush = Brushes.Transparent;
BackgroundHitTestTest(border, null);
BorderHitTestTest(border, border);
border.Background = Brushes.Transparent;
border.BorderBrush = Brushes.Transparent;
BackgroundHitTestTest(border, border);
BorderHitTestTest(border, border);
}
示例4: ChildlessMeasureTest1
public void ChildlessMeasureTest1 ()
{
Border c = new Border ();
Size s = new Size (10,10);
c.Measure (s);
Assert.AreEqual (new Size (0,0), c.DesiredSize, "DesiredSize");
}
示例5: ChildlessMeasureTest2
public void ChildlessMeasureTest2 ()
{
Border c = new Border ();
Size s = new Size (10,10);
c.Width = 20;
c.Height = 20;
c.Measure (s);
Assert.AreEqual (new Size (10,10), c.DesiredSize, "DesiredSize");
}
示例6: GetPage
public override DocumentPage GetPage(int pageNumber)
{
var page = _pages[pageNumber];
var container = new Border();
container.Padding = _margin;
container.Child = page;
container.Measure(PageSize);
container.Arrange(new Rect(PageSize));
return new DocumentPage(container);
}
示例7: GetThumbnailImage
public static BitmapSource GetThumbnailImage(this BitmapSource source, double percent, double dpiX, double dpiY)
{
double width = source.PixelWidth, height = source.PixelHeight;
Algorithm.Math.ToPercentSize(percent, ref width, ref height);
RenderTargetBitmap bmp = new RenderTargetBitmap((int)width, (int)height,
dpiX, dpiY, PixelFormats.Pbgra32);
Border image = new Border();
image.RenderSize = new Size(width, height);
image.Background = new ImageBrush(source);
image.Measure(new Size(width, height));
image.Arrange(new Rect(new Size(width, height)));
bmp.Render(image);
return BitmapFrame.Create(bmp);
}
示例8: 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");
}
示例9: MouseDeviceButtonTest
public void MouseDeviceButtonTest()
{
Border element = new Border { Background = Brushes.Transparent, Width = 100, Height = 100, IsRootElement = true };
element.Measure(Size.Infinity);
element.Arrange(new Rect(element.DesiredSize));
int eventIndex = 0;
int previewMouseDownIndex = 0;
int previewMouseUpIndex = 0;
int mouseDownIndex = 0;
int mouseUpIndex = 0;
element.PreviewMouseDown += (sender, e) => previewMouseDownIndex = ++eventIndex;
element.PreviewMouseUp += (sender, e) => previewMouseUpIndex = ++eventIndex;
element.MouseDown += (sender, e) => mouseDownIndex = ++eventIndex;
element.MouseUp += (sender, e) => mouseUpIndex = ++eventIndex;
TestPresentationSource presentationSource = new TestPresentationSource();
presentationSource.RootElement = element;
MouseDevice mouseDevice = new MouseDevice(presentationSource);
mouseDevice.Activate();
mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Pressed, new Point(10, 10), 0));
Assert.AreEqual(MouseButtonState.Pressed, mouseDevice.GetButtonState(MouseButton.Left));
Assert.AreEqual(1, previewMouseDownIndex);
Assert.AreEqual(2, mouseDownIndex);
mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Released, new Point(10, 10), 0));
Assert.AreEqual(MouseButtonState.Released, mouseDevice.GetButtonState(MouseButton.Left));
Assert.AreEqual(3, previewMouseUpIndex);
Assert.AreEqual(4, mouseUpIndex);
mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Pressed, new Point(10, 10), 0));
Assert.AreEqual(MouseButtonState.Pressed, mouseDevice.GetButtonState(MouseButton.Left));
Assert.AreEqual(5, previewMouseDownIndex);
Assert.AreEqual(6, mouseDownIndex);
mouseDevice.Deactivate();
Assert.AreEqual(MouseButtonState.Released, mouseDevice.GetButtonState(MouseButton.Left));
Assert.AreEqual(7, previewMouseUpIndex);
Assert.AreEqual(8, mouseUpIndex);
}
示例10: MeasureRectangleBorderTest1_1
public void MeasureRectangleBorderTest1_1 ()
{
// This is the same as the above test but has
Border b = new Border ();
Path p = new Path ();
b.Child = p;
p.Fill = new SolidColorBrush (Colors.Black);
RectangleGeometry r = new RectangleGeometry ();
r.Rect = new Rect (10, 10, 20, 20);
p.Data = r;
b.Measure (new Size (50, 50));
b.Arrange (new Rect (0, 0, 50, 50));
Assert.AreEqual (new Size (30,30), b.DesiredSize, "b desired");
Assert.AreEqual (new Size (30,30), p.DesiredSize, "p desired");
Assert.AreEqual (new Size (50,50), b.RenderSize, "b RenderSize");
Assert.AreEqual (new Size (50,50), p.RenderSize, "p RenderSize");
}
示例11: MeasureRectangleBorderTest1
public void MeasureRectangleBorderTest1 ()
{
// See 1_1 1_2 for demonstation of this as a measure invalidation bug.
Border b = new Border ();
Path p = new Path ();
p.Fill = new SolidColorBrush (Colors.Black);
RectangleGeometry r = new RectangleGeometry ();
r.Rect = new Rect (10, 10, 20, 20);
p.Data = r;
b.Child = p;
b.Measure (new Size (50, 50));
b.Arrange (new Rect (0, 0, 50, 50));
Assert.AreEqual (new Size (0,0), b.DesiredSize, "b desired");
Assert.AreEqual (new Size (50,50), b.RenderSize, "b RenderSize");
Assert.AreEqual (new Size (0,0), p.DesiredSize, "p DesiredSize");
Assert.AreEqual (new Size (50,50), p.RenderSize, "p RenderSize");
}
示例12: 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");
}
示例13: BorderRenderTest
public void BorderRenderTest()
{
Brush backgroundBrush = new LinearGradientBrush(30, Colors.Blue, Colors.Green);
Brush borderBrush = new LinearGradientBrush(-30, Colors.Red, Colors.Blue);
Thickness borderThickness = new Thickness(10, 20, 30, 40);
Border border = new Border
{
Child = new FrameworkElement { Width = 200, Height = 100 },
Background = backgroundBrush,
BorderBrush = borderBrush,
BorderThickness = borderThickness,
};
border.Measure(Size.Infinity);
border.Arrange(new Rect(border.DesiredSize));
IRenderElementFactory factory = TestRenderElementFactory.Default;
border.GetRenderElement(factory);
Assert.AreEqual(new Rect(240, 160), border.GetRenderElement(factory).Bounds);
Assert.AreEqual(2, border.GetRenderElement(factory).Children.Count());
IBorderRenderElement borderRenderElement = border.GetRenderElement(factory).Children.ElementAt(0) as IBorderRenderElement;
Assert.IsNotNull(borderRenderElement);
Assert.AreEqual(backgroundBrush, borderRenderElement.Background);
Assert.AreEqual(borderBrush, borderRenderElement.BorderBrush);
Assert.AreEqual(borderThickness, borderRenderElement.BorderThickness);
Assert.AreEqual(new Rect(240, 160), borderRenderElement.Bounds);
IVisualRenderElement visualRenderElement = border.GetRenderElement(factory).Children.ElementAt(1) as IVisualRenderElement;
Assert.IsNotNull(visualRenderElement);
Assert.AreEqual(new Rect(10, 20, 200, 100), visualRenderElement.Bounds);
border.Child = null;
Assert.AreEqual(1, border.GetRenderElement(factory).Children.Count());
}
示例14: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
Transform transform = isTextRightToLeft ? new MatrixTransform(-1, 0, 0, 1, 0, 0) : Transform.Identity;
Border tooltip = new Border
{
Background = new SolidColorBrush(Colors.White),
BorderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBorderColor),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(4),
Margin = new Thickness(10),
Child = new TextBlock
{
Margin = new Thickness(4, 0, 4, 0),
MaxHeight = 100,
Text = expressionString,
},
Effect = new DropShadowEffect
{
Color = Colors.Black,
BlurRadius = 4,
Opacity = 0.5
},
RenderTransform = transform
};
tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
VisualBrush brush = new VisualBrush()
{
Visual = tooltip
};
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
Rect tooltipRect = new Rect(adornedElementRect.TopLeft + new Vector(adornedElementRect.Width, -tooltip.DesiredSize.Height), tooltip.DesiredSize);
Pen renderPen = new Pen();
drawingContext.DrawRectangle(brush, renderPen, tooltipRect);
}
示例15: UpdateShadow
//.........这里部分代码省略.........
Cylinder cylinder = new Cylinder(begin, end, radius);
container.Children.Add(cylinder);
}
}
}
}
#endregion
}
// Get bounding box
Rect3D boundingBox = VisualTreeHelper.GetDescendantBounds(container);
if (boundingBox.IsEmpty)
{
shadowRefreshStarted = false;
return;
}
#region Render Shadow
const double blurSize = 25;
const int renderTargetWidth = 200;
int renderTargetHeight = (int)(200.0 * (boundingBox.SizeX / boundingBox.SizeY));
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(renderTargetWidth, renderTargetHeight, 96, 96, PixelFormats.Pbgra32);
Viewport3D shadowViewport3D = new Viewport3D();
Border border = new Border();
border.Padding = new Thickness(blurSize);
border.Child = shadowViewport3D;
// Change size of the visualizer
border.Width = renderTargetBitmap.PixelWidth;
border.Height = renderTargetBitmap.PixelHeight;
border.Measure(new Size(renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight));
border.Arrange(new Rect(0, 0, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight));
shadowViewport3D.Children.Add(container);
// Create camera
OrthographicCamera orthographicCamera = new OrthographicCamera();
#region Accomodate camera to fit content
orthographicCamera.Position = new Point3D(boundingBox.Location.X + boundingBox.SizeX / 2.0,
boundingBox.Location.Y,
boundingBox.Location.Z + boundingBox.SizeZ / 2.0);
orthographicCamera.LookDirection = new Vector3D(0, 1, 0);
orthographicCamera.UpDirection = new Vector3D(-1, 0, 0);
orthographicCamera.Width = boundingBox.SizeZ;
#endregion
orthographicCamera.NearPlaneDistance = 0;
// Set the camera & correct lights
shadowViewport3D.Camera = orthographicCamera;
BlurEffect blurEffect = new BlurEffect();
blurEffect.Radius = blurSize;
border.Effect = blurEffect;
renderTargetBitmap.Render(border);
renderTargetBitmap.Freeze();
#endregion