UI Slider decorate class
Inheritance: UIBase
Example #1
0
        public void CreateUI()
        {
            Colors = new Slider()
            {
                Margin = new Thickness(100, 20, 0, 32),
                VerticalAlignment = VerticalAlignment.Center,
                Width = 500,
                Height = 100,
                Minimum = -360,
                Maximum = 0,
                Foreground = WaveEngine.Common.Graphics.Color.Bisque,
                Background = WaveEngine.Common.Graphics.Color.DarkGreen,

            };
        }
Example #2
0
        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
        }
Example #3
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Gray;
            //RenderManager.DebugLines = true;

            // Slider 1
            int slider1Top = 60;
            slider1 = new Slider()
            {
                Margin = new Thickness(20, slider1Top, 0, 0),
                Width = 360,
                Value = 50,
            };
            EntityManager.Add(slider1.Entity);

            // Slider 2
            int slider2Top = 130;
            slider2 = new Slider()
            {
                Margin = new Thickness(20, slider2Top, 0, 0),
                Width = 360,
                Minimum = -20,
                Maximum = 500,
                Value = 10,
                Foreground = Color.Purple,
                Background = Color.LightPink,
                TextColor = Color.Purple,
            };
            EntityManager.Add(slider2.Entity);

            // Slider 3
            int slider3Top = 220;
            int spacing = 60;
            slider3 = new Slider()
            {
                Margin = new Thickness(60, slider3Top, 0, 0),
                Orientation = Orientation.Vertical,
                Height = 360,
                Width = 20,
                Minimum = 40,
                Maximum = 500,
                Value = 80,
                Foreground = Color.Yellow,
                Background = Color.Red,
                TextColor = Color.LightGreen
            };
            slider3.ValueChanged += slider3_ValueChanged;
            EntityManager.Add(slider3.Entity);

            textblock1 = new TextBlock()
            {
                Margin = new Thickness(100, slider3Top, 0, 0),
                Text = "Range: [40, 500] InitValue: 80",
                Width = 300,
                Height = 40,
            };
            EntityManager.Add(textblock1.Entity);

            button1 = new Button()
            {
                Margin = new Thickness(100, slider3Top + spacing, 0, 0),
                Width = 160,
                Text = "Set Value 250",
                Foreground = Color.Gray,
                BackgroundColor = Color.LightBlue,
                BorderColor = Color.LightBlue,
            };
            button1.Click += button1_Click;
            EntityManager.Add(button1.Entity);

            textblock2 = new TextBlock()
            {
                Margin = new Thickness(100, slider3Top + spacing * 2, 0, 0),
                Text = "<Info>",
                Width = 300,
                Height = 40,
                Foreground = Color.Yellow
            };
            EntityManager.Add(textblock2.Entity);

            // Image Check
            AddCheckImage("Content/SliderSample.wpk");
        }
Example #4
0
        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 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;
                };
        }
Example #6
0
        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
        }
Example #7
0
        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
        }
Example #8
0
        private void CreateSliders()
        {
            TextBlock t_rotX = new TextBlock()
            {
                Text = "Rot X",
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(15, 0, 0, 60),
            };

            EntityManager.Add(t_rotX);

            this.sliderRotX = new Slider()
            {
                Margin = new Thickness(50, 0, 0, 0),
                Orientation = Orientation.Vertical,
                VerticalAlignment = VerticalAlignment.Center,
                Height = 360,
                Width = 40,
                Minimum = 0,
                Maximum = 360,
                Foreground = darkColor,
                Background = lightColor,
            };
            this.sliderRotX.RealTimeValueChanged += this.sliderRot_RealTimeValueChanged;

            EntityManager.Add(this.sliderRotX);

            TextBlock t_rotY = new TextBlock()
            {
                Text = "Rot Y",
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(40, 0, 0, 40),
            };

            EntityManager.Add(t_rotY);

            this.sliderRotY = new Slider()
            {
                Margin = new Thickness(100, 20, 0, 32),
                VerticalAlignment = VerticalAlignment.Bottom,
                Width = 360,
                Height = 40,
                Minimum = 0,
                Maximum = 360,
                Foreground = darkColor,
                Background = lightColor,
            };
            this.sliderRotY.RealTimeValueChanged += this.sliderRot_RealTimeValueChanged;

            EntityManager.Add(this.sliderRotY);
        }
        /// <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);
        }