Exemplo n.º 1
0
        public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval)
            : base(parent)
        {
            if (statistic == null)
                throw new ArgumentNullException("statistic");

            if (accessInterval == TimeSpan.Zero)
                accessInterval = TimeSpan.FromMilliseconds(16);

            Strata = new ControlStrata() { Layer = Layer.Overlay };
            _tracker = new StatisticTracker(statistic, accessInterval);
            _graph = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60));
            _label = new Label(this, font) {
                Text = statistic.Name,
                Justification = Justification.Centre
            };
            _label.SetPoint(Points.TopLeft, 2, 2);
            _label.SetPoint(Points.TopRight, -2, 2);

            _value = new Label(this, font) {
                Text = "0",
                Justification = Justification.Centre
            };
            _value.SetPoint(Points.BottomLeft, 2, -2);
            _value.SetPoint(Points.BottomRight, -2, -2);

            _texture = new Texture2D(Device, 1, 1);
            _texture.SetData<Color>(new Color[] { new Color(0, 0, 0, 0.8f) });

            SetSize(200, 120);
        }
Exemplo n.º 2
0
        public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval)
            : base(parent)
        {
            if (statistic == null)
            {
                throw new ArgumentNullException("statistic");
            }

            if (accessInterval == TimeSpan.Zero)
            {
                accessInterval = TimeSpan.FromMilliseconds(16);
            }

            Strata = new ControlStrata()
            {
                Layer = Layer.Overlay
            };
            tracker             = new StatisticTracker(statistic, accessInterval);
            graph               = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60));
            label               = new Label(this, font);
            label.Text          = statistic.Name;
            label.Justification = Justification.Centre;
            label.SetPoint(Points.TopLeft, 2, 2);
            label.SetPoint(Points.TopRight, -2, 2);

            value               = new Label(this, font);
            value.Text          = "0";
            value.Justification = Justification.Centre;
            value.SetPoint(Points.BottomLeft, 2, -2);
            value.SetPoint(Points.BottomRight, -2, -2);

            texture = new Texture2D(Device, 1, 1);
            texture.SetData <Color>(new Color[] { new Color(0, 0, 0, 0.8f) });

            SetSize(200, 120);
        }