Beispiel #1
0
        public double[] Load(string filePath, double framePeriod, int maxFrameLength)
        {
            framePeriod *= 0.001;
            Track[] tracks = null;
            try
            {
                using (var fs = new FileStream(filePath, FileMode.Open))
                {
                    tracks = LoadFromVsq4(fs);
                }
            }
            catch (Exception e)
            {
                throw new ScaleLoadException(LangResources.VsqLoader_FailLoadFile, e);
            }

            if (tracks.Length > 1)
            {
                double[] f0 = null;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var selectWindow    = new TrackSelectWindow();
                    selectWindow.Tracks = tracks;
                    selectWindow.ShowDialog();

                    if (selectWindow.Selected)
                    {
                        f0 = selectWindow.SelectedTrack.ToF0(framePeriod)
                             .Concat(EnumerableUtil.Infinity(0.0))
                             .Take(maxFrameLength).ToArray();
                    }
                });

                if (f0 != null)
                {
                    return(f0);
                }
                else
                {
                    throw new ScaleLoadException(LangResources.VsqLoader_CancelLoad);
                }
            }
            else
            {
                return(tracks[0].ToF0(framePeriod)
                       .Concat(EnumerableUtil.Infinity(0.0))
                       .Take(maxFrameLength).ToArray());
            }
        }
Beispiel #2
0
        public double[] Load(string filePath, double framePeriod, int maxFrameLength)
        {
            framePeriod *= 0.001;
            var tracks = LoadFile(filePath);

            if (tracks.Length < 1)
            {
                throw new ScaleLoadException(LangResources.VprLoader_TrackNotFound);
            }
            else if (tracks.Length > 1)
            {
                double[] f0 = null;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var selectWindow    = new TrackSelectWindow();
                    selectWindow.Tracks = tracks;
                    selectWindow.ShowDialog();

                    if (selectWindow.Selected)
                    {
                        f0 = selectWindow.SelectedTrack.ToF0(framePeriod)
                             .Concat(EnumerableUtil.Infinity(0.0))
                             .Take(maxFrameLength).ToArray();
                    }
                });

                if (f0 != null)
                {
                    return(f0);
                }
                else
                {
                    throw new ScaleLoadException(LangResources.VsqLoader_CancelLoad);
                }
            }
            else
            {
                return(tracks[0].ToF0(framePeriod)
                       .Concat(EnumerableUtil.Infinity(0.0))
                       .Take(maxFrameLength).ToArray());
            }
        }