コード例 #1
0
ファイル: EditScheduleForm.cs プロジェクト: Sacro/SimSigWTT
        private void associationAddButton_Click(object sender, EventArgs e)
        {
            locationAssociationsListBox.SelectedItem = null;
            LoadAssociationControls();

            selectedAssociation = new association();
            var foos = new List<association>(selectedLocation.association);
            foos.Add(selectedAssociation);
            selectedLocation.association = foos.ToArray();
            locationAssociationsListBox.SelectedIndex = locationAssociationsListBox.Items.Add(selectedAssociation);
            LoadAssociationControls();
            associationScheduleComboBox.Focus();
        }
コード例 #2
0
ファイル: EditScheduleForm.cs プロジェクト: Sacro/SimSigWTT
        private void LoadAssociationControls()
        {
            if (locationAssociationsListBox.SelectedIndex >= 0)
            {
                associationGroupBox.Enabled = true;
                selectedAssociation = locationAssociationsListBox.SelectedItem as association;

                loadingAssociation = true;

                selectedAssociation.Owner = selectedLocation;

                // Association IDs
                associationScheduleComboBox.Items.Clear();
                //associationScheduleComboBox.Items.AddRange(Timetable.schedule);
                foreach (schedule sched in Timetable.schedule)
                {
                    // Add schedule if it originates at this location
                    if (sched.GetFirstLocation() == locationLocationTextBox.Text)
                    {
                        scheduleLocation firstLoc = sched.scheduleLocation[0];
                        if (firstLoc.platformCode == platformComboBox.Text)
                        {
                            associationScheduleComboBox.Items.Add(sched);
                        }
                    }
                    // Add schedule if it terminates at this location - seperate from above "if" so that
                    // originating and terminating trains at the same location are included correctly
                    if (sched.GetLastLocation() == locationLocationTextBox.Text)
                    {
                        scheduleLocation lastLoc = sched.scheduleLocation[sched.scheduleLocation.Length - 1];
                        if ((lastLoc.platformCode == platformComboBox.Text) && (!associationScheduleComboBox.Items.Contains(sched)))
                        {
                            associationScheduleComboBox.Items.Add(sched);
                        }
                    }
                    if (sched.scheduleID == selectedAssociation.referenceID)
                    {
                        associationScheduleComboBox.SelectedItem = sched;
                    }
                }

                associationTypeComboBox.SelectedIndex = (int)selectedAssociation.associationType;
                associationDaysCheckedListBox.SetItemChecked(0, selectedAssociation.days.monday);
                associationDaysCheckedListBox.SetItemChecked(1, selectedAssociation.days.tuesday);
                associationDaysCheckedListBox.SetItemChecked(2, selectedAssociation.days.wednesday);
                associationDaysCheckedListBox.SetItemChecked(3, selectedAssociation.days.thursday);
                associationDaysCheckedListBox.SetItemChecked(4, selectedAssociation.days.friday);
                associationDaysCheckedListBox.SetItemChecked(5, selectedAssociation.days.saturday);
                associationDaysCheckedListBox.SetItemChecked(6, selectedAssociation.days.sunday);

                if (selectedAssociation.startDate.Year > 1) associationStartDateTimePicker.Value = selectedAssociation.startDate;
                UpdateDateTime(associationStartDateTimePicker, associationStartCheckBox);
                associationStartCheckBox.Checked = selectedAssociation.startDateSpecified;

                if (selectedAssociation.endDate.Year > 1) associationEndDateTimePicker.Value = selectedAssociation.endDate;
                UpdateDateTime(associationEndDateTimePicker, associationEndCheckBox);
                associationEndCheckBox.Checked = selectedAssociation.endDateSpecified;

                loadingAssociation = false;
            }
            else
            {
                associationGroupBox.Enabled = false;
                selectedAssociation = null;
            }
        }
コード例 #3
0
ファイル: EditScheduleForm.cs プロジェクト: Sacro/SimSigWTT
 private void associationDeleteButton_Click(object sender, EventArgs e)
 {
     if (locationAssociationsListBox.SelectedItem != null)
     {
         association ass = locationAssociationsListBox.SelectedItem as association;
         if (MessageBox.Show("Delete " + ass.ToString() + "?", "Delete", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
         {
             var foos = new List<association>(selectedLocation.association);
             foos.Remove(ass);
             selectedLocation.association = foos.ToArray();
             selectedAssociation = null;
             locationAssociationsListBox.Items.Remove(ass);
             LoadAssociationControls();
         }
     }
 }