本文整理汇总了C#中Text.SetStyle方法的典型用法代码示例。如果您正苦于以下问题:C# Text.SetStyle方法的具体用法?C# Text.SetStyle怎么用?C# Text.SetStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text.SetStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGUI
void CreateGUI()
{
var cache = ResourceCache;
UI ui = UI;
UIElement root = ui.Root;
// Load the style sheet from xml
root.SetDefaultStyle(cache.GetXmlFile("UI/DefaultStyle.xml"));
for (int i = 0; i < 10; i++)
{
Button b = new Button();
root.AddChild(b);
// Reference a style from the style sheet loaded earlier:
b.SetStyle("Button", null);
b.SetSize(300, 100);
b.Position = new IntVector2(50 * i, 50 * i);
b.SubscribeToDragMove(HandleDragMove);
b.SubscribeToDragBegin(HandleDragBegin);
b.SubscribeToDragCancel(HandleDragCancel);
b.SubscribeToDragEnd(HandleDragEnd);
{
var t = new Text();
b.AddChild(t);
t.SetStyle("Text", null);
t.HorizontalAlignment = HorizontalAlignment.Center;
t.VerticalAlignment = VerticalAlignment.Center;
t.Name = ("Text");
}
{
var t = new Text();
b.AddChild(t);
t.SetStyle("Text", null);
t.Name=("Event Touch");
t.HorizontalAlignment=HorizontalAlignment.Center;
t.VerticalAlignment=VerticalAlignment.Bottom;
}
{
var t = new Text();
b.AddChild(t);
t.SetStyle("Text", null);
t.Name=("Num Touch");
t.HorizontalAlignment=HorizontalAlignment.Center;
t.VerticalAlignment=VerticalAlignment.Top;
}
}
for (int i = 0; i< 10; i++)
{
var t = new Text();
root.AddChild(t);
t.SetStyle("Text", null);
t.Name=("Touch "+ i);
t.Visible = false;
}
}
示例2: CreateDraggableFish
void CreateDraggableFish()
{
var cache = ResourceCache;
var graphics = Graphics;
// Create a draggable Fish button
draggableFish = new Button();
draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture
draggableFish.BlendMode = BlendMode.Add;
draggableFish.SetSize(128, 128);
draggableFish.SetPosition((graphics.Width - draggableFish.Width)/2, 200);
draggableFish.Name = "Fish";
uiRoot.AddChild(draggableFish);
// Add a tooltip to Fish button
ToolTip toolTip = new ToolTip();
draggableFish.AddChild(toolTip);
toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width/2);
// slightly offset from close button
BorderImage textHolder = new BorderImage();
toolTip.AddChild(textHolder);
textHolder.SetStyle("ToolTipBorderImage", null);
var toolTipText = new Text();
textHolder.AddChild(toolTipText);
toolTipText.SetStyle("ToolTipText", null);
toolTipText.Value = "Please drag me!";
// Subscribe draggableFish to Drag Events (in order to make it draggable)
draggableFish.SubscribeToDragBegin(HandleDragBegin);
draggableFish.SubscribeToDragMove(HandleDragMove);
draggableFish.SubscribeToDragEnd(HandleDragEnd);
}