本文整理汇总了C#中Rect.WithHeight方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.WithHeight方法的具体用法?C# Rect.WithHeight怎么用?C# Rect.WithHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect.WithHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrangeOverride
/// <inheritdoc/>
protected override Size ArrangeOverride(Size arrangeSize)
{
double left = 0.0;
double top = 0.0;
double right = 0.0;
double bottom = 0.0;
// Arrange each of the Children
var children = Children;
int dockedCount = children.Count - (LastChildFill ? 1 : 0);
int index = 0;
foreach (Control element in children)
{
// Determine the remaining space left to arrange the element
Rect remainingRect = new Rect(
left,
top,
Math.Max(0.0, arrangeSize.Width - left - right),
Math.Max(0.0, arrangeSize.Height - top - bottom));
// Trim the remaining Rect to the docked size of the element
// (unless the element should fill the remaining space because
// of LastChildFill)
if (index < dockedCount)
{
Size desiredSize = element.DesiredSize;
switch (GetDock(element))
{
case Dock.Left:
left += desiredSize.Width;
remainingRect = remainingRect.WithWidth(desiredSize.Width);
break;
case Dock.Top:
top += desiredSize.Height;
remainingRect = remainingRect.WithHeight(desiredSize.Height);
break;
case Dock.Right:
right += desiredSize.Width;
remainingRect = new Rect(
Math.Max(0.0, arrangeSize.Width - right),
remainingRect.Y,
desiredSize.Width,
remainingRect.Height);
break;
case Dock.Bottom:
bottom += desiredSize.Height;
remainingRect = new Rect(
remainingRect.X,
Math.Max(0.0, arrangeSize.Height - bottom),
remainingRect.Width,
desiredSize.Height);
break;
}
}
element.Arrange(remainingRect);
index++;
}
return arrangeSize;
}
示例2: DrawTreeView
public void DrawTreeView(Rect bounds, TreeViewModel viewModel, Action<Vector2, IItem> itemClicked,
Action<Vector2, IItem> itemRightClicked = null)
{
var boundY = bounds.height;
if (Event.current != null && Event.current.isKey && Event.current.rawType == EventType.KeyUp)
{
switch (Event.current.keyCode)
{
case KeyCode.UpArrow:
viewModel.MoveUp();
break;
case KeyCode.DownArrow:
viewModel.MoveDown();
break;
case KeyCode.RightArrow:
{
var selectedContainer = viewModel.SelectedData as ITreeItem;
if (selectedContainer != null)
{
selectedContainer.Expanded = true;
viewModel.IsDirty = true;
}
}
break;
case KeyCode.LeftArrow:
{
var selectedContainer = viewModel.SelectedData as ITreeItem;
if (selectedContainer != null)
{
selectedContainer.Expanded = false;
viewModel.IsDirty = true;
}
}
break;
case KeyCode.Return:
if(viewModel!= null)
viewModel.InvokeSubmit();
break;
default:
break;
}
}
// PlatformDrawer.DrawLabel(new Rect().WithSize(100,100).InnerAlignWithBottomRight(bounds),"Total height: {0}, Total Items: {1}");
var dirty = false;
var position = bounds;
var usedRect = position.WithWidth(Math.Max(bounds.width, PlatformDrawer.CalculateTextSize(viewModel.LargestString,CachedStyles.ListItemTitleStyle).x+5*viewModel.MaxIdentLevel)).Pad(0, 0, 15, 0).WithHeight(ItemHeight * viewModel.TreeData.Count(s => s.Visible));
PlatformDrawer.DrawStretchBox(position.PadSides(-1),CachedStyles.WizardListItemBoxStyle,10);
viewModel.Scroll = GUI.BeginScrollView(position, viewModel.Scroll, usedRect);
var itemTemplateRect = bounds.WithHeight(ItemHeight);
bool hasItems = false;
foreach (var treeViewItem in viewModel.TreeData)
{
if (!treeViewItem.Visible) continue;
hasItems = true;
var data = treeViewItem.Data;
var treeData = data as ITreeItem;
var itemRect = itemTemplateRect.Pad(5*treeViewItem.Indent, 0, 5*treeViewItem.Indent, 0);
var localItemY = itemRect.Translate(0, -position.yMin).y;
if (localItemY > (viewModel.Scroll.y + position.height)) break;
var imageRect = new Rect().WithSize(12, 12)
.Align(itemRect)
.AlignHorisonallyByCenter(itemRect)
.Translate(5, 0);
var labelRect =
itemRect.WithWidth(
PlatformDrawer.CalculateTextSize(treeViewItem.Data.Title, CachedStyles.BreadcrumbTitleStyle).x)
.Translate(25, 0);
if (treeViewItem == viewModel.ScrollTarget)
{
viewModel.Scroll = new Vector2(0, localItemY - ItemHeight * 5);
viewModel.ScrollToItem(null);
}
if (treeViewItem.Selected)
{
PlatformDrawer.DrawStretchBox(itemRect, CachedStyles.WizardSubBoxStyle, 14);
}
PlatformDrawer.DrawLabel(labelRect, treeViewItem.Data.Title, CachedStyles.ListItemTitleStyle);
PlatformDrawer.DrawImage(imageRect, treeViewItem.Icon, true);
if (treeViewItem.ColorMark.HasValue)
{
var colorMarkRect = new Rect().WithSize(8, 8).InnerAlignWithCenterRight(itemRect).Translate(-24,0);
PlatformDrawer.DrawRect(colorMarkRect,treeViewItem.ColorMark.Value);
}
if (viewModel.ShowToggle)
{
EditorGUI.BeginChangeCheck();
//.........这里部分代码省略.........