Esempio n. 1
0
        private void cmdNew_Click(object sender, RoutedEventArgs e)
        {
            OsmRouteData Rdata = new OsmRouteData();

            ((List <OsmRouteData>)(dtGridRoute.ItemsSource)).Add(Rdata);
            dtGridRoute.Items.Refresh();
            dtGridRoute.SelectedItem = Rdata;
            //    dtGridRoute.SelectedIndex = dtGridRoute.Items.Count;
            dtGridRoute.CurrentItem = Rdata;

            DataGridWPFUtility.DataGridGotoLast(dtGridRoute);
        }
Esempio n. 2
0
        private async void cmdRoute_Click(object sender, RoutedEventArgs e)
        {
            checkBoxMapSource.IsChecked = false;
            checkBoxMapTarget.IsChecked = false;

            SetHighwayFilter();

            List <int> nodeList = new List <int>();

            if (nodeSourceId != 0)
            {
                nodeList.Add(nodeSourceId);
            }
            for (int i = 0; i < dtGridRoute.Items.Count; i++)
            {
                OsmRouteData DetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i];
                if (DetailData.NodeId != 0)
                {
                    nodeList.Add(DetailData.NodeId);
                }
            }
            if (nodeTargetId != 0)
            {
                nodeList.Add(nodeTargetId);
            }



            //            typRoute RoadRoute = UserSession.ClientSideObject.m_GameManagerProxy.GetRoadsRoute(pntSource.X, pntSource.Y, pntTarget.X, pntTarget.Y);
            enOSMhighwayFilter[] arrHighwayFilter = new enOSMhighwayFilter[1];
            arrHighwayFilter[0] = highwayFilter;


            shPath Path = await clsRoadRoutingWebApi.FindShortPathWithArrayNodes("0", nodeList.ToArray(), arrHighwayFilter);

            m_PolygonPnts.Clear();
            if (Path != null && Path.Points != null)
            {
                for (int i = 0; i < Path.Points.Count; i++)
                {
                    DPoint Dpnt = new DPoint();
                    Dpnt.X = Path.Points[i].x;
                    Dpnt.Y = Path.Points[i].y;
                    m_PolygonPnts.Add(Dpnt);
                }
            }



            VMMainViewModel.Instance.InvalidateVisual();
        }
Esempio n. 3
0
        private void cmdDelete_Click(object sender, RoutedEventArgs e)
        {
            int i = dtGridRoute.SelectedIndex;

            if (i < 0)
            {
                return;
            }
            OsmRouteData currRouteData = (OsmRouteData)dtGridRoute.Items[i];

            ((List <OsmRouteData>)(dtGridRoute.ItemsSource)).Remove(currRouteData);
            dtGridRoute.Items.Refresh();
            dtGridRoute.Items.MoveCurrentToNext();

            VMMainViewModel.Instance.InvalidateVisual();
        }
Esempio n. 4
0
        private void cmdInsert_Click(object sender, RoutedEventArgs e)
        {
            int j = dtGridRoute.SelectedIndex;

            if (j < 0)
            {
                return;
            }

            OsmRouteData Rdata = new OsmRouteData();

            ((List <OsmRouteData>)(dtGridRoute.ItemsSource)).Insert(j, Rdata);

            dtGridRoute.Items.Refresh();
            dtGridRoute.SelectedItem = Rdata;
            dtGridRoute.CurrentItem  = Rdata;

            DataGridWPFUtility.DataGridGotoByIndex(dtGridRoute, j);
        }
Esempio n. 5
0
        private void dtGridRoute_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
        {
            if (e.Column.DisplayIndex == 0)
            {
                CheckBox chBox = e.EditingElement as CheckBox;
                if ((bool)chBox.IsChecked)
                {
                    checkBoxMapSource.IsChecked = false;
                    checkBoxMapTarget.IsChecked = false;
                    //   buttonClear.Visibility = System.Windows.Visibility.Visible;
                    int selind = dtGridRoute.SelectedIndex;

                    for (int i = 0; i < dtGridRoute.Items.Count; i++)
                    {
                        OsmRouteData DetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i];
                        if (i != selind)
                        {
                            DetailData.IsMapClick = false;
                        }
                    }
                }
                dtGridRoute.CommitEdit(DataGridEditingUnit.Cell, true);
            }
        }
