Example #1
0
        private void ToolbarOpen_Click(object sender, RoutedEventArgs e)
        {
            Textbox.Text      = "";
            Textbox.IsEnabled = true;
            var openFileDialog1 = new OpenFileDialog {
                Filter = @"Note Recorder Files|*.nr"
            };
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK) // Test result.
            {
                ZipArchive zip = ZipFile.OpenRead(openFileDialog1.FileName);
                try
                {
                    Directory.Delete("CurrentWorkingDirectory", true);
                }
                catch (DirectoryNotFoundException)
                {
                }

                zip.ExtractToDirectory("CurrentWorkingDirectory");
                Stream stream         = File.Open("CurrentWorkingDirectory" + "\\data.nr", FileMode.Open);
                var    bFormatter     = new BinaryFormatter();
                var    recoveredState = (SaveObject)bFormatter.Deserialize(stream);
                _currentSave = recoveredState;
                stream.Close();
                _timesForNote      = recoveredState.SectionOccurances;
                Textbox.Text       = recoveredState.TheNote;
                _textBackup        = recoveredState.TheNote;
                _recordingDuration = recoveredState.RecordingDuration;
                theSlider.Maximum  = _recordingDuration;
                _savedRecordingAs  = Directory.GetCurrentDirectory() + "\\CurrentWorkingDirectory" + "\\recording.wav";
                _currentSave       = new SaveObject(_recordingDuration, _timesForNote, recoveredState.TheNote,
                                                    _savedRecordingAs);
                _currentOpenNoteLocation = openFileDialog1.FileName;
            }
        }