protected override async Task LoadContent() { await base.LoadContent(); var background = new Entity { new BackgroundComponent { Texture = Content.Load<Texture>("XenkoBackground") } }; Scene.Entities.Add(background); var text1 = new TextBlock { Text = "text block button 1", Font = Content.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true }; ApplyTextBlockDefaultStyle(text1); button1 = new Button { Content = text1 }; ApplyButtonDefaultStyle(button1); button1.SetCanvasRelativePosition(new Vector3(0.025f, 0.05f, 0f)); edit1 = new EditText() { Text = "Edit text 1", Font = Content.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true, }; ApplyEditTextDefaultStyle(edit1); edit1.SetCanvasRelativePosition(new Vector3(0.025f, 0.15f, 0f)); var text2 = new TextBlock { Text = "text block button 2", Font = Content.Load<SpriteFont>("MicrosoftSansSerif15"), SynchronousCharacterGeneration = true }; ApplyTextBlockDefaultStyle(text2); button2 = new Button { Content = text2 }; ApplyButtonDefaultStyle(button2); edit2 = new EditText() { Text = "Edit text 2", Font = Content.Load<SpriteFont>("MicrosoftSansSerif15"), }; ApplyEditTextDefaultStyle(edit2); stackPanel = new StackPanel { Children = { button2, edit2 }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Orientation = Orientation.Horizontal }; stackPanel.SetCanvasRelativePosition(new Vector3(0.5f, 0.5f, 0f)); stackPanel.SetCanvasPinOrigin(new Vector3(.5f)); canvas = new Canvas { Children = {button1, edit1, stackPanel}, CanBeHitByUser = true }; button1.MouseOverStateChanged += (sender, args) => { triggeredButton1 = true; oldValueButton1 = args.OldValue; newValueButton1 = args.NewValue;}; button2.MouseOverStateChanged += (sender, args) => { triggeredButton2 = true;}; edit1.MouseOverStateChanged += (sender, args) => { triggeredEdit1 = true;}; edit2.MouseOverStateChanged += (sender, args) => { triggeredEdit2 = true;}; canvas.MouseOverStateChanged += (sender, args) => { triggeredCanvas = true;}; stackPanel.MouseOverStateChanged += (sender, args) => { triggeredStackPanel = true;}; canvas.UIElementServices = new UIElementServices { Services = this.Services }; UIComponent.Page = new Engine.UIPage { RootElement = canvas }; }
protected override async Task LoadContent() { await base.LoadContent(); var background = new Entity { new BackgroundComponent { Texture = Content.Load <Texture>("XenkoBackground") } }; Scene.Entities.Add(background); var text1 = new TextBlock { Text = "text block button 1", Font = Content.Load <SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true }; ApplyTextBlockDefaultStyle(text1); button1 = new Button { Content = text1 }; ApplyButtonDefaultStyle(button1); button1.SetCanvasRelativePosition(new Vector3(0.025f, 0.05f, 0f)); edit1 = new EditText() { Text = "Edit text 1", Font = Content.Load <SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true, }; ApplyEditTextDefaultStyle(edit1); edit1.SetCanvasRelativePosition(new Vector3(0.025f, 0.15f, 0f)); var text2 = new TextBlock { Text = "text block button 2", Font = Content.Load <SpriteFont>("MicrosoftSansSerif15"), SynchronousCharacterGeneration = true }; ApplyTextBlockDefaultStyle(text2); button2 = new Button { Content = text2 }; ApplyButtonDefaultStyle(button2); edit2 = new EditText() { Text = "Edit text 2", Font = Content.Load <SpriteFont>("MicrosoftSansSerif15"), }; ApplyEditTextDefaultStyle(edit2); stackPanel = new StackPanel { Children = { button2, edit2 }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Orientation = Orientation.Horizontal }; stackPanel.SetCanvasRelativePosition(new Vector3(0.5f, 0.5f, 0f)); stackPanel.SetCanvasPinOrigin(new Vector3(.5f)); canvas = new Canvas { Children = { button1, edit1, stackPanel }, CanBeHitByUser = true }; button1.MouseOverStateChanged += (sender, args) => { triggeredButton1 = true; oldValueButton1 = args.OldValue; newValueButton1 = args.NewValue; }; button2.MouseOverStateChanged += (sender, args) => { triggeredButton2 = true; }; edit1.MouseOverStateChanged += (sender, args) => { triggeredEdit1 = true; }; edit2.MouseOverStateChanged += (sender, args) => { triggeredEdit2 = true; }; canvas.MouseOverStateChanged += (sender, args) => { triggeredCanvas = true; }; stackPanel.MouseOverStateChanged += (sender, args) => { triggeredStackPanel = true; }; canvas.UIElementServices = new UIElementServices { Services = this.Services }; UIComponent.Page = new Engine.UIPage { RootElement = canvas }; }
protected override async Task LoadContent() { await base.LoadContent(); button1 = new Button { Content = new TextBlock { Text = "text block button 1", Font = Asset.Load <SpriteFont>("CourierNew12") } }; button1.SetCanvasRelativePosition(new Vector3(0.025f, 0.05f, 0f)); edit1 = new EditText(Services) { Text = "Edit text 1", Font = Asset.Load <SpriteFont>("CourierNew12"), }; edit1.SetCanvasRelativePosition(new Vector3(0.025f, 0.15f, 0f)); button2 = new Button { Content = new TextBlock { Text = "text block button 2", Font = Asset.Load <SpriteFont>("MicrosoftSansSerif15") } }; edit2 = new EditText(Services) { Text = "Edit text 2", Font = Asset.Load <SpriteFont>("MicrosoftSansSerif15"), }; stackPanel = new StackPanel { Children = { button2, edit2 }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Orientation = Orientation.Horizontal }; stackPanel.SetCanvasRelativePosition(new Vector3(0.5f, 0.5f, 0f)); stackPanel.SetCanvasPinOrigin(new Vector3(.5f)); canvas = new Canvas { Children = { button1, edit1, stackPanel }, CanBeHitByUser = true }; button1.MouseOverStateChanged += (sender, args) => { triggeredButton1 = true; oldValueButton1 = args.OldValue; newValueButton1 = args.NewValue; }; button2.MouseOverStateChanged += (sender, args) => { triggeredButton2 = true; }; edit1.MouseOverStateChanged += (sender, args) => { triggeredEdit1 = true; }; edit2.MouseOverStateChanged += (sender, args) => { triggeredEdit2 = true; }; canvas.MouseOverStateChanged += (sender, args) => { triggeredCanvas = true; }; stackPanel.MouseOverStateChanged += (sender, args) => { triggeredStackPanel = true; }; UI.RootElement = canvas; }
public MouseOverEventArgs(MouseOverState state) { this.state = state; }