示例#1
0
        public static async Task SaveRoute(IHubProxy HubProxy, Route route)
        {
            try
            {
                await HubProxy.Invoke<Route>("SaveRoute", route);
            }
            catch (Exception ex)
            {
            }

        }
示例#2
0
文件: Utilites.cs 项目: ohadmanor/TDS
        public static void UserDrawRoutesWPF(Route Route, DrawingContext dc,System.Windows.Media.Color color)
        {
            System.Windows.Point[] m_ScreenPnts = null;
            int PixelX = 0;
            int PixelY = 0;

            if (Route == null) return;
            if (Route.Points.Count() == 0) return;



            System.Windows.Media.SolidColorBrush curBrush = new System.Windows.Media.SolidColorBrush();


            curBrush.Color = color;// System.Windows.Media.Colors.Gold;


            System.Windows.Media.Pen pen = new System.Windows.Media.Pen(curBrush, 3);


            // m_ScreenPnts = new System.Windows.Point[Route.arr_legs.Length + 1];
            m_ScreenPnts = new System.Windows.Point[Route.Points.Count()];


            //VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.arr_legs[0].FromLongn, Route.arr_legs[0].FromLatn, ref PixelX, ref PixelY);
            //m_ScreenPnts[0].X = PixelX;
            //m_ScreenPnts[0].Y = PixelY;


            for (int i = 0; i < Route.Points.Count(); i++)
            {
                //VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.arr_legs[i].ToLongn, Route.arr_legs[i].ToLatn, ref PixelX, ref PixelY);
                //m_ScreenPnts[i + 1].X = PixelX;
                //m_ScreenPnts[i + 1].Y = PixelY;

                VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.Points[i].X, Route.Points[i].Y, ref PixelX, ref PixelY);
                m_ScreenPnts[i].X = PixelX;
                m_ScreenPnts[i].Y = PixelY;
            }

            System.Windows.Media.PathGeometry PathGmtr = new System.Windows.Media.PathGeometry();
            System.Windows.Media.PathFigure pathFigure = new System.Windows.Media.PathFigure();

            System.Windows.Media.PolyLineSegment myPolyLineSegment = new System.Windows.Media.PolyLineSegment();
            System.Windows.Media.PointCollection pc = new System.Windows.Media.PointCollection(m_ScreenPnts);
            myPolyLineSegment.Points = pc;
            pathFigure.StartPoint = m_ScreenPnts[0];
            pathFigure.Segments.Add(myPolyLineSegment);
            PathGmtr.Figures.Add(pathFigure);

            dc.DrawGeometry(null, pen, PathGmtr);

        }
示例#3
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;

            }
        }
示例#4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            startActivity.Value = TimeSpan.Parse("00:00:01");           
            speedUpDown.Value = 5;

           

            if (refActivityDTO != null)
            {
                speedUpDown.Value = refActivityDTO.Speed;
                txtRoute.Text = refActivityDTO.RouteActivity.RouteName;
                ActivityRoute = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text);

               

                double aXOut = 0;
                double aYOut = 0;

                aXOut = Math.Round(refActivityDTO.ReferencePoint.X, 3);
                aYOut = Math.Round(refActivityDTO.ReferencePoint.Y, 3);

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

                txtReferenceX.Tag = refActivityDTO.ReferencePoint.X;
                txtReferenceY.Tag = refActivityDTO.ReferencePoint.Y;

                startActivity.Value = refActivityDTO.StartActivityOffset;

                referencePoint = new DPoint(refActivityDTO.ReferencePoint.X, refActivityDTO.ReferencePoint.Y);




                //shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", AtomCommonProperty.X, AtomCommonProperty.Y, referencePoint.X, referencePoint.Y, false);
                //if (Path != null)
                //{

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

                VMMainViewModel.Instance.InvalidateVisual();
            }




            VMMainViewModel.Instance.dlgUserDrawWPF += UserDrawWPF;
            VMMainViewModel.Instance.dlgMouseLeftClickOnMapEvent += MapOnClick;
            VMMainViewModel.Instance.InvalidateVisual();
        }
