Example #1
0
        private TrainEditForm(Timetable tt)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            this.tt = tt;

            th = new TrainEditHelper();

            nameValidator = new NotEmptyValidator(nameTextBox, errorMessage: T._("Bitte einen Zugnamen eingeben!"));

            locomotiveComboBox.Items.AddRange(GetAllItems(tt, t => t.Locomotive));
            lastComboBox.Items.AddRange(GetAllItems(tt, t => t.Last));
            mbrComboBox.Items.AddRange(GetAllItems(tt, t => t.Mbr));

            KeyDown += (s, e) => daysControl.HandleKeypress(e);

            resetTransitionButton.TextColor = Colors.Red;

            if (tt.Type == TimetableType.Network && tt.Version.CompareTo(TimetableVersion.Extended_FPL2) < 0)
            {
                linkGroupBox.Visible = false;
            }
            else
            {
                linkGridView.AddColumn <TrainLink>(tl => tl.TrainCount.ToString(), T._("Anzahl"));
                linkGridView.AddColumn <TrainLink>(tl => tl.TimeOffset.ToTimeString(), T._("Erster Abstand"));
                linkGridView.AddColumn <TrainLink>(tl => tl.TimeDifference.ToTimeString(), T._("Zeitdifferenz"));
            }
        }
Example #2
0
        private void CloseButton_Click(object sender, EventArgs e)
        {
            if (direction == TrainDirection.tr && !sortSelection.EnabledOptionSelected)
            {
                MessageBox.Show(T._("Die gewählte Option ist im Netzwerk-Fahrplan nicht verfügbar."), "FPLedit");
                return;
            }

            var th = new TrainEditHelper();

            switch (sortSelection.SelectedState)
            {
            case SortSelectionType.Name:        th.SortTrainsName(tt, direction, false); break;

            case SortSelectionType.TrainNumber: th.SortTrainsName(tt, direction, true); break;

            case SortSelectionType.TimeStation: th.SortTrainsAtStation(tt, direction, (Station)stationsComboBox.SelectedValue); break;

            case SortSelectionType.TimeDown:    th.SortTrainsAllStations(tt, direction, true); break;

            case SortSelectionType.TimeUp:      th.SortTrainsAllStations(tt, direction, false); break;
            }

            Close(DialogResult.Ok);
        }
        private void CloseButton_Click(object sender, EventArgs e)
        {
            changeValidator.Enabled = origLink.TrainNamingScheme is AutoTrainNameGen;
            var validators = new ValidatorCollection(differenceValidator, differenceValidator, changeValidator, offsetValidator);

            if (!validators.IsValid)
            {
                MessageBox.Show(T._("Bitte erst alle Felder korrekt ausfüllen:\n{0}", validators.Message));
                Result = DialogResult.None;
                return;
            }

            var th     = new TrainEditHelper();
            var offset = TimeEntry.Parse(startOffsetTextBox.Text);
            var diff   = TimeEntry.Parse(differenceTextBox.Text);

            var count = int.Parse(countTextBox.Text);

            ITrainNameGen tnc;

            switch (origLink.TrainNamingScheme)
            {
            // Create new link.
            case AutoTrainNameGen _:
                var add = int.Parse(changeTextBox.Text);
                tnc = new AutoTrainNameGen(nameTextBox.Text, add);
                break;

            case SpecialTrainNameGen _:
                var entries = ((SpecialNameEntry[])specialNameGridView.DataStore).Select(en => en.Name).ToArray();
                if (entries.Any(string.IsNullOrEmpty))
                {
                    MessageBox.Show(T._("Es wurden keinen Namen für alle Züge angegeben!"));
                    return;
                }
                tnc = new SpecialTrainNameGen(entries);
                break;

            default:
                throw new NotSupportedException("Not Implemented: Name calculator not supported!");
            }

            tt.RemoveLink(origLink);                               // Remove old link.
            th.LinkTrainMultiple(train, offset, diff, count, tnc); // Create new link.

            Close(DialogResult.Ok);
        }
Example #4
0
        private void CloseButton_Click(object sender, EventArgs e)
        {
            var copy = modeSelect.SelectedState == CopySelectionMode.Copy || modeSelect.SelectedState == CopySelectionMode.Link;

            if (!diffValidator.Valid || (copy && (!countValidator.Valid || !changeValidator.Valid)))
            {
                var msg = diffValidator.Valid ? "" : diffValidator.ErrorMessage + Environment.NewLine;
                if (copy)
                {
                    msg += countValidator.Valid ? "" : countValidator.ErrorMessage + Environment.NewLine;
                    msg += changeValidator.Valid ? "" : changeValidator.ErrorMessage + Environment.NewLine;
                }
                MessageBox.Show(T._("Bitte erst alle Felder korrekt ausfüllen:\n{0}", msg));
                Result = DialogResult.None;
                return;
            }

            var th   = new TrainEditHelper();
            var diff = int.Parse(diffTextBox.Text);

            if (modeSelect.SelectedState == CopySelectionMode.Copy)
            {
                var count = int.Parse(countTextBox.Text);
                var add   = int.Parse(changeTextBox.Text);

                var trains = th.CopyTrainMultiple(train, diff, nameTextBox.Text, copyAllCheckBox.Checked.Value, count, add);

                foreach (var newTrain in trains)
                {
                    if (tt.Trains.Any(t => t.TName == newTrain.TName))
                    {
                        if (MessageBox.Show(T._("Es ist bereits ein Zug mit der Zugnummer {0} in diesem Fahrplan vorhanden, soll diese Kopie trotzdem angelegt werden?", newTrain.TName),
                                            T._("Züge kopieren"), MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            continue;
                        }
                    }

                    tt.AddTrain(newTrain);
                }
            }
            else if (modeSelect.SelectedState == CopySelectionMode.Link)
            {
                var           count = int.Parse(countTextBox.Text);
                ITrainNameGen tnc;

                switch (linkSelect.SelectedState)
                {
                case LinkTypeMode.Auto:
                    var add = int.Parse(changeTextBox.Text);
                    tnc = new AutoTrainNameGen(nameTextBox.Text, add);
                    break;

                case LinkTypeMode.Special:
                    var entries = ((SpecialNameEntry[])specialNameGridView.DataStore).Select(en => en.Name).ToArray();
                    if (entries.Any(string.IsNullOrEmpty))
                    {
                        MessageBox.Show(T._("Es wurden keinen Namen für alle Züge angegeben!"));
                        return;
                    }
                    tnc = new SpecialTrainNameGen(entries);
                    break;

                default:
                    throw new NotSupportedException("The selected LinkTypeMode is not defined!");
                }

                th.LinkTrainMultiple(train, TimeEntry.Zero, new TimeEntry(0, diff), count, tnc);
            }
            else
            {
                th.MoveTrain(train, diff);
            }

            Close(DialogResult.Ok);
        }