void fill_schedule(Train tr, int assign) { /* Here we do the actual adding of the text. It's done once for * each row. */ int i, tt; TimeTableView clist; Train t; ImageList icons = new ImageList(48, 16); listed_trains.Clear(); num_listed_trains = 0; for (t = tr; t != null; t = t.next) { ++num_listed_trains; } // if(num_listed_trains != 0) // listed_trains = (Train**)calloc(sizeof(Train*), num_listed_trains); for (tt = 0; tt < Configuration.NUMTTABLES; ++tt) { clist = GlobalVariables.traindir.m_frame.m_timeTableManager.GetTimeTable(tt); if (clist != null) { continue; } clist.DeleteAllItems(); clist.Freeze(); i = 0; for (t = tr; t != null; t = t.next) { /* when reassigning train stock, we consider only * trains that are scheduled to depart at the same * station where the assignee has arrived. */ /// if(assign && (t.status != train_READY || /// !sameStation(oldtrain.position.station, t.entrance))) /// continue; if (t.entrance != null) { continue; } if (GlobalFunctions.ignore_train(t)) { continue; } if (GlobalVariables.show_canceled || GlobalFunctions.is_canceled(t) == false) { //print_train_info(t); TrainInfo info = new TrainInfo(); t.Get(info); clist.InsertItem(i, info.entering_time, t.epix); clist.UpdateItem(i, t); listed_trains[i] = t; ++i; } } clist.Thaw(); } }
// // // public void UpdateItem(int i, Train t) { ListItem item = new ListItem(); String notes = ""; int n; TrainInfo info = new TrainInfo(); t.Get(info); SetItem(i, 1, t.entrance); SetItem(i, 0, info.entering_time); SetItem(i, 2, t.exit); SetItem(i, 3, info.leaving_time); SetItem(i, 4, t.name); SetItem(i, 5, info.current_speed); SetItem(i, 6, info.current_delay); SetItem(i, 7, info.current_late); SetItem(i, 8, info.current_status); for (n = 0; n < Configuration.MAXNOTES; ++n) { notes += t.notes[n] != null ? t.notes[n] : wxPorting.T(""); notes += wxPorting.T(" "); } SetItem(i, 9, notes); item.Id = i; GetItem(item); item.TextColour = Colour.wxGREEN; item.BackgroundColour = Colour.wxWHITE; item.Data = t; switch (t.status) { case trainstat.train_READY: if (t.days != RunDays.None && (t.days & GlobalVariables.run_day) != RunDays.None) { // wxColour fg(64, 64, 64); // item.SetTextColour(fg); item.TextColour = GlobalVariables.traindir.m_colorCanceled; break; } else { item.TextColour = GlobalVariables.traindir.m_colorReady; //*wxBLUE); break; } case trainstat.train_ARRIVED: if (!GlobalVariables.show_arrived) { item.TextColour = Colour.wxLIGHT_GREY; } else { item.TextColour = GlobalVariables.traindir.m_colorArrived; //*wxGREEN); } break; case trainstat.train_DERAILED: item.TextColour = GlobalVariables.traindir.m_colorDerailed; //*wxRED); break; case trainstat.train_WAITING: item.BackgroundColour = GlobalVariables.traindir.m_colorWaiting; item.TextColour = Colour.wxRED; break; case trainstat.train_STOPPED: item.TextColour = GlobalVariables.traindir.m_colorStopped; break; default: // running item.TextColour = GlobalVariables.traindir.m_colorRunning; //*wxBLACK); break; } SetItem(item); }