Ejemplo n.º 1
0
        protected async override void OnDrop(System.Windows.DragEventArgs e)
        {
            double currMapX = 0;
            double currMapY = 0;

            System.Windows.DataObject d = (System.Windows.DataObject)e.Data;

            string[] dataFormats = d.GetFormats();
            string   dataText    = d.GetText();

            Point position = e.GetPosition(this);

            GMap.NET.PointLatLng curPosition = FromLocalToLatLng((int)position.X, (int)position.Y);
            currMapX = curPosition.Lng;
            currMapY = curPosition.Lat;

            for (int i = 0; i < dataFormats.Length; i++)
            {
                string dragFormat = dataFormats[i];

                if (dragFormat.Contains("FormationTree") && dataText == "Actor")
                {
                    object dragObject = d.GetData(dragFormat);

                    FormationTree formation = dragObject as FormationTree;
                    if (formation == null)
                    {
                        continue;
                    }

                    enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined;
                    SetHighwayFilter(highwayFilter);
                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY);

                    if (PointId != null)
                    {
                        shPoint           pnt             = PointId.point;
                        DeployedFormation deployFormation = new DeployedFormation();
                        deployFormation.x         = pnt.x;
                        deployFormation.y         = pnt.y;
                        deployFormation.formation = formation;

                        AtomData atom = await TDSClient.SAGInterface.SAGSignalR.DeployFormationFromTree(VMMainViewModel.Instance.SimulationHubProxy, deployFormation);

                        if (atom != null)
                        {
                            AtomDeployedEventArgs args = new AtomDeployedEventArgs();
                            args.atom = atom;
                            if (AtomDeployedEvent != null)
                            {
                                AtomDeployedEvent(this, args);
                            }
                        }
                    }

                    return;
                }
            }
        }
Ejemplo n.º 2
0
        // Yinon Douchan: Only find the shortest path between two points.
        public async Task <typRoute> createRouteByShortestPathOnly(double StartX, double StartY, double ReferencePointX, double ReferencePointY)
        {
            List <DPoint> Result = new List <DPoint>();

            DPoint ReferPoint = new DPoint(ReferencePointX, ReferencePointY);
            shPath Path       = await clsRoadRoutingWebApi.FindShortPath("0", StartX, StartY, ReferencePointX, ReferencePointY, false);

            if (Path != null && Path.Points.Count > 0)
            {
                shPoint refPoint = Path.Points[Path.Points.Count - 1];
                ReferPoint = new DPoint(refPoint.x, refPoint.y);

                foreach (shPoint p in Path.Points)
                {
                    Result.Add(new DPoint(p.x, p.y));
                }
            }

            if (Result.Count == 0)
            {
                Result.Add(new DPoint(StartX, StartY));
            }
            else
            {
                if (Result[0].x != StartX || Result[0].y != StartY)
                {
                    Result.Insert(0, new DPoint(StartX, StartY));
                }
            }

            Route routeResult = new Route();

            routeResult.Points = Result;


            typRoute tRoute = new typRoute(routeResult);

            return(tRoute);
        }
Ejemplo n.º 3
0
        public async Task <typRoute> CreateRoute(double StartX, double StartY, double ReferencePointX, double ReferencePointY, string RouteGuid)
        {
            try
            {
                List <DPoint> Result = new List <DPoint>();

                Route  route      = TDS.DAL.RoutesDB.GetRouteByGuid(RouteGuid);
                DPoint ReferPoint = new DPoint(ReferencePointX, ReferencePointY);

                shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", StartX, StartY, ReferencePointX, ReferencePointY, false);

                if (Path != null && Path.Points.Count > 0)
                {
                    shPoint refPoint = Path.Points[Path.Points.Count - 1];
                    ReferPoint = new DPoint(refPoint.x, refPoint.y);

                    foreach (shPoint p in Path.Points)
                    {
                        Result.Add(new DPoint(p.x, p.y));
                    }
                }

                if (Result.Count == 0)
                {
                    Result.Add(new DPoint(StartX, StartY));
                }
                else
                {
                    if (Result[0].x != StartX || Result[0].y != StartY)
                    {
                        Result.Insert(0, new DPoint(StartX, StartY));
                    }
                }

                int    leg      = 0;
                DPoint minP     = null;
                double mainDist = double.MaxValue;
                int    i        = -1;
                foreach (DPoint p in route.Points)
                {
                    i++;
                    // double dist = MathEngine.CalcDistanceForCompare(ReferPoint.x, ReferPoint.y, p.x, p.y);
                    double dist = MathEngine.GreatCircleDistance(ReferPoint.x, ReferPoint.y, p.x, p.y);
                    if (dist < mainDist)
                    {
                        mainDist = dist;
                        minP     = p;
                        leg      = i;
                    }
                }
                if (mainDist != 0.0)
                {
                    List <DPoint> R = route.Points.ToList <DPoint>().GetRange(leg, route.Points.Count() - leg);
                    Result.AddRange(R);
                }
                else
                {
                    if (leg < route.Points.Count() - 1) // Not Last element
                    {
                        List <DPoint> R = route.Points.ToList <DPoint>().GetRange(leg + 1, route.Points.Count() - (leg + 1));
                        Result.AddRange(R);
                    }
                }

                Route routeResult = new Route();
                routeResult.Points = Result;


                typRoute tRoute = new typRoute(routeResult);
                return(tRoute);
            }
            catch (Exception ex)
            {
            }



            return(null);
        }
