private void canvas_MouseMove(object sender, MouseEventArgs e) { // Custom zoom if (isCustomZoomActivated && isDrawingZoomRect) { DrawZoomRect(e.GetPosition(this)); return; } // Display mouse location Transformation.MouseLocation = e.GetPosition(this); // Hit carriage view VCarriage ca = HitCarriage(e.GetPosition(this)); if (ca != Transformation.HitCarriage) { Transformation.HitCarriage = ca; } // Hit passenger view VPassenger p = HitPassenger(e.GetPosition(this)); if (p != Transformation.HitPassenger) { Transformation.HitPassenger = p; } // View Moving if (isViewMoving) { ViewMoving(e.GetPosition(this)); } }
/// <summary> /// Generate the view dataset by the entity data /// </summary> public void GenerateViewData() { if (EntityData.StationList == null || EntityData.StationList.Count == 0) { return; } if (EntityData.SectionList == null || EntityData.SectionList.Count == 0) { return; } canvas.ClearVisual(); foreach (Station sta in EntityData.StationList.Values) { VNode n = new VNode(sta) { Location = sta.Location }; sta.View = n; nodeViewList.Add(n); } foreach (Section sec in EntityData.SectionList.Values) { VLink l = new VLink(sec) { FromNode = sec.FromStation.NodeView, ToNode = sec.ToStation.NodeView, }; sec.View = l; linkViewList.Add(l); } foreach (StopFacility sf in EntityData.StopFacilityList.Values) { VStopFacility vsf = new PassengerPlot.VStopFacility(sf); facilityViewList.Add(vsf); } foreach (Carriage ca in EntityData.CarriageList.Values) { VCarriage c = new VCarriage(ca) { Location = new Point(10, 10) }; ca.View = c; carriageViewList.Add(c); } foreach (Passenger p in EntityData.PassengerDict.Values) { VPassenger vp = new VPassenger(p) { Location = new Point(10, 10), Entity = p }; p.View = vp; passengerViewList.Add(vp); p.View.GeneratePassengerTrack(); } IsDataLoaded = true; }