private void CreateDebugMode() { ToggleSwitch debugMode = new ToggleSwitch() { OnText = "Debug On", OffText = "Debug Off", Margin = new Thickness(5), Width = 200, Foreground = darkColor, Background = lightColor, }; debugMode.Toggled += (s, o) => { RenderManager.DebugLines = debugMode.IsOn; }; EntityManager.Add(debugMode.Entity); }
protected override void CreateScene() { this.Load(WaveContent.Scenes.MyScene); var skeleton = EntityManager.Find("skeleton"); var skeletalAnimation = skeleton.FindComponent<SkeletalAnimation>(); var skeletalRenderer = skeleton.FindComponent<SkeletalRenderer>(); skeletalAnimation.EventAnimation += this.SkeletalAnimation_EventAnimation; #region UI Slider slider1 = new Slider() { Margin = new Thickness(10, 40, 0, 0), Width = 500, Minimum = -25, Maximum = 25, Value = (int)skeletalAnimation.Speed * 10 }; slider1.RealTimeValueChanged += (s, e) => { var entity = EntityManager.Find("Light0"); skeletalAnimation.Speed = e.NewValue / 10f; }; EntityManager.Add(slider1); ToggleSwitch debugMode = new ToggleSwitch() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 10, 10, 0), IsOn = false, OnText = "Debug On", OffText = "Debug Off", Width = 200 }; debugMode.Toggled += (s, o) => { var isOn = ((ToggleSwitch)s).IsOn; WaveServices.ScreenContextManager.SetDiagnosticsActive(isOn); RenderManager.DebugLines = isOn; }; EntityManager.Add(debugMode); CheckBox debugBones = new CheckBox() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 60, 10, 0), Text = "Bones", Width = 150, }; debugBones.Checked += (s, o) => { if (o.Value) { skeletalRenderer.ActualDebugMode |= SkeletalRenderer.DebugMode.Bones; } else { skeletalRenderer.ActualDebugMode &= SkeletalRenderer.DebugMode.Quads; } }; EntityManager.Add(debugBones); CheckBox debugQuads = new CheckBox() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 110, 10, 0), Text = "Quads", Width = 150, }; debugQuads.Checked += (s, o) => { if (o.Value) { skeletalRenderer.ActualDebugMode |= SkeletalRenderer.DebugMode.Quads; } else { skeletalRenderer.ActualDebugMode &= SkeletalRenderer.DebugMode.Bones; } }; EntityManager.Add(debugQuads); #endregion }
protected override void CreateScene() { RenderManager.BackgroundColor = Color.Black; //RenderManager.DebugLines = true; FreeCamera camera = new FreeCamera("MainCamera", new Vector3(0, 4, 12), new Vector3(0, 4, 0)) { Speed = 5 }; EntityManager.Add(camera.Entity); RenderManager.SetActiveCamera(camera.Entity); PointLight Light0 = new PointLight("Light0", new Vector3(-5, 8, 10)) { Color = Color.White, Attenuation = 20, }; Light0.Entity.AddComponent(new MoveBehavior() { Speed = 0.2f }); EntityManager.Add(Light0.Entity); float value = 0.0f; Color c = new Color(value, value, value, 1); Entity cubeModel = new Entity("Cube") .AddComponent(new Transform3D() { Scale = new Vector3(6) }) //.AddComponent(new Spinner() { IncreaseY = 0.02f }) .AddComponent(new BoxCollider()) .AddComponent(new Model("Content/Cube.wpk")) .AddComponent(new MaterialsMap(new NormalMappingMaterial("Content/floor.wpk", "Content/floor_normal_spec.wpk", "Content/lightmap.wpk") { AmbientColor = c })) // "Content/lightmap.wpk" .AddComponent(new ModelRenderer()); EntityManager.Add(cubeModel); #region UI Slider slider1 = new Slider() { Margin = new Thickness(10, 90, 0, 0), Width = 500, Minimum = 4, Maximum = 40, Value = 30 }; slider1.RealTimeValueChanged += (s, e) => { var entity = EntityManager.Find("Light0"); var component = entity.FindComponent<PointLightProperties>(); component.Attenuation = e.NewValue; }; EntityManager.Add(slider1); Slider slider2 = new Slider() { Margin = new Thickness(10, 140, 0, 0), Width = 500, Minimum = 1, Maximum = 100 }; slider2.RealTimeValueChanged += (s, e) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as NormalMappingMaterial); float v = (float)e.NewValue / 100.0f; Color c1 = new Color(v, v, v, 1); material.AmbientColor = c1; }; EntityManager.Add(slider2); ToggleSwitch lightmapEnabled = new ToggleSwitch() { Margin = new Thickness(10, 10, 0, 0), IsOn = true, OnText = "LightMap On", OffText = "LightMap Off", }; lightmapEnabled.Toggled += (s, e) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as NormalMappingMaterial); material.LightMapEnabled = !material.LightMapEnabled; }; EntityManager.Add(lightmapEnabled); ToggleSwitch textureEnabled = new ToggleSwitch() { Margin = new Thickness(10, 40, 0, 0), IsOn = true, OnText = "Texture On", OffText = "Texture Off" }; textureEnabled.Toggled += (s, o) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as NormalMappingMaterial); material.TextureEnabled = !material.TextureEnabled; }; EntityManager.Add(textureEnabled); ToggleSwitch normalMapEnabled = new ToggleSwitch() { Margin = new Thickness(300, 10, 0, 0), IsOn = true, OnText = "NormalMap On", OffText = "NormalMap Off" }; normalMapEnabled.Toggled += (s, o) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as NormalMappingMaterial); material.NormalMappingEnabled = !material.NormalMappingEnabled; }; EntityManager.Add(normalMapEnabled); #endregion }
/// <summary> /// Creates the debug mode. /// </summary> private void CreateDebugMode() { debugMode = new ToggleSwitch() { OnText = "Debug On", OffText = "Debug Off", HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Width = 200, }; debugMode.Toggled += debugMode_Toggled; EntityManager.Add(debugMode.Entity); }
/// <summary> /// Creates the UI. /// </summary> protected override void CreateUI() { base.CreateUI(); // Size text this.tbSize = new TextBlock() { Foreground = this.uiColor, //FontPath = this.fontPath }; customUIPanel.Add(tbSize); // Scale text var tbScale = new TextBlock() { Foreground = this.uiColor, Text = "Scale (1):", //FontPath = this.fontPath }; customUIPanel.Add(tbScale); // Scale slider this.sldScale = new Slider() { Minimum = MinimumSliderScaleValue, Maximum = MaximumSliderScaleValue, Value = DefaultSliderScaleValue, TextColor = Color.Transparent, //FontPath = this.fontPath }; customUIPanel.Add(sldScale); sldScale.RealTimeValueChanged += (o, e) => { var trans2D = this.entity.FindComponent<Transform2D>(); var finalScale = sldScale.Value / 10f; trans2D.XScale = trans2D.YScale = finalScale; tbScale.Text = string.Format("Scale ({0}):", finalScale); }; var tsShowBorder = new ToggleSwitch() { OnText = "Show border?", OffText = "Show border?", IsOn = true, Width = 300, TextColor = this.uiColor, //FontPath = this.fontPath }; customUIPanel.Add(tsShowBorder); tsShowBorder.Toggled += (o, e) => { var border = this.entity.FindComponent<BorderDrawable2D>(); border.IsVisible = !border.IsVisible; }; }
protected override void CreateScene() { RenderManager.BackgroundColor = Color.CornflowerBlue; //"spineboy","walk"), //"powerup","animation"), string file = "spineboy"; var ratio = WaveServices.ViewportManager.RatioX; this.skeleton = new Entity("Spine") .AddComponent(new Transform2D() { X = 350, Y = 460, XScale = 1, YScale = 1}) .AddComponent(new SkeletalData("Content/" + file + ".atlas")) .AddComponent(new SkeletalAnimation("Content/" + file + ".json")) .AddComponent(new SkeletalRenderer() { ActualDebugMode = SkeletalRenderer.DebugMode.None }); EntityManager.Add(this.skeleton); #region UI Slider slider1 = new Slider() { Margin = new Thickness(10, 40, 0, 0), Width = 500, Minimum = -25, Maximum = 25, Value = 0 }; slider1.RealTimeValueChanged += (s, e) => { var entity = EntityManager.Find("Light0"); var component = skeleton.FindComponent<SkeletalAnimation>(); component.Speed = e.NewValue / 10f; }; EntityManager.Add(slider1); ToggleSwitch debugMode = new ToggleSwitch() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 10, 10, 0), IsOn = false, OnText = "Debug On", OffText = "Debug Off", Width = 200 }; debugMode.Toggled += (s, o) => { RenderManager.DebugLines = ((ToggleSwitch)s).IsOn; }; EntityManager.Add(debugMode); CheckBox debugBones = new CheckBox() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 60, 10, 0), Text = "Bones", Width = 150, }; debugBones.Checked += (s, o) => { if (o.Value) { this.skeleton.FindComponent<SkeletalRenderer>().ActualDebugMode |= SkeletalRenderer.DebugMode.Bones; } else { this.skeleton.FindComponent<SkeletalRenderer>().ActualDebugMode &= SkeletalRenderer.DebugMode.Quads; } }; EntityManager.Add(debugBones); CheckBox debugQuads = new CheckBox() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 110, 10, 0), Text = "Quads", Width = 150, }; debugQuads.Checked += (s, o) => { if (o.Value) { this.skeleton.FindComponent<SkeletalRenderer>().ActualDebugMode |= SkeletalRenderer.DebugMode.Quads; } else { this.skeleton.FindComponent<SkeletalRenderer>().ActualDebugMode &= SkeletalRenderer.DebugMode.Bones; } }; EntityManager.Add(debugQuads); #endregion }
/// <summary> /// Create User Interface (UI) /// </summary> private void CreateUI() { var isisBehavior = EntityManager.Find("isis").FindComponent<IsisBehavior>(); CreateJoystickButton("UpButton", 200, WaveServices.Platform.ScreenHeight - 300, 0, (o, e) => { isisBehavior.GoUp = true; }, (o, e) => { isisBehavior.GoUp = false; }); CreateJoystickButton("DownButton", 200, WaveServices.Platform.ScreenHeight - 100, MathHelper.Pi, (o, e) => { isisBehavior.GoDown = true; }, (o, e) => { isisBehavior.GoDown = false; }); CreateJoystickButton("LeftButton", 100, WaveServices.Platform.ScreenHeight - 200, -MathHelper.PiOver2, (o, e) => { isisBehavior.GoLeft = true; }, (o, e) => { isisBehavior.GoLeft = false; }); CreateJoystickButton("RightButton", 300, WaveServices.Platform.ScreenHeight - 200, MathHelper.PiOver2, (o, e) => { isisBehavior.GoRight = true; }, (o, e) => { isisBehavior.GoRight = false; }); var shiftButton = new Entity("ShiftButton") .AddComponent(new Sprite("Content/ShiftButton.wpk")) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)) .AddComponent(new Transform2D() { X = WaveServices.Platform.ScreenWidth - 250, Y = WaveServices.Platform.ScreenHeight - 250 }) .AddComponent(new TouchGestures()) .AddComponent(new RectangleCollider()); shiftButton.FindComponent<TouchGestures>().TouchPressed += (o, e) => { isisBehavior.Run = true; }; shiftButton.FindComponent<TouchGestures>().TouchReleased += (o, e) => { isisBehavior.Run = false; }; EntityManager.Add(shiftButton); var wireframeModeToggle = new ToggleSwitch() { IsOn = false, OnText = "Wireframe?", OffText = "Wireframe?", Width = 175, Margin = new Thickness(50, 50, 0, 0) }; wireframeModeToggle.Toggled += (o, e) => { ((OpaqueLayer)RenderManager.FindLayer(DefaultLayers.Opaque)).FillMode = wireframeModeToggle.IsOn ? FillMode.Wireframe : FillMode.Solid; }; EntityManager.Add(wireframeModeToggle.Entity); }
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); //Slider slider1 = new Slider() //{ // Margin = new Thickness(10, 90, 0, 0), // Width = 500, // Minimum = 4, // Maximum = 40, // Value = 30 //}; //slider1.RealTimeValueChanged += (s, e) => //{ // var entity = EntityManager.Find("Light0"); // var component = entity.FindComponent<PointLightProperties>(); // component.Intensity = e.NewValue; //}; //EntityManager.Add(slider1); //Slider slider2 = new Slider() //{ // Margin = new Thickness(10, 140, 0, 0), // Width = 500, // Minimum = 1, // Maximum = 100 //}; //slider2.RealTimeValueChanged += (s, e) => //{ // var entity = EntityManager.Find("Cube"); // var component = entity.FindComponent<MaterialsMap>(); // var material = (component.DefaultMaterial as DualMaterial); // float v = (float)e.NewValue / 100.0f; // Color c1 = new Color(v, v, v, 1); // material.AmbientColor = c1; //}; //EntityManager.Add(slider2); ToggleSwitch lightmapEnabled = new ToggleSwitch() { Margin = new Thickness(10, 10, 0, 0), IsOn = true, OnText = "LightMap On", OffText = "LightMap Off", }; lightmapEnabled.Toggled += (s, e) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as DualMaterial); if (!string.IsNullOrEmpty(material.Diffuse2Path)) { material.Diffuse2Path = string.Empty; } else { material.Diffuse2Path = WaveContent.Assets.lightmap_png; } }; EntityManager.Add(lightmapEnabled); ToggleSwitch textureEnabled = new ToggleSwitch() { Margin = new Thickness(10, 40, 0, 0), IsOn = true, OnText = "Texture On", OffText = "Texture Off" }; textureEnabled.Toggled += (s, o) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as DualMaterial); if (!string.IsNullOrEmpty(material.Diffuse1Path)) { material.Diffuse1Path = string.Empty; } else { material.Diffuse1Path = WaveContent.Assets.floor_png; } }; EntityManager.Add(textureEnabled); ToggleSwitch normalMapEnabled = new ToggleSwitch() { Margin = new Thickness(300, 10, 0, 0), IsOn = true, OnText = "NormalMap On", OffText = "NormalMap Off" }; normalMapEnabled.Toggled += (s, o) => { var entity = EntityManager.Find("Cube"); var component = entity.FindComponent<MaterialsMap>(); var material = (component.DefaultMaterial as DualMaterial); if (!string.IsNullOrEmpty(material.NormalPath)) { material.NormalPath = string.Empty; } else { material.NormalPath = WaveContent.Assets.floor_normal_png; } }; EntityManager.Add(normalMapEnabled); }
protected override void CreateScene() { RenderManager.BackgroundColor = Color.Gray; //RenderManager.DebugLines = true; // Toggle 1 int offsetTop = 20; int spacing = 80; toggle1 = new ToggleSwitch() { Margin = new Thickness(20, offsetTop, 0, 0), }; EntityManager.Add(toggle1.Entity); // Toggle 2 toggle2 = new ToggleSwitch() { Margin = new Thickness(20, offsetTop + spacing, 0, 0), Width = 150, OnText = "High", OffText = "Low", }; EntityManager.Add(toggle2.Entity); // Toggle 3 toggle3 = new ToggleSwitch() { Margin = new Thickness(20, offsetTop + spacing * 2, 0, 0), Width = 200, OnText = "DirectX", OffText = "OpenGL", Foreground = Color.Purple, Background = Color.LightPink, }; EntityManager.Add(toggle3.Entity); // Toggle 4 toggle4 = new ToggleSwitch() { Margin = new Thickness(20, offsetTop + spacing * 3, 0, 0), Width = 200, OnText = "Victory!", OffText = "You lose", Foreground = Color.Yellow, Background = Color.Red, TextColor = Color.Yellow, IsOn = true, }; toggle4.Toggled += toggle4_Toggled; EntityManager.Add(toggle4.Entity); textblock1 = new TextBlock() { Margin = new Thickness(20, offsetTop + spacing * 4, 0, 0), Text = "Event:", }; EntityManager.Add(textblock1.Entity); // Toggle 5 toggle5 = new ToggleSwitch() { Margin = new Thickness(20, offsetTop + spacing * 5, 0, 0), Width = 200, OnText = "Sonic", OffText = "MarioBros", Foreground = Color.Orange, Background = Color.DarkGray, TextColor = Color.Orange, }; EntityManager.Add(toggle5.Entity); button1 = new Button() { Margin = new Thickness(20, offsetTop + spacing * 6, 0, 0), Text = "Set On", }; button1.Click += button1_Click; EntityManager.Add(button1.Entity); button2 = new Button() { Margin = new Thickness(130, offsetTop + spacing *6,0,0), Text = "Set Off", }; button2.Click += button2_Click; EntityManager.Add(button2.Entity); // Image Check AddCheckImage("Content/ToggleSwitchSample.wpk"); }
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() { 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); }
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"); }
/// <summary> /// Creates the UI. /// </summary> protected override void CreateUI() { base.CreateUI(); // Size text this.tbSize = new TextBlock() { Foreground = this.uiColor, //FontPath = this.fontPath }; customUIPanel.Add(tbSize); // Scale text var tbScale = new TextBlock() { Foreground = this.uiColor, Text = "Scale (1):", //FontPath = this.fontPath }; customUIPanel.Add(tbScale); // Scale slider this.sldScale = new Slider() { Minimum = MinimumSliderScaleValue, Maximum = MaximumSliderScaleValue, Value = DefaultSliderScaleValue, TextColor = Color.Transparent, //FontPath = this.fontPath }; customUIPanel.Add(sldScale); sldScale.RealTimeValueChanged += (o, e) => { var trans2D = this.entity.FindComponent<Transform2D>(); var finalScale = sldScale.Value / 10f; trans2D.XScale = trans2D.YScale = finalScale; tbScale.Text = string.Format("Scale ({0}):", finalScale); }; var tsShowBorder = new ToggleSwitch() { OnText = "Show border?", OffText = "Show border?", IsOn = true, Width = 300, TextColor = this.uiColor, //FontPath = this.fontPath }; customUIPanel.Add(tsShowBorder); tsShowBorder.Toggled += (o, e) => { var border = this.entity.FindComponent<BorderDrawable2D>(); border.IsVisible = !border.IsVisible; }; var tsShowRectangles = new ToggleSwitch() { OnText = "Show Rectangles?", OffText = "Show Rectangles?", IsOn = true, Width = 300, TextColor = this.uiColor, //FontPath = this.fontPath }; customUIPanel.Add(tsShowRectangles); tsShowRectangles.Toggled += (o, e) => { var renderer = this.entity.FindComponent<SpritesheetRectanglesRenderer>(); renderer.IsVisible = !renderer.IsVisible; }; this.tbSample = new TextBlock() { Text = "Test Text 1234", Width = 300, HorizontalAlignment = HorizontalAlignment.Right, TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Top, }; EntityManager.Add(this.tbSample); }