예제 #1
0
        private void SaveDoWork(object sender, DoWorkEventArgs e)
        {
            string fileName = (string)e.Argument;

            FileStream stream = new FileStream(fileName, FileMode.Create,
                                               FileAccess.Write, FileShare.None);

            using (stream)
            {
                properties.Write(stream);

                TrackWriter writer = new TrackWriter();

                float percentage;

                for (int i = 0; i < tracks.Count && !saveWorker.CancellationPending; i++)
                {
                    writer.Track = tracks[i];
                    writer.Write(stream);

                    percentage = (i + 1f) / properties.TrackCount;

                    saveWorker.ReportProgress((int)(100 * percentage));
                }

                if (saveWorker.CancellationPending)
                {
                    e.Cancel = true;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Saves the Sequence as a Stream.
        /// </summary>
        /// <param name="stream">
        /// The stream to use for saving the sequence.
        /// </param>
        public void Save(Stream stream)
        {
            properties.Write(stream);

            TrackWriter writer = new TrackWriter();

            foreach (Track trk in tracks)
            {
                writer.Track = trk;
                writer.Write(stream);
            }
        }