public RenderTreeVisualizer()
        {
            bars = new List<ProgressBar>();
            Updateable = true;
            Size = new SlimDX.Vector2(200, 200);

            for (int i = 0; i < 5; i++)
            {
                ProgressBar p = new ProgressBar
                {
                    Position = new SlimDX.Vector2(0, i * 20),
                    TextAnchor = Orientation.Left,
                    Size = new SlimDX.Vector2(200, 20)
                };
                bars.Add(p);
                AddChild(p);
            }
        }
        public void NewProgressBarResults(Control f, string label, float value, float maxValue, ref Vector2 elementPosition, string customText)
        {
            if (maxValue <= 0)
                return;

            System.Drawing.Color color = System.Drawing.Color.Red;

            if (value <= maxValue)
            {
                System.Drawing.Color color1 = System.Drawing.Color.Red, color2 = System.Drawing.Color.Yellow, color3 = System.Drawing.Color.Green;
                float halfWay = maxValue / 2f;
                float v = value;
                if (v >= halfWay)
                {
                    color1 = color2;
                    color2 = color3;
                    v -= halfWay;
                }
                var i = new Common.Interpolator4();
                i.AddKey(new Common.InterpolatorKey<Vector4> { Time = 0, Value = Common.Math.ToVector4(color1) });
                i.AddKey(new Common.InterpolatorKey<Vector4> { Time = 1, Value = Common.Math.ToVector4(color2) });
                color = Common.Math.ToColor(i.Update(v / halfWay));
            }

            float pbSize = 18;

            var pb = new ProgressBar
            {
                Size = new Vector2(rightHandWidth, pbSize),
                Text = customText,
                MaxValue = maxValue,
                Value = value,
                Anchor = global::Graphics.Orientation.TopLeft,
                ProgressGraphic = new Graphics.Content.StretchingImageGraphic
                {
                    Texture = new Graphics.Content.TextureConcretizer { TextureDescription = new global::Graphics.Software.Textures.SingleColorTexture(color) }
                },
                Font = statTextFont
            };

            NewResults(f, label, pb, ref elementPosition);
        }