Ejemplo n.º 4
0
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
          
            if (checkBoxMapReferencePoint.IsChecked == true && string.IsNullOrEmpty(txtRoute.Text)==false)
            {
                txtReferenceX.Tag = null;
                referencePoint = new DPoint();


                DPoint Dpnt = new DPoint();
                Dpnt.X = e.MapXLongLatWGS84;
                Dpnt.Y = e.MapYLongLatWGS84;

                Route route = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text);
                ActivityRoute = route;
                if(route!=null)
                {
                 

                    double minDist = double.MaxValue;
                    DPoint minDpoint = new DPoint();
                    int leg = 0;
                    int i = -1;
                    foreach(DPoint dpoint in route.Points)
                    {
                        i++;
                        double dist = Utilites.GreatCircleDistance(Dpnt.X, Dpnt.Y, dpoint.X, dpoint.Y);
                        if(dist<minDist)
                        {
                            minDist = dist;
                            minDpoint = dpoint;
                            leg = i;
                        }
                    }



                    float NearestIndex=0;
                   // shPoint[] shPoints = Utilites.Convert2shPoint(route.Points);

                    shPoint pnt = new shPoint(minDpoint.X, minDpoint.Y);


                    //shPoint pnt = TerrainService.MathEngine.ReturnNearestPointOnPolygonBorder(Dpnt.X, Dpnt.Y, shPoints, out  NearestIndex);
                    if (pnt.x != 0.0 && pnt.y != 0.0)
                    {

                        referencePoint = new DPoint(pnt.x, pnt.y);


                    }


                    double aXOut = 0;
                    double aYOut = 0;

                    aXOut = Math.Round(pnt.x, 3);
                    aYOut = Math.Round(pnt.y, 3);

                    txtReferenceX.Content = aXOut.ToString();
                    txtReferenceY.Content = aYOut.ToString();

                    txtReferenceX.Tag = pnt.x;
                    txtReferenceY.Tag = pnt.y;


                    shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", AtomCommonProperty.X, AtomCommonProperty.Y, pnt.x, pnt.y, false);

                   
                    {
                        ReferenceRoute = new Route();
                        ReferenceRoute.Points=Utilites.Convert2DPoint(Path.Points);

                        VMMainViewModel.Instance.InvalidateVisual();

                    }
                }



               
                checkBoxMapReferencePoint.IsChecked = false;

            }
        }
