本文整理汇总了C#中UIElement.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.Arrange方法的具体用法?C# UIElement.Arrange怎么用?C# UIElement.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.Arrange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrangeChild
private void ArrangeChild(int itemIndex, UIElement child, Size finalSize) {
if (Tile) {
var num = CalculateChildrenPerRow(finalSize);
var num2 = itemIndex / num;
var num3 = itemIndex % num;
child.Arrange(new Rect(num3 * ChildHeight, num2 * ChildHeight, ChildHeight, ChildHeight));
}
else {
var width = CalculateChildWidth(finalSize);
var num5 = itemIndex / Columns;
var num6 = itemIndex % Columns;
child.Arrange(new Rect(num6 * width, num5 * ChildHeight, width, ChildHeight));
}
}
示例2: Arrange
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
{
adorner.Arrange(new Rect(column.Offset - GridRailAdorner.SplitterWidth / 2,
-(GridRailAdorner.RailSize + GridRailAdorner.RailDistance),
GridRailAdorner.SplitterWidth,
GridRailAdorner.RailSize + GridRailAdorner.RailDistance + adornedElementSize.Height));
}
示例3: ArrangeChild
private void ArrangeChild(int itemIndex, UIElement child, Size finalSize)
{
if (this.Tile)
{
int num = this.CalculateChildrenPerRow(finalSize);
int num2 = itemIndex / num;
int num3 = itemIndex % num;
child.Arrange(new Rect(num3 * this.ChildHeight, num2 * this.ChildHeight, this.ChildHeight, this.ChildHeight));
}
else
{
double width = this.CalculateChildWidth(finalSize);
int num5 = itemIndex / this.Columns;
int num6 = itemIndex % this.Columns;
child.Arrange(new Rect(num6 * width, num5 * this.ChildHeight, width, this.ChildHeight));
}
}
示例4: InvalidateArrange
private void InvalidateArrange(UIElement uiElement) {
if (plotter == null)
return;
var transform = plotter.Transform;
var childBounds = GetElementBounds(transform, uiElement);
uiElement.Arrange(childBounds);
}
示例5: PopupRoot
public PopupRoot(Point location, UIElement child)
{
this.PresentationSource = PlatformInterface.Instance.CreatePopupPresentationSource();
this.PresentationSource.RootVisual = this;
this.Child = child;
Size clientSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
child.Measure(clientSize);
child.Arrange(new Rect(child.DesiredSize));
this.PresentationSource.BoundingRect = new Rect(location, child.RenderSize);
this.PresentationSource.Show();
child.InvalidateVisual();
}
示例6: ArrangeChild
/// Position a child
private void ArrangeChild(int itemIndex, UIElement child, Size finalSize)
{
int childrenPerRow = CalculateChildrenPerRow(finalSize);
int row = itemIndex/childrenPerRow;
int column = itemIndex%childrenPerRow;
child.Arrange(new Rect(column*ChildWidth, row*ChildHeight, ChildWidth, ChildHeight));
}
示例7: ArrangeChild
private void ArrangeChild(UIElement child, double finalMainStart, double finalCrossStart, double finalMainLength, double finalCrossLength)
{
child.Arrange(Orientation == Orientation.Horizontal ?
new Rect(finalMainStart, finalCrossStart, finalMainLength.Max(0), finalCrossLength.Max(0)) :
new Rect(finalCrossStart, finalMainStart, finalCrossLength.Max(0), finalMainLength.Max(0)));
}
示例8: OptimizeSize
/// <summary>
/// Optimizes the size of a panel.
/// </summary>
/// <param name="panel">The panel to optimize.</param>
/// <param name="minWidth">The minimum width.</param>
/// <param name="maxWidth">The maximum width.</param>
/// <returns>The desired size.</returns>
private static double OptimizeSize(UIElement panel, double minWidth, double maxWidth)
{
double width;
// optimize size
for (width = minWidth; width < maxWidth; width += 50)
{
panel.Measure(new Size(width, width + 1));
if (panel.DesiredSize.Height <= width)
{
break;
}
}
panel.Arrange(new Rect(0, 0, width, width));
return width;
}
示例9: ArrangeChild
/// <summary>
/// Position a child
/// </summary>
/// <param name="itemIndex">The data item index of the child</param>
/// <param name="child">The element to position</param>
/// <param name="finalSize">The size of the panel</param>
private void ArrangeChild(int itemIndex, UIElement child, Size finalSize)
{
child.Arrange(GetChildRect(itemIndex, finalSize));
}
示例10: saveToJpg
public static void saveToJpg(UIElement source, string filename, String link, bool include_exif, int quality=100)
{
RenderOptions.SetEdgeMode(source, EdgeMode.Aliased);
RenderOptions.SetBitmapScalingMode(source, BitmapScalingMode.HighQuality);
source.SnapsToDevicePixels = true;
source.Measure(source.RenderSize);//new System.Windows.Size(source.RenderSize.Width, source.RenderSize.Height));
source.Arrange(new Rect(source.RenderSize));//new System.Windows.Rect(0.0, 0.0, 320.0, 240.0));
//RenderOptions.SetBitmapScalingMode(source, BitmapScalingMode.Linear);
RenderTargetBitmap rtbImage = new RenderTargetBitmap(CMSConfig.imagewidth,
CMSConfig.imageheight,
96,
96,
PixelFormats.Default);
rtbImage.Render(source);
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
/* String v = "http://radiodns1.ebu.ch/";
BitmapMetadata m = new BitmapMetadata("jpg");
//m.Comment = v; 37510
m.SetQuery("/app1/ifd/exif:{uint=270}", v);*/
//BitmapFrame outputFrame = BitmapFrame.Create(rtbImage, rtbImage, m, null);
int width = rtbImage.PixelWidth;
int height = rtbImage.PixelHeight;
int stride = width * ((rtbImage.Format.BitsPerPixel + 7) / 8);
byte[] bits = new byte[height * stride];
MemoryStream mem = new MemoryStream();
BitmapEncoder bitmapenc = new BmpBitmapEncoder();
bitmapenc.Frames.Add(BitmapFrame.Create(rtbImage));
bitmapenc.Save(mem);
Bitmap bmp1 = new Bitmap(mem);
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Compression;
System.Drawing.Imaging.Encoder myEncoder2 =
System.Drawing.Imaging.Encoder.Quality;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
EncoderParameters myEncoderParameters = new EncoderParameters(2);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 0L);
EncoderParameter myEncoderParameter2 = new EncoderParameter(myEncoder2, quality);
myEncoderParameters.Param[0] = myEncoderParameter;
myEncoderParameters.Param[1] = myEncoderParameter2;
bmp1.Save(filename, jgpEncoder, myEncoderParameters);
/*
BitmapFrame outputFrame = BitmapFrame.Create(rtbImage);
encoder.QualityLevel = quality;
encoder.Frames.Add(outputFrame);
*/
/*
try
{
using (FileStream file = File.OpenWrite(filename))
{
encoder.Save(file);
file.Close();
}
}
catch(Exception e)
{
Console.WriteLine("Error writting files\n"+e.Message);
}*/
}
示例11: SetElementLocation
protected void SetElementLocation(UIElement e, Rect finalRect, bool isAnimated)
{
// update the element's state
ElementState state = null;
if (states.ContainsKey(e))
{
state = states[e];
}
else
{
state = new ElementState(finalRect, this.Randomness);
states.Add(e, state);
}
// set the final rectangle and kick of the timer
if (isAnimated && IsAnimationEnabled)
{
if (!state.NeedsArrange)
{
state.NeedsArrange = true;
animatingCount++;
}
state.TargetRect = finalRect;
// make sure that the timer is running
StartTimer();
}
else
{
e.Arrange(finalRect);
state.CurrentRect = finalRect;
if (state.NeedsArrange)
{
state.NeedsArrange = false;
animatingCount--;
}
}
}
示例12: Arrange
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
{
Point p = _element.TranslatePoint(new Point(), panel.AdornedElement);
var rect = new Rect(p, _element.RenderSize);
rect.Inflate(3, 1);
adorner.Arrange(rect);
}
示例13: ArrangeChild
private void ArrangeChild(int itemIndex, UIElement child)
{
child.Arrange(new Rect(_itemPositionOffsets[itemIndex], 0, //_itemPositionOffsets[itemIndex] - HorizontalOffset, -VerticalOffset,
_itemPositionOffsets[itemIndex + 1] - _itemPositionOffsets[itemIndex], child.DesiredSize.Height));
}
示例14: TestNoInvalidation
public static void TestNoInvalidation(UIElement element, Action changeProperty)
{
element.Measure(Vector3.Zero);
element.Arrange(Vector3.Zero, false);
changeProperty();
Assert.IsTrue(element.IsMeasureValid);
Assert.IsTrue(element.IsArrangeValid);
}
示例15: ArrangeChild
/// <summary>
/// Method which arranges the give child
/// based on given arrange state.
///
/// Determines the start position of the child
/// based on its display index, frozen count of
/// datagrid, current horizontal offset etc.
/// </summary>
private void ArrangeChild(
UIElement child,
int displayIndex,
ArrangeState arrangeState)
{
Debug.Assert(child != null, "child cannot be null.");
double childWidth = 0.0;
IProvideDataGridColumn cell = child as IProvideDataGridColumn;
// Determine if this child was clipped in last arrange for the sake of frozen columns
if (child == _clippedChildForFrozenBehaviour)
{
arrangeState.OldClippedChild = child;
_clippedChildForFrozenBehaviour = null;
}
// Width determinition of the child to be arranged. It is
// display value if available else the ActualWidth
if (cell != null)
{
Debug.Assert(cell.Column != null, "column cannot be null.");
childWidth = cell.Column.Width.DisplayValue;
if (DoubleUtil.IsNaN(childWidth))
{
childWidth = cell.Column.ActualWidth;
}
}
else
{
childWidth = child.DesiredSize.Width;
}
Rect rcChild = new Rect(new Size(childWidth, arrangeState.ChildHeight));
// Determinition of start point for children to arrange. Lets say the there are 5 columns of which 2 are frozen.
// If the datagrid is scrolled horizontally. Following is the snapshot of arrange
/*
* *
*| <Cell3> | <Unarranged space> | <RowHeader> | <Cell1> | <Cell2> | <Right Clip of Cell4> | <Cell5> |*
* | <Visible region> |*
*/
if (displayIndex < arrangeState.FrozenColumnCount)
{
// For all the frozen children start from the horizontal offset
// and arrange increamentally
rcChild.X = arrangeState.NextFrozenCellStart;
arrangeState.NextFrozenCellStart += childWidth;
arrangeState.DataGridHorizontalScrollStartX += childWidth;
}
else
{
// For arranging non frozen children arrange which ever can be arranged
// from the start to horizontal offset. This would fill out the space left by
// frozen children. The next one child will be arranged and clipped accordingly past frozen
// children. The remaining children will arranged in the remaining space.
if (DoubleUtil.LessThanOrClose(arrangeState.NextNonFrozenCellStart, arrangeState.ViewportStartX))
{
if (DoubleUtil.LessThanOrClose(arrangeState.NextNonFrozenCellStart + childWidth, arrangeState.ViewportStartX))
{
rcChild.X = arrangeState.NextNonFrozenCellStart;
arrangeState.NextNonFrozenCellStart += childWidth;
}
else
{
double cellChoppedWidth = arrangeState.ViewportStartX - arrangeState.NextNonFrozenCellStart;
if (DoubleUtil.AreClose(cellChoppedWidth, 0.0))
{
rcChild.X = arrangeState.NextFrozenCellStart;
arrangeState.NextNonFrozenCellStart = arrangeState.NextFrozenCellStart + childWidth;
}
else
{
rcChild.X = arrangeState.NextFrozenCellStart - cellChoppedWidth;
double clipWidth = childWidth - cellChoppedWidth;
arrangeState.NewClippedChild = child;
_childClipForFrozenBehavior.Rect = new Rect(cellChoppedWidth, 0, clipWidth, rcChild.Height);
arrangeState.NextNonFrozenCellStart = arrangeState.NextFrozenCellStart + clipWidth;
}
}
}
else
{
rcChild.X = arrangeState.NextNonFrozenCellStart;
arrangeState.NextNonFrozenCellStart += childWidth;
}
}
child.Arrange(rcChild);
}