Exemplo n.º 1
0
        private void StartSearch()
        {
            bool found = false;

            AllowTimersTick = false;
            RefreshMapTimer.Start();

            List <Location> locations = new List <Location>();

            EPL_WS.GET_Suspensions_FullDetailed_Result item = new EPL_WS.GET_Suspensions_FullDetailed_Result();

            foreach (Pushpin pushpin in m_PushpinLayer.Children)
            {
                string tag   = pushpin.Tag.ToString();
                int    index = tag.IndexOf("_");

                string ID_Suspension = tag.Substring(0, index);
                string ID_Ramal      = tag.Substring(index + 1, tag.Length - index - 1);

                if (ID_Suspension.Equals(TB_Search.Text))
                {
                    pushpin.RenderTransform = new ScaleTransform
                    {
                        CenterX = pushpin.Width / 2,
                        CenterY = pushpin.Height / 2,
                        ScaleX  = 1.5,
                        ScaleY  = 1.5
                    };

                    Canvas.SetZIndex(pushpin, 1000);

                    locations.Add(pushpin.Location);

                    if (!found)
                    {
                        item            = PinsArray.Where(e => e.ID.ToString().Equals(ID_Suspension)).ElementAt(0);
                        SelectedPushpin = pushpin;
                        found           = true;
                    }
                }
                else
                {
                    pushpin.RenderTransform = new ScaleTransform
                    {
                        CenterX = pushpin.Width / 2,
                        CenterY = pushpin.Height / 2,
                        ScaleX  = 0.75,
                        ScaleY  = 0.75
                    };

                    Canvas.SetZIndex(pushpin, 0);
                }
            }

            if (found)
            {
                MiraMap.SetView(new LocationRect(locations));
                ShowSuspensionDetail(SelectedPushpin, item);
            }
        }
Exemplo n.º 2
0
        private void soapClient_GET_Suspensions_FullDetailedCompleted(object sender, EPL_WS.GET_Suspensions_FullDetailedCompletedEventArgs e)
        {
            try
            {
                if (e.Result != null && e.Result.Length > 0)
                {
                    Locations = new List <Location>();
                    m_PushpinLayer.Children.Clear();
                    m_ControlLayer.Children.Clear();

                    PinsArray.Clear();

                    string Latitude;
                    string Longitude;

                    for (int i = 0; i < e.Result.Length; i++)
                    {
                        if (!AllowSuspensionDetail || (AllowSuspensionDetail && e.Result.ElementAt(i).ID.ToString().Equals(ID_Suspension.ToString())))
                        {
                            LinearGradientBrush PinBackgroundColor;

                            switch (e.Result.ElementAt(i).Status)
                            {
                            case 0:
                                PinBackgroundColor = PinBackgroundColorNormal;
                                break;

                            case 1:
                                PinBackgroundColor = PinBackgroundColorApproved;
                                break;

                            case 2:
                                PinBackgroundColor = PinBackgroundColorExecution;
                                break;

                            case 3:
                                PinBackgroundColor = PinBackgroundColorConcluded;
                                break;

                            default:
                                PinBackgroundColor = PinBackgroundColorNormal;
                                break;
                            }

                            Latitude  = e.Result.ElementAt(i).Coord_Lat == null ? "0.0" : e.Result.ElementAt(i).Coord_Lat.ToString();
                            Longitude = e.Result.ElementAt(i).Coord_Long == null ? "0.0" : e.Result.ElementAt(i).Coord_Long.ToString();

                            if (AllowSuspensionDetail || (!AllowSuspensionDetail && e.Result.ElementAt(i).Status > 0))
                            {
                                PinsArray.Add(e.Result.ElementAt(i));

                                Pushpin pushpin = new Pushpin()
                                {
                                    Background = PinBackgroundColor,
                                    Tag        = string.Format("{0}_{1}", e.Result.ElementAt(i).ID, e.Result.ElementAt(i).ID_Ramal),
                                    Location   = new Location {
                                        Latitude = double.Parse(Latitude), Longitude = double.Parse(Longitude)
                                    },
                                    Cursor = Cursors.Hand
                                };

                                if (CB_Year.SelectedIndex == 0)
                                {
                                    pushpin.Visibility = Visibility.Visible;
                                }
                                else
                                {
                                    pushpin.Visibility = e.Result.ElementAt(i).Status.Equals(CB_Year.SelectedIndex) ? Visibility.Visible : Visibility.Collapsed;
                                }

                                pushpin.MouseLeftButtonDown += new MouseButtonEventHandler(pushpin_MouseLeftButtonDown);

                                pushpin.RenderTransform = new ScaleTransform
                                {
                                    CenterX = pushpin.Width / 2,
                                    CenterY = pushpin.Height / 2,
                                    ScaleX  = 0.75,
                                    ScaleY  = 0.75
                                };

                                m_PushpinLayer.AddChild(pushpin, new Location(double.Parse(Latitude), double.Parse(Longitude)), PositionOrigin.BottomCenter);

                                Locations.Add(pushpin.Location);
                            }
                        }
                    }

                    if (ShowAllPins)
                    {
                        MiraMap.SetView(new LocationRect(Locations));

                        if (MiraMap.ZoomLevel > 16)
                        {
                            MiraMap.ZoomLevel = 16;
                        }

                        DefaultZoomLevel = MiraMap.ZoomLevel;
                        ShowAllPins      = false;
                    }

                    RefreshMapTimer.Start();
                }
                else
                {
                    MiraMap.ZoomLevel = 13;
                }
            }
            catch
            {
            }
        }