Exemplo n.º 1
0
        private void closeButton_Click(object sender, EventArgs e)
        {
            if (direction == TrainDirection.tr && !sortSelection.EnabledOptionSelected)
            {
                MessageBox.Show("Die gewählte Option ist im Netzwerk-Fahrplan nicht verfügbar.", "FPLedit");
                return;
            }

            var th = new TrainEditHelper();

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

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

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

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

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

            Close(DialogResult.Ok);
        }
Exemplo n.º 2
0
        private void fillButton_Click(object sender, EventArgs e)
        {
            using (var tfd = new TrainFillDialog(Train))
            {
                if (tfd.ShowModal() == DialogResult.Ok)
                {
                    var th = new TrainEditHelper();
                    th.FillTrain(tfd.ReferenceTrain, Train, tfd.Offset);

                    editor.Initialize(Train._parent, Train);
                }
            }
        }
Exemplo n.º 3
0
        private void closeButton_Click(object sender, EventArgs e)
        {
            var copy = modeSelect.SelectedState == 0;

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

            var th     = new TrainEditHelper();
            var offset = int.Parse(offsetTextBox.Text);

            if (copy)
            {
                var count = int.Parse(countTextBox.Text);
                var add   = int.Parse(changeTextBox.Text);

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

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

                    tt.AddTrain(newTrain, true);
                }
            }
            else
            {
                th.MoveTrain(train, offset);
            }

            Close(DialogResult.Ok);
        }
Exemplo n.º 4
0
        private TrainEditForm(Timetable tt)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            this.tt = tt;

            th = new TrainEditHelper();

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

            daysBoxes = new[] { mondayCheckBox, tuesdayCheckBox, wednesdayCheckBox, thursdayCheckBox, fridayCheckBox, saturdayCheckBox, sundayCheckBox };
            foreach (var dayBox in daysBoxes)
            {
                dayBox.CheckedChanged += CheckBoxStateChanged;
            }

            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) =>
            {
                if (!e.Control)
                {
                    return;
                }

                var handled = true;
                if (new[] { Keys.D0, Keys.Keypad0 }.Contains(e.Key))
                {
                    ApplyShortcut(zShortcut);
                }
                else if (e.Key == Keys.A)
                {
                    ApplyShortcut(aShortcut);
                }
                else if (e.Key == Keys.W && e.Shift)
                {
                    ApplyShortcut(wExclSaShortcut);
                }
                else if (e.Key == Keys.W)
                {
                    ApplyShortcut(wShortcut);
                }
                else if (e.Key == Keys.S)
                {
                    ApplyShortcut(sShortcut);
                }
                else
                {
                    handled = false;
                }

                e.Handled = handled;
            };

            var shortcutsButtons = new[] { wShort, wSaShort, sShort, aShort, zShort };
            var shortcuts        = new[] { wShortcut, wExclSaShortcut, sShortcut, aShortcut, zShortcut };

            shortcutsToggle = new ToggleButton[shortcuts.Length];
            for (int i = 0; i < shortcutsButtons.Length; i++)
            {
                var toggle = new ToggleButton(shortcutsButtons[i])
                {
                    Tag          = shortcuts[i],
                    AllowDisable = false
                };
                toggle.ToggleClick += ApplyShortcutBtn;
                shortcutsToggle[i]  = toggle;
            }
        }