当前位置: 首页>>代码示例>>C#>>正文


C# Button.SetTemplate方法代码示例

本文整理汇总了C#中Button.SetTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetTemplate方法的具体用法?C# Button.SetTemplate怎么用?C# Button.SetTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Button的用法示例。


在下文中一共展示了Button.SetTemplate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button_SetTemplate_Test

        public void Button_SetTemplate_Test()
        {
            var button = new Button(new TestHelpers.RootElement(), AssetManager);
            var block = new TextBlock(button, AssetManager) { Name = "Normal TextBlock" };

            Assert.IsTrue(button.SetTemplate(ButtonState.Normal, block.Name));
            Assert.IsFalse(block.IsLogical);
            Assert.AreEqual(block, button.GetTemplate(ButtonState.Normal));

            Assert.IsFalse(button.SetTemplate(ButtonState.Normal, "NonExistingChildName"));

            Assert.IsTrue(button.SetTemplate(ButtonState.Normal, null));
            Assert.IsTrue(block.IsLogical);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:14,代码来源:ButtonTest.cs

示例2: Button_StateChangesOnMouseEvent_Test

        public void Button_StateChangesOnMouseEvent_Test()
        {
            var button = new Button(new TestHelpers.RootElement(), AssetManager)
            {
                DestRect = new Rectangle(0.0f, 0.0f, 0.5f, 0.5f)
            };

            // We need to check that "template" does not consume our event.
            var block = new TextBlock(button, AssetManager) { Name = "Normal TextBlock" };
            button.SetTemplate(ButtonState.Normal, block.Name);

            button.InjectMouseMoveEvent(0.0f, 0.0f);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseDownEvent(0.0f, 0.0f, MouseButton.Left);
            Assert.AreEqual(ButtonState.Pushed, button.State);

            button.InjectMouseUpEvent(0.0f, 0.0f, MouseButton.Left);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseDownEvent(0.0f, 0.0f, MouseButton.Right);
            Assert.AreEqual(ButtonState.Hover, button.State);

            button.InjectMouseMoveEvent(button.AbsRect.Left - 1, button.AbsRect.Top - 1);
            Assert.AreEqual(ButtonState.Normal, button.State);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:26,代码来源:ButtonTest.cs

示例3: Button_Render_Test

        public void Button_Render_Test()
        {
            var button = new Button(new TestHelpers.RootElement(), AssetManager);
            TestHelpers.RenderSprite(Device, (s) => Assert.IsFalse((button as ISprite).Render(s)));

            var block = new TextBlock(button, AssetManager) { Name = "Normal TextBlock" };
            button.SetTemplate(ButtonState.Normal, block.Name);
            TestHelpers.RenderSprite(Device, s => Assert.IsTrue((button as ISprite).Render(s)));
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:9,代码来源:ButtonTest.cs

示例4: AddButton

 private void AddButton()
 {
     var button = new Button(Element, this.assetManager);
     var textBlock = new TextBlock(button, assetManager) { Name = "NormalTemplate" };
     button.SetTemplate(ButtonState.Normal, textBlock.Name);
     Childs.Add(UIElementEditor.Create(this, button, this.assetManager));
 }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:7,代码来源:UIElementEditor.cs

示例5: Button_State_Test

        public void Button_State_Test()
        {
            var button = new Button(new TestHelpers.RootElement(), AssetManager);
            var block = new TextBlock(button, AssetManager) { Name = "Normal TextBlock" };
            var img = new Image(button, AssetManager) { Name = "Hover Image" };

            button.SetTemplate(ButtonState.Normal, block.Name);
            button.SetTemplate(ButtonState.Hover, img.Name);

            Assert.AreEqual(ButtonState.Normal, button.State);
            Assert.IsTrue(block.IsVisible);
            Assert.IsFalse(img.IsVisible);

            button.State = ButtonState.Hover;
            Assert.IsFalse(block.IsVisible);
            Assert.IsTrue(img.IsVisible);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:17,代码来源:ButtonTest.cs

示例6: Button_XmlSerialize_Test

        public void Button_XmlSerialize_Test()
        {
            var parent = new TestHelpers.RootElement();
            var expected = new Button(parent, AssetManager);
            var block = new TextBlock(expected, AssetManager) { Name = "Normal TextBlock" };
            expected.SetTemplate(ButtonState.Normal, block.Name);

            var stream = new MemoryStream();
            using (var xmlWriter = XmlWriter.Create(stream))
            {
                expected.WriteXml(xmlWriter);
            }

            stream.Position = 0;
            var actual = new Button(parent, AssetManager);
            using (var xmlReader = XmlReader.Create(stream))
            {
                actual.ReadXml(xmlReader);
            }

            Assert.AreEqual(block.Name, actual.GetTemplate(ButtonState.Normal).Name);
            Assert.IsNull(actual.GetTemplate(ButtonState.Hover));
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:23,代码来源:ButtonTest.cs


注:本文中的Button.SetTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。