public Bus(List <RoadPoint> route, String name, Canvas parent, Brush color) { this.Route = route; this.BusLineName = name; this.OnBoard = new HashSet <Passenger>(); this.Stops = new List <string>(); this.Parent = parent; this.BusColor = color; this.traces = new List <Point[]>(); this.netComm = new BusNetComm(); this.pasb = new Storyboard(); BusImage = new Image(); BusImage.Source = new BitmapImage((new Uri(@"Img\bus.bmp", UriKind.Relative))); BusImage.Height = 20; BusImage.Width = 20; BusImage.ToolTip = this.BusLineName; BusImage.MouseEnter += MouseOverEventHandler; BusImage.MouseLeave += MouseLeaveEventHandler; this.Parent.Children.Add(this.BusImage); int i = 0; this.points = new Point[Route.Count]; foreach (RoadPoint rd in Route) { if (rd is RoadStop) { RoadStop rs = (RoadStop)rd; Stops.Add(rs.StopName); } points[i] = rd.Coordinate; i++; } }
static void Main(string[] args) { try { //start to listen for receving request ServerNetComm serverNetComm = new ServerNetComm(); //TODO:这里仅仅是为了编码而模拟BUS自动向SERVER发消息,日后清除 BusNetComm busNetComm = new BusNetComm(); //if the thread reports aborted we can know there are bugs in that field do { if (serverNetComm.ListenThread.ThreadState == ThreadState.AbortRequested || serverNetComm.ListenThread.ThreadState == ThreadState.Aborted) { throw new Exception("serverNetComm.ListenThread stop abnomally"); } }while(serverNetComm.ListenThread.ThreadState == ThreadState.Running); Environment.Exit(0); } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString()); Environment.Exit(-1); } }