Exemple #1
0
        private void importBtn_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = GetFileDialogFilter();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(
                Environment.SpecialFolder.MyDocuments);
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                var file = openFileDialog.FileName;

                try
                {
                    var docs = TrackFiles.ReadFromFile(file);
                    docs.ForEach(d => LoadXDoc(d));
                }
                catch (Exception ex)
                {
                    Log(ex);
                    this.ShowWarning($"Failed to load file {file}");
                }
            }
        }
Exemple #2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            var msg = TrackTypes
                      .Select(t => airwayNetwork.GetTrackMessage(t))
                      .Where(m => m != null)
                      .ToList();

            if (msg.Count == 0)
            {
                this.ShowWarning("No track has been downloaded or imported.");
                return;
            }

            var myDoc          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = GetFileDialogFilter();
            saveFileDialog.InitialDirectory = myDoc;
            saveFileDialog.RestoreDirectory = true;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                var file = saveFileDialog.FileName;

                try
                {
                    File.Delete(file);
                    TrackFiles.SaveToFile(msg, file);
                }
                catch (Exception ex)
                {
                    Log(ex);
                    this.ShowWarning("Failed to save file.");
                }
            }
        }