示例#3
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            InterfaceScene = new Graphics.Interface.InterfaceScene(this);


            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "TopRight",
                Anchor = Orientation.TopRight
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "BottomLeft",
                Anchor = Orientation.BottomLeft
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "BottomRight",
                Anchor = Orientation.BottomRight
            });

            InterfaceScene.Add(new Graphics.Interface.Button
            {
                Size   = new Vector2(100, 20),
                Text   = "Button",
                Anchor = Orientation.Center
            });

            InterfaceScene.Add(cb = new Graphics.Interface.Checkbox
            {
                Size     = new Vector2(100, 20),
                Text     = "Checkbox",
                Anchor   = Orientation.Center,
                Position = new Vector2(0, 40)
            });

            InterfaceScene.Add(pb = new Graphics.Interface.ProgressBar
            {
                Size            = new Vector2(100, 100),
                Text            = "Button",
                Anchor          = Orientation.Bottom,
                MaxValue        = 100,
                Value           = 50,
                ProgressGraphic = new ImageGraphic
                {
                    Texture = new TextureFromFile("cornellbox3.png"),
                    //new TextureConcretizer { TextureDescription = new Graphics.Software.Textures.SingleColorTexture(Color.Red) },
                    TextureAnchor = Orientation.BottomLeft
                },
                ProgressOrientation = Graphics.Interface.ProgressOrientation.BottomToTop
            });

            InterfaceScene.Add(dpb = new Graphics.Interface.DeltaProgressBar
            {
                Size                = new Vector2(140, 10),
                Anchor              = Orientation.Center,
                MaxValue            = 100,
                Value               = 70,
                Position            = new Vector2(0, -30),
                ProgressOrientation = Graphics.Interface.ProgressOrientation.LeftToRight
            });

            Button bb;

            InterfaceScene.Add(bb = new Button
            {
                Size     = new Vector2(50, 20),
                Text     = "-",
                Anchor   = Orientation.Center,
                Position = new Vector2(-30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value - 20, 0, 100); };
            InterfaceScene.Add(bb = new Button
            {
                Size     = new Vector2(50, 20),
                Text     = "+",
                Anchor   = Orientation.Center,
                Position = new Vector2(30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value + 20, 0, 100); };

            InterfaceScene.Add(new Graphics.Interface.Console
            {
                Anchor   = Orientation.Bottom,
                Position = new Vector2(0, 100),
                Size     = new Vector2(400, 100)
            });

            var f = new Graphics.Interface.Form
            {
                Size = new Vector2(300, 300)
            };

            InterfaceScene.Add(f);
            b = new Graphics.Interface.Button
            {
                Size   = new Vector2(100, 20),
                Text   = "TopLeft",
                Anchor = Orientation.TopLeft
            };
            f.AddChild(b);
            Control checker;

            InterfaceScene.Add(checker = new Control
            {
                Background = new ImageGraphic
                {
                    Size    = new Vector2(100, 100),
                    Texture = new TextureFromFile("checker.png")
                },
                Size                 = new Vector2(100, 100),
                Position             = new Vector2(10, 30),
                Anchor               = Orientation.TopRight,
                Clickable            = true,
                PickingLocalBounding = new Common.Bounding.Chain
                {
                    Boundings = new object[]
                    {
                        new BoundingBox(Vector3.Zero, new Vector3(1, 1, 0)),
                        new MetaBoundingImageGraphic
                        {
                            Graphic = new ImageGraphic
                            {
                                Size    = new Vector2(100, 100),
                                Texture = new TextureFromFile("checker.png")
                            },
                        }
                    },
                    Shallow = true
                }
            });
            InterfaceScene.Add(popupContainer);
            InterfaceScene.Add(new Form
            {
                Anchor     = Orientation.Right,
                Size       = new Vector2(100, 100),
                ControlBox = true
            });

            tt = new Graphics.Interface.ToolTip();
            tt.SetToolTip(pb, "This is a progress bar");
            tt.SetToolTip(checker, "Checker");
            InterfaceScene.Add(tt);

            if (Direct3DVersion == Direct3DVersion.Direct3D10)
            {
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer10(Device10)
                {
                    Scene = InterfaceScene
                }
            }
            ;
            else
            {
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
                {
                    Scene = InterfaceScene, StateManager = new Device9StateManager(Device9)
                }
            };
            InterfaceRenderer.Initialize(this);
            InputHandler = Manager = new Graphics.Interface.InterfaceManager {
                Scene = InterfaceScene
            };
            //bvr = new BoundingVolumesRenderer
            //{
            //    View = this,
            //    StateManager = sm
            //};
        }

        Graphics.Interface.ToolTip tt;
        Graphics.Interface.Button b;
        public override void Init()
        {
            Content.ContentPath = "Data";

            InterfaceScene = new Graphics.Interface.InterfaceScene(this);

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "TopRight",
                Anchor = Orientation.TopRight
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "BottomLeft",
                Anchor = Orientation.BottomLeft
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "BottomRight",
                Anchor = Orientation.BottomRight
            });

            InterfaceScene.Add(new Graphics.Interface.Button
            {
                Size = new Vector2(100, 20),
                Text = "Button",
                Anchor = Orientation.Center
            });

            InterfaceScene.Add(cb = new Graphics.Interface.Checkbox
            {
                Size = new Vector2(100, 20),
                Text = "Checkbox",
                Anchor = Orientation.Center,
                Position = new Vector2(0, 40)
            });

            InterfaceScene.Add(pb = new Graphics.Interface.ProgressBar
            {
                Size = new Vector2(100, 100),
                Text = "Button",
                Anchor = Orientation.Bottom,
                MaxValue = 100,
                Value = 50,
                ProgressGraphic = new ImageGraphic
                {
                    Texture = new TextureFromFile("cornellbox3.png"),
                        //new TextureConcretizer { TextureDescription = new Graphics.Software.Textures.SingleColorTexture(Color.Red) },
                    TextureAnchor = Orientation.BottomLeft
                },
                ProgressOrientation = Graphics.Interface.ProgressOrientation.BottomToTop
            });

            InterfaceScene.Add(dpb = new Graphics.Interface.DeltaProgressBar
            {
                Size = new Vector2(140, 10),
                Anchor = Orientation.Center,
                MaxValue = 100,
                Value = 70,
                Position = new Vector2(0, -30),
                ProgressOrientation = Graphics.Interface.ProgressOrientation.LeftToRight
            });

            Button bb;
            InterfaceScene.Add(bb = new Button
            {
                Size = new Vector2(50, 20),
                Text = "-",
                Anchor = Orientation.Center,
                Position = new Vector2(-30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value - 20, 0, 100); };
            InterfaceScene.Add(bb = new Button
            {
                Size = new Vector2(50, 20),
                Text = "+",
                Anchor = Orientation.Center,
                Position = new Vector2(30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value + 20, 0, 100); };

            InterfaceScene.Add(new Graphics.Interface.Console
            {
                Anchor = Orientation.Bottom,
                Position = new Vector2(0, 100),
                Size = new Vector2(400, 100)
            });

            var f = new Graphics.Interface.Form
            {
                Size = new Vector2(300, 300)
            };
            InterfaceScene.Add(f);
            b = new Graphics.Interface.Button
            {
                Size = new Vector2(100, 20),
                Text = "TopLeft",
                Anchor = Orientation.TopLeft
            };
            f.AddChild(b);
            Control checker;
            InterfaceScene.Add(checker = new Control
            {
                Background = new ImageGraphic
                {
                    Size = new Vector2(100, 100),
                    Texture = new TextureFromFile("checker.png")
                },
                Size = new Vector2(100, 100),
                Position = new Vector2(10, 30),
                Anchor = Orientation.TopRight,
                Clickable = true,
                PickingLocalBounding = new Common.Bounding.Chain
                {
                    Boundings = new object[]
                    {
                        new BoundingBox(Vector3.Zero, new Vector3(1, 1, 0)),
                        new MetaBoundingImageGraphic
                        {
                            Graphic = new ImageGraphic
                            {
                                Size = new Vector2(100, 100),
                                Texture = new TextureFromFile("checker.png")
                            },
                        }
                    },
                    Shallow = true
                }
            });
            InterfaceScene.Add(popupContainer);
            InterfaceScene.Add(new Form
            {
                Anchor = Orientation.Right,
                Size = new Vector2(100, 100),
                ControlBox = true
            });

            tt = new Graphics.Interface.ToolTip();
            tt.SetToolTip(pb, "This is a progress bar");
            tt.SetToolTip(checker, "Checker");
            InterfaceScene.Add(tt);

            if (Direct3DVersion == Direct3DVersion.Direct3D10)
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer10(Device10)
                { Scene = InterfaceScene };
            else
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
                { Scene = InterfaceScene, StateManager = new Device9StateManager(Device9) };
            InterfaceRenderer.Initialize(this);
            InputHandler = Manager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene };
            //bvr = new BoundingVolumesRenderer
            //{
            //    View = this,
            //    StateManager = sm
            //};
        }
 public ProfilersResults()
 {
     Size = new Vector2(250, 250);
     Updateable = true;
     float y = 0;
     IEnumerable<Profiler> allProfilers;
     if (Program.Settings.DisplayProfilersSystem == ProfilersSystem.Client)
         allProfilers = ClientProfilers.AllProfilers;
     else
         allProfilers = PhysicsProfilers.AllProfilers;
     foreach (var v in allProfilers)
     {
         float ind = 10 * v.Indentation;
         var pb = new ProgressBar
         {
             Position = new Vector2(ind, y += 20),
             Size = new Vector2(200, 20),
             TextAnchor = global::Graphics.Orientation.Left,
         };
         profilers.Add(new Common.Tuple<Profiler, ProgressBar>(v, pb));
         AddChild(pb);
     }
 }