Ejemplo n.º 5
0
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
            try
            {
                SetHighwayFilter();

                DPoint Dpnt = new DPoint();
                Dpnt.X = e.MapXLongLatWGS84;
                Dpnt.Y = e.MapYLongLatWGS84;

                if (checkBoxMapSource.IsChecked == true)
                {
                    checkBoxMapSource.IsChecked = false;

                    shPoint pnt    = new shPoint();
                    int     nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, Dpnt.X, Dpnt.Y);

                    pnt    = PointId.point;
                    nodeid = PointId.nodeId;

                    if (pnt.x != 0 || pnt.y != 0)
                    {
                        pntSource.X     = pnt.x;
                        pntSource.Y     = pnt.y;
                        nodeSourceId    = nodeid;
                        txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                        txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();
                    }

                    VMMainViewModel.Instance.InvalidateVisual();
                }
                else if (checkBoxMapTarget.IsChecked == true)
                {
                    checkBoxMapTarget.IsChecked = false;

                    shPoint pnt    = new shPoint();
                    int     nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);

                    pnt    = PointId.point;
                    nodeid = PointId.nodeId;


                    //UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid,highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);


                    if (pnt.x != 0 || pnt.y != 0)
                    {
                        pntTarget.X = pnt.x;
                        pntTarget.Y = pnt.y;

                        txtTargetX.Text = Math.Round(pntTarget.X, 4).ToString();
                        txtTargetY.Text = Math.Round(pntTarget.Y, 4).ToString();
                        nodeTargetId    = nodeid;
                    }
                    else
                    {
                    }


                    VMMainViewModel.Instance.InvalidateVisual();
                }
                else
                {
                    for (int i = 0; i < dtGridRoute.Items.Count; i++)
                    {
                        OsmRouteData DetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i];
                        if (DetailData.IsMapClick)
                        {
                            DetailData.IsMapClick = false;

                            shPoint pnt = new shPoint();
                            //  string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoad(out pnt, Dpnt.X, Dpnt.Y);
                            int nSourceId = 0;
                            if (i == 0)
                            {
                                nSourceId = nodeSourceId;
                            }
                            else
                            {
                                OsmRouteData prevDetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i - 1];
                                nSourceId = prevDetailData.NodeId;
                            }

                            int nodeid = 0;


                            shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);

                            pnt    = PointId.point;
                            nodeid = PointId.nodeId;


                            //  UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid, highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);


                            if (pnt.x != 0 || pnt.y != 0)
                            {
                                DetailData.X      = pnt.x;
                                DetailData.Y      = pnt.y;
                                DetailData.NodeId = nodeid;
                            }
                            else
                            {
                            }


                            VMMainViewModel.Instance.InvalidateVisual();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 6
