本文整理汇总了C#中UIElement.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.AddChild方法的具体用法?C# UIElement.AddChild怎么用?C# UIElement.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.AddChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateUI
void CreateUI()
{
IsLogoVisible = false; // We need the full rendering window
var graphics = Graphics;
UIElement root = UI.Root;
var cache = ResourceCache;
XmlFile uiStyle = cache.GetXmlFile("UI/DefaultStyle.xml");
// Set style to the UI root so that elements will inherit it
root.SetDefaultStyle(uiStyle);
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
chatHistoryText = new Text();
chatHistoryText.SetFont(font, 12);
root.AddChild(chatHistoryText);
buttonContainer = new UIElement();
root.AddChild(buttonContainer);
buttonContainer.SetFixedSize(graphics.Width, 20);
buttonContainer.SetPosition(0, graphics.Height - 20);
buttonContainer.LayoutMode = LayoutMode.Horizontal;
textEdit = new LineEdit();
textEdit.SetStyleAuto(null);
buttonContainer.AddChild(textEdit);
sendButton = CreateButton("Send", 70);
connectButton = CreateButton("Connect", 90);
disconnectButton = CreateButton("Disconnect", 100);
startServerButton = CreateButton("Start Server", 110);
UpdateButtons();
// No viewports or scene is defined. However, the default zone's fog color controls the fill color
Renderer.DefaultZone.FogColor = new Color(0.0f, 0.0f, 0.1f);
}
示例2: InitWindow
void InitWindow()
{
// Create the Window and add it to the UI's root node
window = new Window();
uiRoot.AddChild(window);
// Set Window size and layout settings
window.SetMinSize(384, 192);
window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
window.Name = "Window";
// Create Window 'titlebar' container
UIElement titleBar = new UIElement();
titleBar.SetMinSize(0, 24);
titleBar.VerticalAlignment = VerticalAlignment.Top;
titleBar.LayoutMode = LayoutMode.Horizontal;
// Create the Window title Text
var windowTitle = new Text();
windowTitle.Name = "WindowTitle";
windowTitle.Value = "Hello GUI!";
// Create the Window's close button
Button buttonClose = new Button();
buttonClose.Name = "CloseButton";
// Add the controls to the title bar
titleBar.AddChild(windowTitle);
titleBar.AddChild(buttonClose);
// Add the title bar to the Window
window.AddChild(titleBar);
// Apply styles
window.SetStyleAuto(null);
windowTitle.SetStyleAuto(null);
buttonClose.SetStyle("CloseButton", null);
buttonClose.SubscribeToReleased(_ => Engine.Exit());
// Subscribe also to all UI mouse clicks just to see where we have clicked
UI.SubscribeToUIMouseClick(HandleControlClicked);
}