本文整理汇总了C#中System.Windows.Controls.Grid.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.EndInit方法的具体用法?C# Grid.EndInit怎么用?C# Grid.EndInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Grid
的用法示例。
在下文中一共展示了Grid.EndInit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMappedLayerWeights
public ScrollViewer GetMappedLayerWeights()
{
WrapPanel panel = new WrapPanel();
panel.BeginInit();
panel.UseLayoutRounding = true;
panel.SnapsToDevicePixels = true;
panel.Orientation = Orientation.Horizontal;
panel.HorizontalAlignment = HorizontalAlignment.Stretch;
panel.VerticalAlignment = VerticalAlignment.Stretch;
for (int map = 0; map < MapCount; map++)
{
Grid grid = new Grid();
grid.SnapsToDevicePixels = true;
grid.UseLayoutRounding = true;
grid.Background = System.Windows.Media.Brushes.White;
grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
grid.Width = double.NaN;
grid.Height = double.NaN;
grid.Margin = new Thickness(4);
for (int col = 0; col < MapWidth; col++)
{
ColumnDefinition colDef = new ColumnDefinition();
colDef.Width = new GridLength(0, GridUnitType.Auto);
grid.ColumnDefinitions.Add(colDef);
}
for (int row = 0; row < MapHeight; row++)
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(0, GridUnitType.Auto);
grid.RowDefinitions.Add(rowDef);
}
double weightMin = Weights.Min(weight => weight.Value);
double weightMax = Weights.Max(weight => weight.Value);
double range = GetRangeFactor(weightMin, weightMax);
grid.BeginInit();
for (int y = 0; y < ReceptiveFieldWidth; y++)
{
for (int x = 0; x < ReceptiveFieldHeight; x++)
{
int index = x + (y * ReceptiveFieldWidth) + (map * ((ReceptiveFieldWidth * ReceptiveFieldHeight) + 1));
System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
rectangle.BeginInit();
rectangle.SnapsToDevicePixels = true;
rectangle.UseLayoutRounding = true;
rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
ToolTip tip = new ToolTip();
tip.Content = Weights[index].Value.ToString("N17", CultureInfo.CurrentUICulture);
rectangle.ToolTip = tip;
rectangle.VerticalAlignment = VerticalAlignment.Stretch;
rectangle.Margin = new Thickness(0);
rectangle.Height = 8;
rectangle.Width = 8;
rectangle.Stretch = Stretch.Uniform;
rectangle.Fill = GetBrushFromRange(range, weightMin, weightMax, Weights[index].Value);
rectangle.EndInit();
Grid.SetColumn(rectangle, x);
Grid.SetRow(rectangle, y);
grid.Children.Add(rectangle);
tip = null;
rectangle = null;
}
};
grid.EndInit();
panel.Children.Add(grid);
}
panel.EndInit();
ScrollViewer scr = new ScrollViewer();
scr.BeginInit();
scr.SnapsToDevicePixels = true;
scr.UseLayoutRounding = true;
scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
scr.HorizontalContentAlignment = HorizontalAlignment.Left;
scr.VerticalContentAlignment = VerticalAlignment.Top;
scr.VerticalAlignment = VerticalAlignment.Stretch;
scr.HorizontalAlignment = HorizontalAlignment.Stretch;
scr.Content = panel;
scr.Height = double.NaN;
scr.Width = double.NaN;
scr.EndInit();
return (scr);
}
示例2: GetMappedLayerOutputs
public ScrollViewer GetMappedLayerOutputs()
{
WrapPanel panel = new WrapPanel();
panel.BeginInit();
panel.UseLayoutRounding = true;
panel.SnapsToDevicePixels = true;
panel.Orientation = Orientation.Horizontal;
panel.HorizontalAlignment = HorizontalAlignment.Stretch;
panel.VerticalAlignment = VerticalAlignment.Stretch;
for (int map = 0; map < MapCount; ++map)
{
Grid grid = new Grid();
grid.SnapsToDevicePixels = true;
grid.UseLayoutRounding = true;
grid.Background = System.Windows.Media.Brushes.White;
grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
grid.Width = double.NaN;
grid.Height = double.NaN;
grid.Margin = new Thickness(4);
for (int col = 0; col < MapWidth; col++)
{
ColumnDefinition colDef = new ColumnDefinition();
colDef.Width = new GridLength(0, GridUnitType.Auto);
grid.ColumnDefinitions.Add(colDef);
}
for (int row = 0; row < MapHeight; row++)
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(0, GridUnitType.Auto);
grid.RowDefinitions.Add(rowDef);
}
grid.BeginInit();
for (int y = 0; y < MapHeight; y++)
{
for (int x = 0; x < MapWidth; x++)
{
int index = x + (y * MapWidth) + (map * MapWidth * MapHeight);
byte color = (byte)(255 - ((Neurons[index].Output + 1D) * 127D));
System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(color, color, color));
brush.Freeze();
System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
rectangle.BeginInit();
rectangle.SnapsToDevicePixels = true;
rectangle.UseLayoutRounding = true;
rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
ToolTip tip = new ToolTip();
tip.Content = Neurons[index].Output.ToString("N17", CultureInfo.CurrentUICulture);
rectangle.ToolTip = tip;
rectangle.VerticalAlignment = VerticalAlignment.Stretch;
rectangle.Margin = new Thickness(0);
rectangle.Height = 8;
rectangle.Width = 8;
rectangle.Stretch = Stretch.Uniform;
rectangle.Fill = brush;
rectangle.EndInit();
Grid.SetColumn(rectangle, x);
Grid.SetRow(rectangle, y);
grid.Children.Add(rectangle);
brush = null;
tip = null;
rectangle = null;
}
}
grid.EndInit();
panel.Children.Add(grid);
}
panel.EndInit();
ScrollViewer scr = new ScrollViewer();
scr.BeginInit();
scr.SnapsToDevicePixels = true;
scr.UseLayoutRounding = true;
scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
scr.HorizontalContentAlignment = HorizontalAlignment.Left;
scr.VerticalContentAlignment = VerticalAlignment.Top;
scr.VerticalAlignment = VerticalAlignment.Stretch;
scr.HorizontalAlignment = HorizontalAlignment.Stretch;
scr.Content = panel;
scr.Height = double.NaN;
scr.Width = double.NaN;
scr.EndInit();
return (scr);
}
示例3: ResizeRows
//.........这里部分代码省略.........
starRowsAvailableHeight -=
rowDefinition.ActualHeight;
}
}
}
if (upperRowGridUnitType == GridUnitType.Star)
{
if (lowerRowGridUnitType == GridUnitType.Star)
{
// If both rows are star rows
// - totalStarRowsHeight won't change and
// as much as one of the rows grows
// - the other row will shrink by the same value.
// If there is no width available to star rows
// - we can't resize two of them.
if (starRowsAvailableHeight < 1)
{
return;
}
var oldStarHeight = upperRowDefinition.Height.Value;
var newStarHeight = Math.Max(
0,
totalStarRowsHeight * newUpperRowActualHeight /
starRowsAvailableHeight);
upperRowDefinition.Height =
new GridLength(newStarHeight, GridUnitType.Star);
lowerRowDefinition.Height =
new GridLength(
Math.Max(
0,
lowerRowDefinition.Height.Value -
newStarHeight + oldStarHeight),
GridUnitType.Star);
}
else
{
var newStarRowsAvailableHeight =
starRowsAvailableHeight +
lowerRowActualHeight -
newLowerRowActualHeight;
if (newStarRowsAvailableHeight - newUpperRowActualHeight >= 1)
{
var newStarHeight = Math.Max(
0,
(totalStarRowsHeight -
upperRowDefinition.Height.Value) *
newUpperRowActualHeight /
(newStarRowsAvailableHeight - newUpperRowActualHeight));
upperRowDefinition.Height =
new GridLength(newStarHeight, GridUnitType.Star);
}
}
}
else
{
upperRowDefinition.Height =
new GridLength(
newUpperRowActualHeight, GridUnitType.Pixel);
}
if (lowerRowGridUnitType ==
GridUnitType.Star)
{
if (upperRowGridUnitType !=
GridUnitType.Star)
{
var newStarRowsAvailableHeight =
starRowsAvailableHeight +
upperRowActualHeight -
newUpperRowActualHeight;
if (newStarRowsAvailableHeight - newLowerRowActualHeight >= 1)
{
var newStarHeight = Math.Max(
0,
(totalStarRowsHeight -
lowerRowDefinition.Height.Value) *
newLowerRowActualHeight /
(newStarRowsAvailableHeight - newLowerRowActualHeight));
lowerRowDefinition.Height =
new GridLength(newStarHeight, GridUnitType.Star);
}
}
// else handled in the upper row width calculation block
}
else
{
lowerRowDefinition.Height =
new GridLength(
newLowerRowActualHeight, GridUnitType.Pixel);
}
grid.EndInit();
}
示例4: GenerateFixedDocument
public void GenerateFixedDocument(bool InPrintMode)
{
PrintDocument = new FixedDocument();
int RowsOnPage = 100;
PageSupplemental oSupplemental = new PageSupplemental(Configuration);
PageDefinition def = definition;
//Verteilung auf mehreren Seiten?
GenerateRanges();
int RowsOnFirstPage = CalculateRowsOnPage(ref RowsOnPage, def);
UpdatePages();
int from = PageSelectionFrom;
int until = PageSelectionUntil;
if (AllPages | !InPrintMode)
{ from = 1; until = maxPages; }
ProgressContext.Init(Properties.Resources.prgSeiten, (until - from + 1));
PrintDocument.DocumentPaginator.PageSize = def.PageSize;
for (int i = from; i <= until; i++)
{
for (int x = 1; x <= ColRanges.Count; x++)
{
oTable = new Grid();
oTable.BeginInit();
ProgressContext.UpdateProgress(i - from + x);
if (ProgressContext.Canceled)
{
ProgressContext.Finish();
return;
}
offset = x - 1;
PageContent oPage = new PageContent();
FixedPage oFixed = CreatePage();
int RowsUntil = Math.Min((i - 1) * RowsOnPage + RowsOnFirstPage, oData.Rows.Count);
int RowsFrom = (i - 2) * RowsOnPage + RowsOnFirstPage;
if (RowsFrom < 0)
RowsFrom = 0;
GenerateRows(RowsFrom, RowsUntil);
oTable.Width = def.ContentSize.Width;
oTable.Margin = new Thickness(def.ContentOrigin.X, def.ContentOrigin.Y, 0, 0);
oTable.EndInit();
oFixed.Children.Add(oTable);
FrameworkElement oHeader = oSupplemental.PageHeader();
oHeader.Width = def.ContentSize.Width;
oHeader.Margin = new Thickness(def.HeaderRect.Left, def.HeaderRect.Top, 0, 0);
oFixed.Children.Add(oHeader);
string currentpage = Convert.ToString(((int)i));
if (ColRanges.Count > 1)
currentpage = currentpage.AddLetter(x);
FrameworkElement oFooter = oSupplemental.PageFooter(currentpage, Maximum);
oFooter.Margin = new Thickness(def.FooterRect.Left, def.FooterRect.Top, 0, 0);
oFooter.Width = def.ContentSize.Width;
oFixed.Children.Add(oFooter);
oFixed.Measure(def.PageSize);
oFixed.Arrange(new Rect(new Point(), def.PageSize));
oFixed.UpdateLayout();
((IAddChild)oPage).AddChild(oFixed);
PrintDocument.Pages.Add(oPage);
}
}
ticket.PageBorderless = PageBorderless.Borderless;
oTable = null;
ProgressContext.Finish();
NotifyPropertyChanged("PrintDocument");
NotifyPropertyChanged("Maximum");
NotifyPropertyChanged("PageSelectionFrom");
NotifyPropertyChanged("PageSelectionUntil");
}
示例5: ResizeColumns
//.........这里部分代码省略.........
starColumnsAvailableWidth -=
columnDefinition.ActualWidth;
}
}
}
if (leftColumnGridUnitType == GridUnitType.Star)
{
if (rightColumnGridUnitType == GridUnitType.Star)
{
// If both columns are star columns
// - totalStarColumnsWidth won't change and
// as much as one of the columns grows
// - the other column will shrink by the same value.
// If there is no width available to star columns
// - we can't resize two of them.
if (starColumnsAvailableWidth < 1)
{
return;
}
var oldStarWidth = leftColumnDefinition.Width.Value;
var newStarWidth = Math.Max(
0,
totalStarColumnsWidth * newLeftColumnActualWidth /
starColumnsAvailableWidth);
leftColumnDefinition.Width =
new GridLength(newStarWidth, GridUnitType.Star);
rightColumnDefinition.Width =
new GridLength(
Math.Max(
0,
rightColumnDefinition.Width.Value -
newStarWidth + oldStarWidth),
GridUnitType.Star);
}
else
{
var newStarColumnsAvailableWidth =
starColumnsAvailableWidth +
rightColumnActualWidth -
newRightColumnActualWidth;
if (newStarColumnsAvailableWidth - newLeftColumnActualWidth >= 1)
{
var newStarWidth = Math.Max(
0,
(totalStarColumnsWidth -
leftColumnDefinition.Width.Value) *
newLeftColumnActualWidth /
(newStarColumnsAvailableWidth - newLeftColumnActualWidth));
leftColumnDefinition.Width =
new GridLength(newStarWidth, GridUnitType.Star);
}
}
}
else
{
leftColumnDefinition.Width =
new GridLength(
newLeftColumnActualWidth, GridUnitType.Pixel);
}
if (rightColumnGridUnitType ==
GridUnitType.Star)
{
if (leftColumnGridUnitType !=
GridUnitType.Star)
{
var newStarColumnsAvailableWidth =
starColumnsAvailableWidth +
leftColumnActualWidth -
newLeftColumnActualWidth;
if (newStarColumnsAvailableWidth - newRightColumnActualWidth >= 1)
{
var newStarWidth = Math.Max(
0,
(totalStarColumnsWidth -
rightColumnDefinition.Width.Value) *
newRightColumnActualWidth /
(newStarColumnsAvailableWidth - newRightColumnActualWidth));
rightColumnDefinition.Width =
new GridLength(newStarWidth, GridUnitType.Star);
}
}
// else handled in the left column width calculation block
}
else
{
rightColumnDefinition.Width =
new GridLength(
newRightColumnActualWidth, GridUnitType.Pixel);
}
grid.EndInit();
}