0
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
            try
            {
                SetHighwayFilter();

                DPoint Dpnt = new DPoint();
                Dpnt.X = e.MapXLongLatWGS84;
                Dpnt.Y = e.MapYLongLatWGS84;

                if (checkBoxMapSource.IsChecked == true)
                {

                    checkBoxMapSource.IsChecked = false;

                    shPoint pnt = new shPoint();
                    int nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, Dpnt.X, Dpnt.Y);
                    pnt = PointId.point;
                    nodeid = PointId.nodeId;

                    if (pnt.x != 0 || pnt.y != 0)
                    {
                        pntSource.X = pnt.x;
                        pntSource.Y = pnt.y;
                        nodeSourceId = nodeid;
                        txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                        txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();

                    }

                    VMMainViewModel.Instance.InvalidateVisual();

                   
                }
                else if (checkBoxMapTarget.IsChecked == true)
                {

                    checkBoxMapTarget.IsChecked = false;

                    shPoint pnt = new shPoint();
                    int nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);
                    pnt = PointId.point;
                    nodeid = PointId.nodeId;


                    //UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid,highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);


                    if (pnt.x != 0 || pnt.y != 0)
                    {
                        pntTarget.X = pnt.x;
                        pntTarget.Y = pnt.y;

                        txtTargetX.Text = Math.Round(pntTarget.X, 4).ToString();
                        txtTargetY.Text = Math.Round(pntTarget.Y, 4).ToString();
                        nodeTargetId = nodeid;
                    }
                    else
                    {

                    }


                    VMMainViewModel.Instance.InvalidateVisual();
                }
                else
                {
                    for (int i = 0; i < dtGridRoute.Items.Count; i++)
                    {
                        OsmRouteData DetailData = ((List<OsmRouteData>)dtGridRoute.ItemsSource)[i];
                        if (DetailData.IsMapClick)
                        {
                            DetailData.IsMapClick = false;

                            shPoint pnt = new shPoint();
                            //  string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoad(out pnt, Dpnt.X, Dpnt.Y);
                            int nSourceId = 0;
                            if (i == 0)
                            {
                                nSourceId = nodeSourceId;
                            }
                            else
                            {
                                OsmRouteData prevDetailData = ((List<OsmRouteData>)dtGridRoute.ItemsSource)[i - 1];
                                nSourceId = prevDetailData.NodeId;
                            }

                            int nodeid = 0;


                            shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);
                            pnt = PointId.point;
                            nodeid = PointId.nodeId;


                            //  UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid, highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);


                            if (pnt.x != 0 || pnt.y != 0)
                            {
                                DetailData.X = pnt.x;
                                DetailData.Y = pnt.y;
                                DetailData.NodeId = nodeid;

                            }
                            else
                            {

                            }


                            VMMainViewModel.Instance.InvalidateVisual();
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
            try
            {
                SetHighwayFilter();

                DPoint Dpnt = new DPoint();
                Dpnt.X = e.MapXLongLatWGS84;
                Dpnt.Y = e.MapYLongLatWGS84;

                if (checkBoxMapSource.IsChecked == true)
                {
                    checkBoxMapSource.IsChecked = false;

                    shPoint pnt    = new shPoint();
                    int     nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, Dpnt.X, Dpnt.Y);

                    if (PointId != null)
                    {
                        pnt    = PointId.point;
                        nodeid = PointId.nodeId;

                        if (pnt.x != 0 || pnt.y != 0)
                        {
                            pntSource.X     = pnt.x;
                            pntSource.Y     = pnt.y;
                            nodeSourceId    = nodeid;
                            txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                            txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();
                        }
                    }



                    //////string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointIdOnRoad(out pnt,out nodeid,highwayFilter, Dpnt.X, Dpnt.Y);
                    //////if (string.IsNullOrEmpty(err) == false)
                    //////{
                    //////    err = KingsGameClientModel.Properties.Resources.strSpatialServicenotActive;
                    //////    ComponentsUtility.KGMsgBox.ShowCustomMsgOk(UserSession.GetParentWindow(this), err);
                    //////    return;
                    //////}
                    //////else
                    //////{
                    //////    if (pnt.x != 0 || pnt.y != 0)
                    //////    {
                    //////        pntSource.X = pnt.x;
                    //////        pntSource.Y = pnt.y;
                    //////        nodeSourceId = nodeid;
                    //////        txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                    //////        txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();

                    //////    }
                    //////    else
                    //////    {

                    //////    }
                    //////}
                    VMMainViewModel.Instance.InvalidateVisual();
                }
                else if (checkBoxMapTarget.IsChecked == true)
                {
                    checkBoxMapTarget.IsChecked = false;

                    shPoint pnt    = new shPoint();
                    int     nodeid = 0;

                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);

                    if (PointId != null)
                    {
                        pnt    = PointId.point;
                        nodeid = PointId.nodeId;


                        //UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid,highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);


                        if (pnt.x != 0 || pnt.y != 0)
                        {
                            pntTarget.X = pnt.x;
                            pntTarget.Y = pnt.y;

                            txtTargetX.Text = Math.Round(pntTarget.X, 4).ToString();
                            txtTargetY.Text = Math.Round(pntTarget.Y, 4).ToString();
                            nodeTargetId    = nodeid;
                        }
                        else
                        {
                        }
                    }


                    VMMainViewModel.Instance.InvalidateVisual();
                }
                else
                {
                    for (int i = 0; i < dtGridRoute.Items.Count; i++)
                    {
                        OsmRouteData DetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i];
                        if (DetailData.IsMapClick)
                        {
                            DetailData.IsMapClick = false;

                            shPoint pnt = new shPoint();
                            //  string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoad(out pnt, Dpnt.X, Dpnt.Y);
                            int nSourceId = 0;
                            if (i == 0)
                            {
                                nSourceId = nodeSourceId;
                            }
                            else
                            {
                                OsmRouteData prevDetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i - 1];
                                nSourceId = prevDetailData.NodeId;
                            }

                            int nodeid = 0;


                            shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);

                            if (PointId != null)
                            {
                                pnt    = PointId.point;
                                nodeid = PointId.nodeId;


                                //  UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid, highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);


                                if (pnt.x != 0 || pnt.y != 0)
                                {
                                    DetailData.X      = pnt.x;
                                    DetailData.Y      = pnt.y;
                                    DetailData.NodeId = nodeid;
                                }
                                else
                                {
                                }
                            }



                            VMMainViewModel.Instance.InvalidateVisual();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 8
0
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
            if (checkBoxMapReferencePoint.IsChecked == true && string.IsNullOrEmpty(txtRoute.Text) == false)
            {
                txtReferenceX.Tag = null;
                referencePoint    = new DPoint();


                DPoint Dpnt = new DPoint();
                Dpnt.X = e.MapXLongLatWGS84;
                Dpnt.Y = e.MapYLongLatWGS84;

                Route route = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text);

                ActivityRoute = route;
                if (route != null)
                {
                    double minDist   = double.MaxValue;
                    DPoint minDpoint = new DPoint();
                    int    leg       = 0;
                    int    i         = -1;
                    foreach (DPoint dpoint in route.Points)
                    {
                        i++;
                        double dist = Utilites.GreatCircleDistance(Dpnt.X, Dpnt.Y, dpoint.X, dpoint.Y);
                        if (dist < minDist)
                        {
                            minDist   = dist;
                            minDpoint = dpoint;
                            leg       = i;
                        }
                    }



                    float NearestIndex = 0;
                    // shPoint[] shPoints = Utilites.Convert2shPoint(route.Points);

                    shPoint pnt = new shPoint(minDpoint.X, minDpoint.Y);


                    //shPoint pnt = TerrainService.MathEngine.ReturnNearestPointOnPolygonBorder(Dpnt.X, Dpnt.Y, shPoints, out  NearestIndex);
                    if (pnt.x != 0.0 && pnt.y != 0.0)
                    {
                        referencePoint = new DPoint(pnt.x, pnt.y);
                    }


                    double aXOut = 0;
                    double aYOut = 0;

                    aXOut = Math.Round(pnt.x, 3);
                    aYOut = Math.Round(pnt.y, 3);

                    txtReferenceX.Content = aXOut.ToString();
                    txtReferenceY.Content = aYOut.ToString();

                    txtReferenceX.Tag = pnt.x;
                    txtReferenceY.Tag = pnt.y;


                    shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", AtomCommonProperty.X, AtomCommonProperty.Y, pnt.x, pnt.y, false);


                    {
                        ReferenceRoute        = new Route();
                        ReferenceRoute.Points = Utilites.Convert2DPoint(Path.Points);

                        VMMainViewModel.Instance.InvalidateVisual();
                    }
                }



                checkBoxMapReferencePoint.IsChecked = false;
            }
        }
