リビジョン | 56 (tree) |
---|---|
日時 | 2020-07-16 11:57:57 |
作者 | dangerouswoo |
(メッセージはありません)
@@ -909,6 +909,69 @@ | ||
909 | 909 | }; |
910 | 910 | popupmenu.Items.Add(delpathitem); |
911 | 911 | |
912 | + ToolStripMenuItem delmultipathitem = new ToolStripMenuItem("駅一括削除"); | |
913 | + delmultipathitem.Click += (sender, args) => | |
914 | + { | |
915 | + double HitDistance = 5.0; | |
916 | + | |
917 | + StationInfoData endstation = null; | |
918 | + SetSelectPoint((viewrequestinfo, viewpoint, dLat, dLng) => | |
919 | + { | |
920 | + //対象駅探索 | |
921 | + var result = new Dictionary<TrainPath.Position, double>(); | |
922 | + | |
923 | + foreach (var ostation in Factory.GetStationManager().StationList()) | |
924 | + { | |
925 | + if (station == ostation) | |
926 | + continue; | |
927 | + | |
928 | + //画面座標変換 | |
929 | + var mypoint = viewrequestinfo.LatLongToViewPoint(ostation.Latitude, ostation.Longitude); | |
930 | + | |
931 | + //距離算出 | |
932 | + double dDistance = Math.Sqrt((mypoint.X - viewpoint.X) * (mypoint.X - viewpoint.X) + (mypoint.Y - viewpoint.Y) * (mypoint.Y - viewpoint.Y)); | |
933 | + if (HitDistance >= dDistance) | |
934 | + { | |
935 | + endstation = ostation; | |
936 | + break; | |
937 | + } | |
938 | + } | |
939 | + if(endstation != null ) | |
940 | + { | |
941 | + var listtable = Factory.GetNetwork().BuildLine(station, endstation); | |
942 | + if (listtable.Count == 0) | |
943 | + return; | |
944 | + | |
945 | + if (listtable.Count >= 2) | |
946 | + { | |
947 | + MessageBox.Show("複数経路があるので削除出来ません。"); | |
948 | + return; | |
949 | + } | |
950 | + | |
951 | + var deletetable = new Dictionary<int, StationInfoData>(); | |
952 | + var deletelist = listtable[0]; | |
953 | + foreach( var tpath in deletelist ) | |
954 | + { | |
955 | + if( tpath.StationA != null ) | |
956 | + { | |
957 | + if(deletetable.ContainsKey(tpath.StationA.UniqID) == false ) | |
958 | + deletetable[tpath.StationA.UniqID] = tpath.StationA; | |
959 | + } | |
960 | + if (tpath.StationB != null) | |
961 | + { | |
962 | + if (deletetable.ContainsKey(tpath.StationB.UniqID) == false) | |
963 | + deletetable[tpath.StationB.UniqID] = tpath.StationB; | |
964 | + } | |
965 | + } | |
966 | + deletetable.Values.ToList().ForEach(pstation => DeleteStation(pstation)); | |
967 | + } | |
968 | + }); | |
969 | + | |
970 | + MapViewCnt.RefreshImage(); | |
971 | + }; | |
972 | + popupmenu.Items.Add(delmultipathitem); | |
973 | + | |
974 | + | |
912 | 975 | popupmenu.Show(Cursor.Position); |
913 | 976 | } |
914 | 977 |