Пример #1
0
        /// <summary>
        /// Load relevant resources
        /// </summary>
        /// <param name="game">Provide access to the game.</param>
        /// <param name="contentManager">Provide access to the screen's content manager.</param>
        /// <param name="spriteBatch">Provide access to the screen's sprite batch.</param>
        public override void LoadContent(Game game, ContentManager contentManager, SpriteBatch spriteBatch)
        {
            if (contentManager == null)
            {
                return;
            }

            Texture2D = contentManager.Load <Texture2D>(@"UI\ReplayTile");
            contentManager.Load <Texture2D>(@"blank");
            _titleTexture     = CreateTitleTexture(game, contentManager, spriteBatch);
            _titleDestination = new Rectangle(
                (int)Position.X + MARGIN,
                (int)Position.Y + MARGIN,
                _titleTexture.Width,
                _titleTexture.Height
                );

            /** Grab the data off of the recording manager now because we don't have a reference to the game forever */
            RecordingManager recorder = (RecordingManager)game.Services.GetService(typeof(RecordingManager));

            _skeletons = recorder.ReadProcessedData(FileId);

            string[] axesNames  = { "Time (ms)", "Avg. Deviation\n\r(per 100ms)" };
            string   chartType  = "Time";
            bool     chartLines = true;
            bool     tickMarks  = false;
            float    repetitionDuration;

            float[] dataPoints = CalculateSkeletonChartLine(_skeletons, out repetitionDuration);
            float   timeSpan;

            timeSpan = dataPoints.Length;

            GuiChartOptions chartOptions = new GuiChartOptions(axesNames, chartType, chartLines, tickMarks, dataPoints, timeSpan, repetitionDuration);

            _chartTexture = new GuiChart(
                "Text",
                Size - new Vector2(MARGIN * 2, MARGIN + 40),
                Position + new Vector2(MARGIN - 7, _titleTexture.Height + 15),
                chartOptions
                );

            _chartTexture.LoadContent(game, contentManager, spriteBatch);

            _titleSource = new Rectangle(
                0,
                0,
                _titleTexture.Width,
                _titleTexture.Height
                );
        }
Пример #2
0
        /// <summary>
        /// GuiChart is a class that handles taking datapoints from the Summary Screen and creates a chart object to be displayed and returns a percentage
        /// value of where in the chart between x-axis begin and x-axis end the mouse was clicked.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="size"></param>
        /// <param name="position"></param>
        /// <param name="chartOptions"></param>
        public GuiChart(string text, Vector2 size, Vector2 position, GuiChartOptions chartOptions)
            : base(text, size, position)
        {
            _xAxisLabel  = chartOptions.AxesName[0];
            _yAxisLabel  = chartOptions.AxesName[1];
            _chartType   = chartOptions.ChartType;
            _tickMarks   = chartOptions.TickMarks;
            _dataPoints  = chartOptions.DataPoints;
            _timeSpan    = chartOptions.TimeInterval;
            _repDuration = chartOptions.RepDuration;
            _chartLines  = chartOptions.ChartLines;

            _position = position;
        }
Пример #3
0
        /// <summary>
        /// GuiChart is a class that handles taking datapoints from the Summary Screen and creates a chart object to be displayed and returns a percentage
        /// value of where in the chart between x-axis begin and x-axis end the mouse was clicked.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="size"></param>
        /// <param name="position"></param>
        /// <param name="chartOptions"></param>
        public GuiChart(string text, Vector2 size, Vector2 position, GuiChartOptions chartOptions)
            : base(text, size, position)
        {
            _xAxisLabel = chartOptions.AxesName[0];
            _yAxisLabel = chartOptions.AxesName[1];
            _chartType = chartOptions.ChartType;
            _tickMarks = chartOptions.TickMarks;
            _dataPoints = chartOptions.DataPoints;
            _scale = chartOptions.Scale;
            _timeSpan = chartOptions.TimeInterval;
            _repDuration = chartOptions.RepDuration;
            _chartLines = chartOptions.ChartLines;

            _position = position;
        }
Пример #4
0
        public void ClickMouse()
        {
            _timeSpan = _dataPoints.Length;

            _guiChartOptions = new GuiChartOptions(_axesNames, ChartType, ChartLines, TickMarks, Scale, _dataPoints, _timeSpan, RepDuration);
            _guiChart = new GuiChart("Title", new Vector2(1024, 780), Vector2.Zero, _guiChartOptions);
            _guiChart.LoadContent(_game, _contentManager, _spriteBatch);

            MouseState currentMouseState = new MouseState(
                    50,
                    50,
                    0,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released
                );

            MouseState oldMouseState = new MouseState(
                    currentMouseState.X,
                    currentMouseState.Y,
                    currentMouseState.ScrollWheelValue,
                    ButtonState.Released,
                    currentMouseState.MiddleButton,
                    currentMouseState.RightButton,
                    currentMouseState.XButton1,
                    currentMouseState.XButton2
                );

            Assert.IsNotNull(currentMouseState);
            Assert.IsNotNull(oldMouseState);

            GameTime gt = new GameTime(new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 0, 0, 100));

            _guiChart.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), gt);

            Assert.IsNotNull(_guiChart.MouseXCoord);
            Assert.IsNotNull(_guiChart.MouseYCoord);

            Assert.IsNotNull(_guiChart.MouseXPercent);
            Assert.IsNotNull(_guiChart.MouseYPercent);
            Assert.Pass("GuiChart.Update passed.");
        }
Пример #5
0
        public void CreateXAxisTexture()
        {
            _timeSpan = _dataPoints.Length;

            _guiChartOptions = new GuiChartOptions(_axesNames, ChartType, ChartLines, TickMarks, Scale, _dataPoints, _timeSpan, RepDuration);
            _guiChart = new GuiChart("Title", new Vector2(1024, 780), Vector2.Zero, _guiChartOptions);

            Texture2D testing = _guiChart.CreateXAxisTitleTexture(_game, _contentManager, _spriteBatch);

            FileStream fs = File.Open(@"c:\school\Chart_X-Axis.png", FileMode.Create);
            testing.SaveAsPng(fs, testing.Width, testing.Height);
            fs.Close();

            Assert.IsNotNull(testing);
            Assert.Pass("GuiChart.CreateXAxisTitleTexture passed.");
        }