本文整理汇总了C#中Gwen.Control.Base.SizeToChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Base.SizeToChildren方法的具体用法?C# Base.SizeToChildren怎么用?C# Base.SizeToChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gwen.Control.Base
的用法示例。
在下文中一共展示了Base.SizeToChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAddRemoveButton
private Base CreateAddRemoveButton(Base parent, string labelText, int labelMaxWidth, int valueLabelMaxWidth, int minValue, int maxValue, Action onAdd, Action onRemove)
{
Base b = new Base(parent);
b.Dock = Pos.Top;
b.Padding = new Padding(0, 0, 0, 4);
//Base r = new Base(b);
//r.Dock = Pos.Right;
//r.Padding = new Padding(0, 0, 0, 0);
//Base l = new Base(b);
//l.Dock = Pos.Left;
//l.Padding = new Padding(0, 0, 0, 0);
Label label = new Label(b);
label.Text = labelText;
label.Dock = Pos.Left;
label.Padding = new Padding(0, 0, Math.Max(0, labelMaxWidth - label.Width), 0);
Label valueLabel = new Label(b);
valueLabel.Dock = Pos.Left;
valueLabel.Text = "0";
valueLabel.Padding = new Padding(Math.Max(0, valueLabelMaxWidth - valueLabel.Width), 0, 0, 0);
Button addButton = new Button(b);
addButton.Text = "+";
addButton.Height = 20;
addButton.Width = 20;
addButton.Dock = Pos.Right;
addButton.Released += (s, e) => onAdd();
addButton.Released += (s, e) => valueLabel.Text = Math.Min(maxValue, int.Parse(valueLabel.Text) + 1).ToString();
Button removeButton = new Button(b);
removeButton.Text = "-";
removeButton.Height = 20;
removeButton.Width = 20;
removeButton.Dock = Pos.Right;
removeButton.Released += (s, e) => onRemove();
removeButton.Released += (s, e) => valueLabel.Text = Math.Max(minValue, int.Parse(valueLabel.Text) - 1).ToString();
b.SizeToChildren();
return b;
}
示例2: CreateSliderOption
private Base CreateSliderOption(Base parent, string labelText, float min, float max, float value, string valueStringFormat, int labelMaxWidth, int valueLabelMaxWidth, Action<float> onChange)
{
Base b = new Base(parent);
b.Dock = Pos.Top;
b.Padding = new Padding(0, 0, 0, 4);
Label label = new Label(b);
label.Text = labelText;
label.Dock = Pos.Left;
label.Padding = new Padding(0, 0, Math.Max(0, labelMaxWidth - label.Width), 0);
Label valueLabel = new Label(b);
valueLabel.Dock = Pos.Right;
HorizontalSlider slider = new HorizontalSlider(b);
slider.Dock = Pos.Fill;
slider.Height = 20;
slider.Min = min;
slider.Max = max;
slider.Value = value;
slider.ValueChanged += (s, e) =>
{
int prevWidth = valueLabel.Width;
valueLabel.Text = slider.Value.ToString(valueStringFormat);
valueLabel.Padding = new Padding(valueLabel.Padding.Left - (valueLabel.Width - prevWidth), 0, 0, 0);
};
slider.ValueChanged += (s, e) => onChange(slider.Value);
valueLabel.Text = value.ToString(valueStringFormat);
valueLabel.Padding = new Padding(Math.Max(0, valueLabelMaxWidth - valueLabel.Width), 0, 0, 0);
onChange(value);
b.SizeToChildren();
return b;
}
示例3: InitializeUI
private void InitializeUI()
{
settings = NavMeshGenerationSettings.Default;
areaSettings = new AreaIdGenerationSettings();
DockBase dock = new DockBase(gwenCanvas);
dock.Dock = Pos.Fill;
dock.SetSize(Width, Height);
dock.RightDock.Width = 280;
dock.BottomDock.Height = 150;
statusBar = new StatusBar(gwenCanvas);
Label genTime = new Label(statusBar);
genTime.Name = "GenTime";
genTime.Text = "Generation Time: 0ms";
genTime.Dock = Pos.Left;
LabeledCheckBox catchCheckBox = new LabeledCheckBox(statusBar);
catchCheckBox.Text = "Intercept and log exceptions";
catchCheckBox.Dock = Pos.Right;
catchCheckBox.CheckChanged += (s, e) => interceptExceptions = catchCheckBox.IsChecked;
catchCheckBox.IsChecked = true;
Base genBase = new Base(dock);
dock.RightDock.TabControl.AddPage("NavMesh Generation", genBase);
Button generateButton = new Button(genBase);
generateButton.Text = "Generate!";
generateButton.Height = 30;
generateButton.Dock = Pos.Top;
generateButton.Released += (s, e) => GenerateNavMesh();
GroupBox displaySettings = new GroupBox(genBase);
displaySettings.Text = "Display";
displaySettings.Dock = Pos.Top;
displaySettings.Height = 60;
Base levelCheckBase = new Base(displaySettings);
levelCheckBase.Dock = Pos.Top;
Label levelCheckLabel = new Label(levelCheckBase);
levelCheckLabel.Text = "Level";
levelCheckLabel.Dock = Pos.Left;
CheckBox levelCheckBox = new CheckBox(levelCheckBase);
levelCheckBox.Dock = Pos.Right;
levelCheckBox.Checked += (s, e) => displayLevel = true;
levelCheckBox.UnChecked += (s, e) => displayLevel = false;
levelCheckBox.IsChecked = true;
levelCheckBase.SizeToChildren();
Base displayModeBase = new Base(displaySettings);
displayModeBase.Dock = Pos.Top;
displayModeBase.Padding = new Padding(0, 4, 0, 0);
Label displayModeLabel = new Label(displayModeBase);
displayModeLabel.Text = "Generation Step";
displayModeLabel.Dock = Pos.Left;
displayModeLabel.Padding = new Padding(0, 0, 4, 0);
ComboBox displayModes = new ComboBox(displayModeBase);
displayModes.Dock = Pos.Top;
displayModes.AddItem("None", "", DisplayMode.None);
displayModes.AddItem("Heightfield", "", DisplayMode.Heightfield);
displayModes.AddItem("Compact Heightfield", "", DisplayMode.CompactHeightfield);
displayModes.AddItem("Distance Field", "", DisplayMode.DistanceField);
displayModes.AddItem("Regions", "", DisplayMode.Regions);
displayModes.AddItem("Contours", "", DisplayMode.Contours);
displayModes.AddItem("Polygon Mesh", "", DisplayMode.PolyMesh);
displayModes.AddItem("Polygon Mesh Detail", "", DisplayMode.PolyMeshDetail);
displayModes.AddItem("NavMesh", "", DisplayMode.NavMesh);
displayModes.AddItem("Pathfinding", "", DisplayMode.Pathfinding);
displayModes.ItemSelected += (s, e) => displayMode = (DisplayMode)e.SelectedItem.UserData;
displayModes.SelectByUserData(DisplayMode.PolyMeshDetail);
displayModeBase.SizeToChildren();
displayModeBase.Height += 4; //accounts for the padding, GWEN.NET should do this
const int leftMax = 125;
const int rightMax = 20;
GroupBox areaSetting = new GroupBox(genBase);
areaSetting.Text = "Area";
areaSetting.Dock = Pos.Top;
areaSetting.Height = 90;
var levelTris = level.GetTriangles();
BBox3 bounds = TriangleEnumerable.FromTriangle(levelTris, 0, levelTris.Length).GetBoundingBox();
Base maxTriSlope = CreateSliderOption(areaSetting, "Max Tri Slope:", 0.0001f, 3.14f, 3.14f, "N2", leftMax, rightMax, v => areaSettings.MaxTriSlope = v);
Base minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v);
Base maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v);
GroupBox rsSettings = new GroupBox(genBase);
rsSettings.Text = "Rasterization";
rsSettings.Dock = Pos.Top;
rsSettings.Height = 90;
//.........这里部分代码省略.........