Ejemplo n.º 9
0
        public async void MapOnClick(object sender, MapMouseEventArgsWPF e)
        {
             try
             {
                 SetHighwayFilter();

                 DPoint Dpnt = new DPoint();  
                 Dpnt.X = e.MapXLongLatWGS84;
                 Dpnt.Y = e.MapYLongLatWGS84;

                 if (checkBoxMapSource.IsChecked == true)
                 {

                     checkBoxMapSource.IsChecked = false;

                     shPoint pnt = new shPoint();
                     int nodeid = 0;

                     shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, Dpnt.X, Dpnt.Y);

                     if (PointId!=null)
                     {
                         pnt = PointId.point;
                         nodeid = PointId.nodeId;

                         if (pnt.x != 0 || pnt.y != 0)
                         {
                             pntSource.X = pnt.x;
                             pntSource.Y = pnt.y;
                             nodeSourceId = nodeid;
                             txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                             txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();

                         }
                     }


                   

                     
                     //////string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointIdOnRoad(out pnt,out nodeid,highwayFilter, Dpnt.X, Dpnt.Y);
                     //////if (string.IsNullOrEmpty(err) == false)
                     //////{
                     //////    err = KingsGameClientModel.Properties.Resources.strSpatialServicenotActive;
                     //////    ComponentsUtility.KGMsgBox.ShowCustomMsgOk(UserSession.GetParentWindow(this), err);
                     //////    return;
                     //////}
                     //////else
                     //////{                         
                     //////    if (pnt.x != 0 || pnt.y != 0)
                     //////    {
                     //////        pntSource.X = pnt.x;
                     //////        pntSource.Y = pnt.y;
                     //////        nodeSourceId = nodeid;
                     //////        txtSourceX.Text = Math.Round(pntSource.X, 4).ToString();
                     //////        txtSourceY.Text = Math.Round(pntSource.Y, 4).ToString();
                           
                     //////    }
                     //////    else
                     //////    {

                     //////    }
                     //////}
                    VMMainViewModel.Instance.InvalidateVisual();


                    
                 }
                 else if (checkBoxMapTarget.IsChecked == true)
                 {

                     checkBoxMapTarget.IsChecked = false;

                     shPoint pnt = new shPoint();                   
                     int nodeid = 0;

                     shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);
                     if (PointId!=null)
                     {
                         pnt = PointId.point;
                         nodeid = PointId.nodeId;


                         //UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid,highwayFilter, Dpnt.X, Dpnt.Y, nodeSourceId, true);


                         if (pnt.x != 0 || pnt.y != 0)
                         {
                             pntTarget.X = pnt.x;
                             pntTarget.Y = pnt.y;

                             txtTargetX.Text = Math.Round(pntTarget.X, 4).ToString();
                             txtTargetY.Text = Math.Round(pntTarget.Y, 4).ToString();
                             nodeTargetId = nodeid;
                         }
                         else
                         {

                         }

                     }


                         VMMainViewModel.Instance.InvalidateVisual();
                 }
                 else
                 {
                     for (int i = 0; i < dtGridRoute.Items.Count; i++)
                     {
                         OsmRouteData DetailData = ((List<OsmRouteData>)dtGridRoute.ItemsSource)[i];
                         if(DetailData.IsMapClick)
                         {
                             DetailData.IsMapClick = false;

                             shPoint pnt = new shPoint();
                           //  string err = UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoad(out pnt, Dpnt.X, Dpnt.Y);
                             int nSourceId = 0;
                             if(i==0)
                             {
                                 nSourceId = nodeSourceId;
                             }
                             else
                             {
                                 OsmRouteData prevDetailData = ((List<OsmRouteData>)dtGridRoute.ItemsSource)[i-1];
                                 nSourceId = prevDetailData.NodeId;
                             }

                             int nodeid = 0;


                             shPointId PointId = await clsRoadRoutingWebApi.GetNearestRoadNodeWithCondition("0", highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);
                             if (PointId!=null)
                             {
                                 pnt = PointId.point;
                                 nodeid = PointId.nodeId;


                                 //  UserSession.ClientSideObject.m_GameManagerProxy.GetNearestPointOnRoadWithCondition(out pnt, out nodeid, highwayFilter, Dpnt.X, Dpnt.Y, nSourceId, true);


                                 if (pnt.x != 0 || pnt.y != 0)
                                 {
                                     DetailData.X = pnt.x;
                                     DetailData.Y = pnt.y;
                                     DetailData.NodeId = nodeid;

                                 }
                                 else
                                 {

                                 }
                             }

                            


                            VMMainViewModel.Instance.InvalidateVisual();
                         }
                     }
                 }
             }
            catch(Exception ex)
             {

             }
        }
