Example #1
0
        private void LoadLine()
        {
            if (tt.Stations.Count != 0)
            {
                return;
            }
            if (info.Timetable.Type == TimetableType.Network)
            {
                throw new Exception("Streckendateien können bei Netzwerk-Fahrplänen nicht geladen werden!");
            }

            IImport timport = new XMLImport();
            IImport simport = new NonDefaultFiletypes.XMLStationsImport();

            using (var ofd = new OpenFileDialog())
            {
                ofd.AddLegacyFilter(timport.Filter, simport.Filter);

                if (ofd.ShowDialog(this) == DialogResult.Ok)
                {
                    IImport import = Path.GetExtension(ofd.FileName) == ".fpl" ? timport : simport;
                    var     ntt    = import.Import(ofd.FileName, info);
                    foreach (var station in ntt.Stations)
                    {
                        tt.AddStation(station, Timetable.LINEAR_ROUTE_ID);
                    }
                    // ntt will be destroyed by decoupling stations, do not use afterwards!
                }
            }

            UpdateStations();
        }
Example #2
0
        private void ChooseJtgButton_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.Title = T._("jTrainGraph-Programmdatei wählen");
                ofd.AddLegacyFilter(T._("JAR-Dateien (*.jar)|*.jar"));

                if (!string.IsNullOrWhiteSpace(jtgPathTextBox.Text))
                {
                    var directory = Path.GetDirectoryName(jtgPathTextBox.Text);
                    if (Directory.Exists(directory))
                    {
                        ofd.Directory = new Uri(directory);
                    }
                }

                if (ofd.ShowDialog(this) == DialogResult.Ok)
                {
                    jtgPathTextBox.Text = ofd.FileName;

                    JtgShared.JtgCompatCheck(jtgPathTextBox.Text, out var compatVersion);
                    if (compatVersion.HasValue)
                    {
                        versionComboBox.SelectedValue = versionComboBox.DataStore.
                                                        FirstOrDefault(i => ((VersionItem)i).Version == compatVersion);
                    }
                }
            }
        }
Example #3
0
        public FileHandler(Window parent, IInfo info, ILastFileHandler lfh, UndoManager undo)
        {
            this.parent = parent;
            this.info   = info;
            this.lfh    = lfh;
            this.undo   = undo;

            FileState = new FileState();
            FileState.FileStateInternalChanged += (s, e) => OnFileStateChanged();

            open = new XMLImport();
            save = new XMLExport();

            saveFileDialog   = new SaveFileDialog();
            openFileDialog   = new OpenFileDialog();
            exportFileDialog = new SaveFileDialog();
            importFileDialog = new OpenFileDialog();

            saveFileDialog.AddLegacyFilter(save.Filter);
            openFileDialog.AddLegacyFilter(open.Filter);

            FileOpened += (s, e) => MaybeUpgradeTtVersion();

            SetLastPath(info.Settings.Get("files.lastpath", ""));
        }
Example #4
0
        private void chooseJtgButton_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.AddLegacyFilter("JAR-Dateien (*.jar)|*.jar");
                if (ofd.ShowDialog(this) == DialogResult.Ok)
                {
                    jtgPathTextBox.Text = ofd.FileName;

                    var compat = JTGShared.JTGCompatCheck(jtgPathTextBox.Text);
                    if (compat.Version.HasValue)
                    {
                        versionComboBox.SelectedValue = versionComboBox.DataStore.
                                                        FirstOrDefault(i => ((VersionItem)i).Version == compat.Version);
                    }
                }
            }
        }
Example #5
0
 private void ViewDump_Click(object sender, EventArgs e)
 {
     using (var ofd = new OpenFileDialog())
     {
         ofd.Title = T._("Dump auswählen");
         ofd.AddLegacyFilter("*.fpldmp|*.fpldmp");
         if (ofd.ShowDialog(this) == DialogResult.Ok)
         {
             try
             {
                 var reader = new DumpReader(ofd.FileName);
                 var events = reader.Events;
                 using (var isf = new InspectForm(events))
                     isf.ShowModal();
             }
             catch
             {
                 MessageBox.Show(T._("Fehler beim Öffnen der Datei."));
             }
         }
     }
 }