protected override void CreateScene() { FreeCamera camera = new FreeCamera("camera", new Vector3(-3.8f, 2.2f, 5.6f), new Vector3(0, 0.8f, 2.2f)) { Speed = 5, NearPlane = 0.1f }; EntityManager.Add(camera); this.Video1 = WaveServices.VideoPlayer.VideoInfoFromPath("Content/Video/bunny.mp4"); this.Video2 = WaveServices.VideoPlayer.VideoInfoFromPath("Content/Video/bear.mp4"); WaveServices.VideoPlayer.IsLooped = true; WaveServices.VideoPlayer.Play(this.Video1); Entity tvRoomEntity = new Entity("tvRoom") .AddComponent(new Transform3D()) .AddComponent(new Model("Content/TvRoom.wpk")) .AddComponent(new ModelRenderer()) .AddComponent(new MaterialsMap(new System.Collections.Generic.Dictionary<string, Material> { {"floor", new DualTextureMaterial("Content/parketFloor_Diffuse.wpk", "Content/TvRoomLightingMap.wpk", DefaultLayers.Opaque)}, {"tv", new DualTextureMaterial("Content/Tv_Diffuse.wpk", "Content/TvRoomLightingMap.wpk", DefaultLayers.Opaque)}, {"table", new DualTextureMaterial("Content/table_Diffuse.wpk", "Content/TvRoomLightingMap.wpk", DefaultLayers.Opaque)}, {"chair", new DualTextureMaterial("Content/Chair_Diffuse.wpk", "Content/TvRoomLightingMap.wpk", DefaultLayers.Opaque)}, {"tv_screen", new BasicMaterial(WaveServices.VideoPlayer.VideoTexture)} } )); EntityManager.Add(tvRoomEntity); StackPanel controlPanel = new StackPanel() { VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Right, Margin = new WaveEngine.Framework.UI.Thickness(0, 0, 30, 30), BorderColor = Color.White, IsBorder = true, }; ToggleSwitch muteToggle = new ToggleSwitch() { OnText = "Mute", OffText = "Mute", Margin = new WaveEngine.Framework.UI.Thickness(5, 5, 5, 10) }; muteToggle.Toggled += (e, s) => { WaveServices.VideoPlayer.IsMuted = muteToggle.IsOn; }; controlPanel.Add(muteToggle); RadioButton radioButton1 = new RadioButton() { GroupName = "Videos", Text = "Channel 1", Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 0), IsChecked = true }; radioButton1.Checked += (e, s) => { WaveServices.VideoPlayer.Play(this.Video1); }; controlPanel.Add(radioButton1); RadioButton radioButton2 = new RadioButton() { GroupName = "Videos", Text = "Channel 2", Margin = new WaveEngine.Framework.UI.Thickness(5,0,5,10) }; radioButton2.Checked += (e, s) => { WaveServices.VideoPlayer.Play(this.Video2); }; controlPanel.Add(radioButton2); PlayBtn = new Button("playBtn") { Text = "Play", Opacity = 0.5f, Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 0), Width = 170 }; PlayBtn.Click += (e, s) => { WaveServices.VideoPlayer.Resume(); PlayBtn.Opacity = 0.5f; PauseBtn.Opacity = 1f; }; controlPanel.Add(PlayBtn); PauseBtn = new Button("pauseBtn") { Text = "Pause", Width = 170, Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 5), }; PauseBtn.Click += (e, s) => { WaveServices.VideoPlayer.Pause(); PlayBtn.Opacity = 1f; PauseBtn.Opacity = 0.5f; }; controlPanel.Add(PauseBtn); EntityManager.Add(controlPanel); }
protected override void CreateScene() { this.Load(WaveContent.Scenes.MyScene); this.bunnyVideo = WaveServices.VideoPlayer.VideoInfoFromPath(WaveContent.Assets.Video.bear_mp4); this.bearVideo = WaveServices.VideoPlayer.VideoInfoFromPath(WaveContent.Assets.Video.bunny_mp4); WaveServices.VideoPlayer.IsLooped = true; WaveServices.VideoPlayer.Play(this.bunnyVideo); StackPanel controlPanel = new StackPanel() { VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom, HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Right, Margin = new WaveEngine.Framework.UI.Thickness(0, 0, 30, 30), BorderColor = Color.White, IsBorder = true, }; ToggleSwitch muteToggle = new ToggleSwitch() { OnText = "Mute", OffText = "Mute", Margin = new WaveEngine.Framework.UI.Thickness(5, 5, 5, 10) }; muteToggle.Toggled += (e, s) => { WaveServices.VideoPlayer.IsMuted = muteToggle.IsOn; }; controlPanel.Add(muteToggle); RadioButton radioButton1 = new RadioButton() { GroupName = "Videos", Text = "Channel 1", Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 0), IsChecked = true }; radioButton1.Checked += (e, s) => { WaveServices.VideoPlayer.Play(this.bunnyVideo); }; controlPanel.Add(radioButton1); RadioButton radioButton2 = new RadioButton() { GroupName = "Videos", Text = "Channel 2", Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 10) }; radioButton2.Checked += (e, s) => { WaveServices.VideoPlayer.Play(this.bearVideo); }; controlPanel.Add(radioButton2); PlayBtn = new Button("playBtn") { Text = "Play", Opacity = 0.5f, Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 0), Width = 170 }; PlayBtn.Click += (e, s) => { WaveServices.VideoPlayer.Resume(); PlayBtn.Opacity = 0.5f; PauseBtn.Opacity = 1f; }; controlPanel.Add(PlayBtn); PauseBtn = new Button("pauseBtn") { Text = "Pause", Width = 170, Margin = new WaveEngine.Framework.UI.Thickness(5, 0, 5, 5), }; PauseBtn.Click += (e, s) => { WaveServices.VideoPlayer.Pause(); PlayBtn.Opacity = 1f; PauseBtn.Opacity = 0.5f; }; controlPanel.Add(PauseBtn); EntityManager.Add(controlPanel); }
private void CreateGrid() { Grid grid = new Grid() { HorizontalAlignment = HorizontalAlignment.Right, Height = WaveServices.Platform.ScreenHeight, }; grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) }); grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(3, GridUnitType.Proportional) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(200, GridUnitType.Pixel) }); EntityManager.Add(grid); #region Color UI TextBlock t_colors = new TextBlock() { Text = "Colors", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_colors.SetValue(GridControl.RowProperty, 0); t_colors.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_colors); StackPanel stackPanel = new StackPanel() { Margin = new Thickness(30, 0, 0, 0), }; stackPanel.SetValue(GridControl.RowProperty, 1); stackPanel.SetValue(GridControl.ColumnProperty, 0); grid.Add(stackPanel); RadioButton radio1 = new RadioButton() { Text = "Red", GroupName = "colors", Foreground = Color.Red, }; radio1.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Red; }; stackPanel.Add(radio1); RadioButton radio2 = new RadioButton() { Text = "Green", GroupName = "colors", Foreground = Color.Green, }; radio2.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Green; }; stackPanel.Add(radio2); RadioButton radio3 = new RadioButton() { Text = "Blue", GroupName = "colors", Foreground = Color.Blue, }; radio3.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.Blue; }; stackPanel.Add(radio3); RadioButton radio4 = new RadioButton() { Text = "White", GroupName = "colors", Foreground = Color.White, IsChecked = true, }; radio4.Checked += (s, o) => { this.cubeMaterial.DiffuseColor = Color.White; }; stackPanel.Add(radio4); #endregion #region Texture UI TextBlock t_texture = new TextBlock() { Text = "Textures", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_texture.SetValue(GridControl.RowProperty, 2); t_texture.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_texture); ToggleSwitch toggleTexture = new ToggleSwitch() { Margin = new Thickness(30, 0, 0, 0), Foreground = darkColor, Background = lightColor, IsOn = true, }; toggleTexture.Toggled += (s, o) => { this.cubeMaterial.TextureEnabled = toggleTexture.IsOn; }; toggleTexture.SetValue(GridControl.RowProperty, 3); toggleTexture.SetValue(GridControl.ColumnProperty, 0); grid.Add(toggleTexture); #endregion #region Scale UI TextBlock t_scale = new TextBlock() { Text = "Scale", VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(10), }; t_scale.SetValue(GridControl.RowProperty, 4); t_scale.SetValue(GridControl.ColumnProperty, 0); grid.Add(t_scale); Slider sliderScale = new Slider() { Width = 150, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(30, 0, 0, 0), Foreground = darkColor, Background = lightColor, Value = 50, }; sliderScale.RealTimeValueChanged += (s, o) => { this.cubeTransform.Scale = Vector3.One / 2 + (Vector3.One * (o.NewValue / 100f)); }; sliderScale.SetValue(GridControl.RowProperty, 5); sliderScale.SetValue(GridControl.ColumnProperty, 0); grid.Add(sliderScale); #endregion #region Reset UI Button b_reset = new Button() { Text = "Reset", Margin = new Thickness(10, 0, 0, 20), VerticalAlignment = VerticalAlignment.Bottom, Foreground = Color.White, BackgroundColor = lightColor, }; b_reset.Click += (s, o) => { radio4.IsChecked = true; toggleTexture.IsOn = true; sliderScale.Value = 50; this.sliderRotX.Value = 0; this.sliderRotY.Value = 0; }; b_reset.SetValue(GridControl.RowProperty, 6); b_reset.SetValue(GridControl.ColumnProperty, 0); grid.Add(b_reset); #endregion }
protected override void CreateScene() { RenderManager.BackgroundColor = Color.Gray; //RenderManager.DebugLines = true; // Group 1 int group1Top = 20; radio1 = new RadioButton() { Width = 360, Margin = new Thickness(20, group1Top, 0, 0), Text = "Group 1 - Choice 1", GroupName = "First group", Foreground = Color.Black, IsChecked = true }; EntityManager.Add(radio1.Entity); radio2 = new RadioButton() { Width = 360, Margin = new Thickness(20, group1Top + 40, 0, 0), Text = "Group 1 - Choice 2", GroupName = "First group", Foreground = Color.Black }; EntityManager.Add(radio2.Entity); // Free radio3 = new RadioButton() { Width = 180, Margin = new Thickness(20, 180, 0, 0), Text = "Free choice", IsBorder = true, BorderColor = Color.Yellow }; EntityManager.Add(radio3.Entity); // Toggle toggle = new ToggleSwitch() { Margin = new Thickness(220, 180, 0, 0) }; toggle.Toggled += toggle_Toggled; EntityManager.Add(toggle.Entity); // Group 2 int group2Top = 300; radio4 = new RadioButton() { Width = 360, Margin = new Thickness(20, group2Top, 0, 0), Text = "Group 2 - Choice 1", GroupName = "Second group", Foreground = Color.Yellow, IsChecked = true }; radio4.Checked += radio_group2_Checked; EntityManager.Add(radio4.Entity); radio5 = new RadioButton() { Width = 360, Margin = new Thickness(20, group2Top + 40, 0, 0), Text = "Group 2 - Choice 2", GroupName = "Second group", Foreground = Color.LightSalmon, }; radio5.Checked += radio_group2_Checked; EntityManager.Add(radio5.Entity); radio6 = new RadioButton() { Width = 360, Margin = new Thickness(20, group2Top + 80, 0, 0), Text = "Group 2 - Choice 3", GroupName = "Second group", Foreground = Color.LightSkyBlue }; radio6.Checked += radio_group2_Checked; EntityManager.Add(radio6.Entity); // Event text textBlock = new TextBlock() { Width = 360, Height = 40, Margin = new Thickness(20, group2Top + 120,0,0), Text = "Selected:" }; EntityManager.Add(textBlock.Entity); // Image check AddCheckImage("Content/RadioButtonSample.wpk"); }