當前位置: 首頁>>代碼示例>>C#>>正文


C# Text.SetStyle方法代碼示例

本文整理匯總了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;
			}
		}
開發者ID:cianmulville,項目名稱:urho-samples,代碼行數:60,代碼來源:UIDrag.cs

示例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);
        }
開發者ID:ZENG-Yuhao,項目名稱:Xamarin-CrossPlatform,代碼行數:32,代碼來源:HelloGUI.cs


注:本文中的Text.SetStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。