Esempio n. 6
0
        private void UserDrawWPF(DrawingContext dc)
        {
            System.Windows.Media.Color           m_LineColor      = System.Windows.Media.Colors.Gold;
            System.Windows.Media.SolidColorBrush m_LineColorBrush = System.Windows.Media.Brushes.Gold;
            int m_LineWidth = 4;

            try
            {
                int PixelX = 0;
                int PixelY = 0;
                if (pntSource.X != 0.0 && pntSource.Y != 0.0)
                {
                    VMMainViewModel.Instance.ConvertCoordGroundToPixel(pntSource.X, pntSource.Y, ref PixelX, ref PixelY);
                    ImageSource ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Images/" + "flag_blue.png"));
                    Utilites.UserDrawRasterWPFScreenCoordinate(dc, ImageSource, PixelX, PixelY, 22, 22);
                }
                if (pntTarget.X != 0.0 && pntTarget.Y != 0.0)
                {
                    VMMainViewModel.Instance.ConvertCoordGroundToPixel(pntTarget.X, pntTarget.Y, ref PixelX, ref PixelY);
                    ImageSource ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Images/" + "flag_red.png"));
                    Utilites.UserDrawRasterWPFScreenCoordinate(dc, ImageSource, PixelX, PixelY, 22, 22);
                }



                if (m_PolygonPnts == null)
                {
                    return;
                }
                //  if (m_PolygonPnts.Count == 0) return;

                //  m_LineColor = System.Windows.Media.Colors.Gold;

                //   m_LineColorBrush.Color = System.Windows.Media.Colors.Gold;



                System.Windows.Media.Pen pen = new System.Windows.Media.Pen(m_LineColorBrush, m_LineWidth);
                pen.Thickness = m_LineWidth;
                pen.LineJoin  = PenLineJoin.Round;



                System.Windows.Point[] m_ScreenPnts = new System.Windows.Point[m_PolygonPnts.Count];
                for (int i = 0; i < m_PolygonPnts.Count; i++)
                {
                    //   int PixelX = 0;
                    //   int PixelY = 0;
                    VMMainViewModel.Instance.ConvertCoordGroundToPixel(m_PolygonPnts[i].X, m_PolygonPnts[i].Y, ref PixelX, ref PixelY);
                    m_ScreenPnts[i].X = PixelX;
                    m_ScreenPnts[i].Y = PixelY;
                }



                if (m_ScreenPnts.Length > 1)
                {
                    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);



                    pathFigure.IsClosed = false;

                    dc.DrawGeometry(null, pen, PathGmtr);
                }



                if (dtGridRoute != null)
                {
                    FormattedText frm = new FormattedText("o",
                                                          System.Globalization.CultureInfo.GetCultureInfo("en-us"),
                                                          System.Windows.FlowDirection.RightToLeft,
                                                          new System.Windows.Media.Typeface("Arial"),
                                                          18, System.Windows.Media.Brushes.Red);

                    for (int i = 0; i < dtGridRoute.Items.Count; i++)
                    {
                        if (dtGridRoute.SelectedIndex == i)
                        {
                            frm.SetFontSize(24);
                        }
                        else
                        {
                            frm.SetFontSize(18);
                        }


                        OsmRouteData DetailData = ((List <OsmRouteData>)dtGridRoute.ItemsSource)[i];
                        VMMainViewModel.Instance.ConvertCoordGroundToPixel(DetailData.X, DetailData.Y, ref PixelX, ref PixelY);


                        frm.SetFontWeight(System.Windows.FontWeights.Bold);
                        frm.TextAlignment = TextAlignment.Center;
                        dc.DrawText(frm, new System.Windows.Point(PixelX - frm.Width / 2, PixelY - frm.Height / 2));


                        FormattedText frmNum = new FormattedText((i + 1).ToString(),
                                                                 System.Globalization.CultureInfo.GetCultureInfo("en-us"),
                                                                 System.Windows.FlowDirection.LeftToRight,
                                                                 new System.Windows.Media.Typeface("Arial"),
                                                                 14, System.Windows.Media.Brushes.Red);

                        frmNum.SetFontWeight(System.Windows.FontWeights.Bold);

                        dc.DrawText(frmNum, new System.Windows.Point(PixelX, PixelY));
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 7
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)
            {
            }
        }
        private void cmdInsert_Click(object sender, RoutedEventArgs e)
        {
            int j = dtGridRoute.SelectedIndex;
            if (j < 0) return;

            OsmRouteData Rdata = new OsmRouteData();

            ((List<OsmRouteData>)(dtGridRoute.ItemsSource)).Insert(j, Rdata);

            dtGridRoute.Items.Refresh();
            dtGridRoute.SelectedItem = Rdata;
            dtGridRoute.CurrentItem = Rdata;

            DataGridWPFUtility.DataGridGotoByIndex(dtGridRoute, j);

        }
        private void cmdNew_Click(object sender, RoutedEventArgs e)
        {
            OsmRouteData Rdata = new OsmRouteData();
            ((List<OsmRouteData>)(dtGridRoute.ItemsSource)).Add(Rdata);
            dtGridRoute.Items.Refresh();
            dtGridRoute.SelectedItem = Rdata;
            //    dtGridRoute.SelectedIndex = dtGridRoute.Items.Count;
            dtGridRoute.CurrentItem = Rdata;

            DataGridWPFUtility.DataGridGotoLast(dtGridRoute);

        }
        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)
            {
            }
        }