Ejemplo n.º 10
0
        internal async void NotifyMouseLeftClickOnMapEvent(MapMouseEventArgsWPF args)
        {
            double currMapX = args.MapXLongLatWGS84;
            double currMapY = args.MapYLongLatWGS84;


            switch (CurrMapTool)
            {
            case enMapTool.MoveObjectTool:
                CurrMapTool = enMapTool.DefautMapTool;

                enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined;
                highwayFilter = highwayFilter | enOSMhighwayFilter.CarMostImportant;
                highwayFilter = highwayFilter | enOSMhighwayFilter.CarMediumImportant;
                highwayFilter = highwayFilter | enOSMhighwayFilter.CarLowImportant;
                highwayFilter = highwayFilter | enOSMhighwayFilter.Construction;

                shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY);

                if (PointId != null)
                {
                    shPoint           pnt             = PointId.point;
                    DeployedFormation deployFormation = new DeployedFormation();
                    deployFormation.x = pnt.x;
                    deployFormation.y = pnt.y;

                    deployFormation.formation = new FormationTree();
                    deployFormation.formation.Identification = MoveObjectCommonProperty.AtomName;
                    deployFormation.formation.GUID           = MoveObjectCommonProperty.GUID;


                    // deployFormation.formation = formation;

                    await TDSClient.SAGInterface.SAGSignalR.MoveGroundObject(VMMainViewModel.Instance.SimulationHubProxy, deployFormation);
                }


                break;
            }



            if (dlgMouseLeftClickOnMapEvent == null)
            {
                return;
            }

            System.Delegate[] invklist = dlgMouseLeftClickOnMapEvent.GetInvocationList();
            IEnumerator       ie       = invklist.GetEnumerator();

            while (ie.MoveNext())
            {
                MouseLeftClickOnMapEventWPF handler = (MouseLeftClickOnMapEventWPF)ie.Current;
                try
                {
                    {
                        // IAsyncResult ar = handler.BeginInvoke(this,args, null, null);
                        // handler.EndInvoke(ar);

                        handler.Invoke(this, args);
                    }
                }
                catch (System.Exception e)
                //catch
                {
                    dlgMouseLeftClickOnMapEvent -= handler;
                }
            }
        }