Exemplo n.º 1
0
        public void TuneEndWithinDesktopViewRange()
        {
            //         |-----------|
            //   |=====|=====|     |
            //  400   500   600   700
            //
            var window = new Range(500, 700);
            var tune   = new Tune(_mockFrameData.Object)
            {
                StartTick = 400
            };

            var firstVisibleTuneTick = Math.Max(window.Minimum, tune.StartTick);

            Assert.Equal(500, firstVisibleTuneTick);

            var lastVisibleTuneTick = Math.Min(window.Maximum, tune.EndTick);

            Assert.Equal(600, lastVisibleTuneTick);

            var offsetIntoTune = Math.Max(0, window.Minimum - tune.StartTick);

            Assert.Equal(100, offsetIntoTune);

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));

            Assert.Equal(100, visibleTicks);
        }
Exemplo n.º 2
0
        public void TuneStraddlesDesktopViewRange()
        {
            //        |-----|-----|
            //  |=====|===========|=====|
            // 400   500         700   800

            _mockFrameData.Setup(f => f.Length).Returns(400);

            var window = new Range(500, 700);
            var tune   = new Tune(_mockFrameData.Object)
            {
                StartTick = 400
            };

            var firstVisibleTuneTick = Math.Max(window.Minimum, tune.StartTick);

            Assert.Equal(500, firstVisibleTuneTick);

            var lastVisibleTuneTick = Math.Min(window.Maximum, tune.EndTick);

            Assert.Equal(700, lastVisibleTuneTick);

            var offsetIntoTune = Math.Max(0, window.Minimum - tune.StartTick);

            Assert.Equal(100, offsetIntoTune);

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));

            Assert.Equal(200, visibleTicks);
        }
Exemplo n.º 3
0
        public void TuneNotInRange(int startTick)
        {
            //               |-----|
            //   |=====|     |     |     |=====|
            //  400   500   600   700   800   900
            //

            _mockFrameData.Setup(f => f.Length).Returns(100);

            var window = new Range(600, 700);
            var tune   = new Tune(_mockFrameData.Object)
            {
                StartTick = startTick
            };

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));

            Assert.Equal(-100, visibleTicks);
        }
Exemplo n.º 4
0
        public void TuneEndWithinDesktopViewRange()
        {
            //         |-----------|
            //   |=====|=====|     |
            //  400   500   600   700
            //
            var window = new Range(500, 700);
            var tune = new Tune(_mockFrameData.Object) { StartTick = 400 };

            var firstVisibleTuneTick = Math.Max(window.Minimum, tune.StartTick);
            Assert.Equal(500, firstVisibleTuneTick);

            var lastVisibleTuneTick = Math.Min(window.Maximum, tune.EndTick);
            Assert.Equal(600, lastVisibleTuneTick);

            var offsetIntoTune = Math.Max(0, window.Minimum - tune.StartTick);
            Assert.Equal(100, offsetIntoTune);

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));
            Assert.Equal(100, visibleTicks);
        }
Exemplo n.º 5
0
        public void TuneStraddlesDesktopViewRange()
        {
            //        |-----|-----|
            //  |=====|===========|=====|
            // 400   500         700   800

            _mockFrameData.Setup(f => f.Length).Returns(400);

            var window = new Range(500, 700);
            var tune = new Tune(_mockFrameData.Object) { StartTick = 400 };

            var firstVisibleTuneTick = Math.Max(window.Minimum, tune.StartTick);
            Assert.Equal(500, firstVisibleTuneTick);

            var lastVisibleTuneTick = Math.Min(window.Maximum, tune.EndTick);
            Assert.Equal(700, lastVisibleTuneTick);

            var offsetIntoTune = Math.Max(0, window.Minimum - tune.StartTick);
            Assert.Equal(100, offsetIntoTune);

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));
            Assert.Equal(200, visibleTicks);
        }
Exemplo n.º 6
0
        private void On_Load()
        {
            _tunes = new List<Tune>();

            //var p = new Project { TuneFilenames = new[] { "abc", "def" } };
            //string x = JsonConvert.SerializeObject(p);

            var fileConverterFactory = new FileConverterFactory(new FileSystemHelper());

            try
            {
                var project = Project.OpenProject(Path.Combine(Directory.GetCurrentDirectory(), "TestProject"));

                foreach (var fileName in project.TuneFilenames)
                {
                    var metaDataPath = Path.Combine(project.WorkingFolder, "MetaData");
                    Directory.CreateDirectory(metaDataPath);

                    var tunePath = Path.Combine(project.WorkingFolder, fileName);

                    var rawTunePath = Path.ChangeExtension(Path.Combine(metaDataPath, fileName), "m6raw");
                    var summaryPath = Path.ChangeExtension(Path.Combine(metaDataPath, fileName), "summary");

                    IFileConverter converter;
                    if ((converter = fileConverterFactory.ParseFile(rawTunePath)) == null)
                    {
                        converter = fileConverterFactory.ParseFile(tunePath);
                    }
                    if (converter == null) continue;

                    var waveData = converter.ProcessFile();
                    if (waveData == null) continue;

                    if (!File.Exists(rawTunePath))
                    {
                        try
                        {
                            using (var rawFile = File.Create(rawTunePath))
                            {
                                Serializer.Serialize(rawFile, waveData);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }

                    var tune = new Tune(waveData);

                    SummaryCollection summaryData = null;
                    try
                    {
                        using (var summaryFile = File.OpenRead(summaryPath))
                        {
                            summaryData = Serializer.Deserialize<SummaryCollection>(summaryFile);
                        }

                        tune.SummaryCollection = summaryData;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }

                    if (summaryData == null)
                    {
                        tune.BuildSummaries();
                        try
                        {
                            using (var summaryFile = File.Create(summaryPath))
                            {
                                Serializer.Serialize(summaryFile, tune.SummaryCollection);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }

                    tune.StartTick = 0;
                    tune.Track = _tunes.Count;

                    _tunes.Add(tune);
                }

                _delta = new Delta();

                _ticksPerPixel = 1024;

                _bbBitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);

                _desktopRange = new Range(0, ClientRectangle.Width*_ticksPerPixel);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 7
0
 public void TheseRangesDoNotAppearInTheViewport(int min, int max)
 {
     var viewport = new Range(1000, 3000);
     var testRange = new Range(min, max);
     Assert.False(viewport.ContainsOrIntersectsWithRange(testRange));
 }
Exemplo n.º 8
0
 public void TheseRangesIntersectOrAreContainedByTheViewport(int min, int max)
 {
     var viewport = new Range(1000, 3000);
     var testRange = new Range(min, max);
     Assert.True(viewport.ContainsOrIntersectsWithRange(testRange));
 }
Exemplo n.º 9
0
        public void TuneNotInRange(int startTick)
        {
            //               |-----|
            //   |=====|     |     |     |=====|
            //  400   500   600   700   800   900
            //

            _mockFrameData.Setup(f => f.Length).Returns(100);

            var window = new Range(600, 700);
            var tune = new Tune(_mockFrameData.Object) { StartTick = startTick };

            var visibleTicks = Math.Min(window.Width, Math.Min(window.Maximum - tune.StartTick, tune.EndTick - window.Minimum));
            Assert.Equal(-100, visibleTicks);
        }