示例#5
0
        public async void frmRouteList_EndDrawPolygonEvent(object sender, DrawPolygonEventArgs args)
        {
            if (txtRoute.Text != args.PolygonName)
            {
                txtReferenceX.Tag = null;
                txtReferenceX.Content = string.Empty;
                txtReferenceY.Content = string.Empty;
                referencePoint.X = 0;
                referencePoint.Y = 0;

            }


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

            VMMainViewModel.Instance.InvalidateVisual();

        }
        private async void cmdExit_Click(object sender, RoutedEventArgs e)
        {

            bool isCheckOk = await CheckOk();

            if (isCheckOk == false) return;

            DrawPolygonEventArgs arg = new DrawPolygonEventArgs();
            arg.isCancel = false;
            arg.isNew = true;

            arg.PolygonName = txtRouteName.Text.Trim();

            arg.PolygonPnts = m_PolygonPnts.ToArray<DPoint>();
            //  isOK = true;
            if (EndDrawPolygonEvent != null)
            {
                EndDrawPolygonEvent(this, arg);
            }


            GeneralActivityDTO ActivityDTO = new GeneralActivityDTO();
            ActivityDTO.ActivityType = enumActivity.MovementActivity;

            AtomData atomdata = new AtomData();
            atomdata.UnitName = txPlatformName.Text;
            atomdata.Location = m_PolygonPnts[0];

            ActivityDTO.StartActivityOffset = (TimeSpan)startActivity.Value;
            ActivityDTO.DurationActivity = (TimeSpan)durationActivity.Value;
            ActivityDTO.Speed = (int)speedUpDown.Value;

            Route route = new Route();
            route.RouteName = txtRouteName.Text;
            route.Points = m_PolygonPnts;
            ActivityDTO.RouteActivity = route;

            if (refActivityDTO!=null)
            {
                atomdata.UnitGuid = refActivityDTO.Atom.UnitGuid;
                ActivityDTO.ActivityId = refActivityDTO.ActivityId;
                if (ActivityDTO.RouteActivity!=null)
                {
                    ActivityDTO.RouteActivity.RouteGuid = refActivityDTO.RouteActivity.RouteGuid;
                }
             

                

            }



            ActivityDTO.Atom = atomdata;

           


            
           


            await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, ActivityDTO);


            this.Close();
        }
示例#7
0
        public async void RouteEdit_EndDrawPolygonEvent(object sender, DrawPolygonEventArgs args)
        {
            dtGridRoute.Focus();


            if (args.isCancel)
            {
                int i = dtGridRoute.SelectedIndex;
                if (i > 0)
                {

                    RouteData currRouteData = (RouteData)dtGridRoute.Items[i];
                    if (!RouteShowList.ContainsKey(currRouteData.RouteName))
                    {
                        RouteShowList.Add(currRouteData.RouteName, currRouteData.route);
                    }
                }
            }
            else
            {
                Route route = null;// 
                if (!args.isNew)
                {
                      

                    if (dtGridRoute.ItemsSource == null) return;

                    List<RouteData> listData = (List<RouteData>)(dtGridRoute.ItemsSource);

                    RouteData currRouteData = null;
                    for (int j = 0; j < listData.Count; j++)
                    {
                        if (listData[j].RouteName == args.PolygonName)
                        {
                            currRouteData = listData[j];
                            break;
                        }
                    }

                    if (currRouteData == null) return;

                 //Victor   currRouteData.route.arr_legs = LegSector;
                    route = currRouteData.route;
                    if (!RouteShowList.ContainsKey(currRouteData.RouteName))
                    {
                        RouteShowList.Add(currRouteData.RouteName, currRouteData.route);
                    }


                }
                else
                {
                    route = new Route();                   

                   // LegSector = CreateLegSector(args.PolygonPnts);
                    route.Points =new List<DPoint>(args.PolygonPnts);
                    route.RouteName = args.PolygonName;

                    RouteData Rdata = new RouteData();
                    Rdata.route = route;




                    ((List<RouteData>)(dtGridRoute.ItemsSource)).Add(Rdata);
                    dtGridRoute.Items.Refresh();
                    dtGridRoute.SelectedItem = Rdata;
                    dtGridRoute.CurrentItem = Rdata;
                    DataGridWPFUtility.DataGridGotoLast(dtGridRoute);
                }

                await SAGSignalR.SaveRoute(VMMainViewModel.Instance.SimulationHubProxy, route);
            }
        }