コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: guusbeckett/GTec
        private void PinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            foreach (UIElement element in layer.Children)
            {
                try
                {
                    if (!(element is InfoBox))
                    {
                        continue;
                    }

                    if ((element as InfoBox).Tag == "Popup")
                    {
                        (element as InfoBox).Visibility = Visibility.Collapsed;
                    }
                }
                catch
                { }
            }

            Pushpin pp = sender as Pushpin;

            try
            {
                InfoBoxData ibd = (InfoBoxData)pp.Tag;
                InfoBox     box = new InfoBox();
                box.AddData(ibd);
                layer.Children.Add(box);
                box.Tag = "Popup";

                if (!String.IsNullOrEmpty(ibd.Title) || !String.IsNullOrEmpty(ibd.Description))
                {
                    MapLayer.SetPosition(box, MapLayer.GetPosition(pp));
                }
                else
                {
                    box.Visibility = Visibility.Collapsed;
                }
                SettingsPane.GetForCurrentView().CommandsRequested += onCommandsRequested;
            }
            catch { }
        }
コード例 #2
0
        public static InfoBoxData GetGPSPosition(string unitID)
        {
            if (string.IsNullOrEmpty(unitID))
            {
                return(null);
            }
            Facade.IResource facResource = new Facade.Resource();
            DataSet          dsPosition  = facResource.GetCurrentGPSPosition(unitID);

            InfoBoxData retVal = new InfoBoxData();

            if (dsPosition.Tables[0].Rows.Count == 0)
            {
                return(retVal);
            }

            DataRow row = dsPosition.Tables[0].Rows[0];

            #region get the Latitude and the Longitude

            decimal latitude = 0.0M;
            if (row["Latitude"] != DBNull.Value)
            {
                latitude = decimal.Parse(row["Latitude"].ToString());
            }
            else
            {
                decimal latitude_degree = decimal.Parse(row["Latitude_Degree"].ToString());
                decimal latitude_minute = decimal.Parse(row["Latitude_Minute"].ToString());
                decimal latitude_second = decimal.Parse(row["Latitude_Second"].ToString());
                latitude = latitude_degree + (latitude_minute / 60) + (latitude_second / 3600);


                if (row["Latitude_Indicator"].ToString() == "S")
                {
                    latitude = -latitude;
                }
            }
            retVal.Latitude = latitude;


            decimal longitude = 0.0M;

            if (row["Longitude"] != DBNull.Value)
            {
                longitude = decimal.Parse(row["Longitude"].ToString());
            }
            else
            {
                decimal longitude_degree = decimal.Parse(row["Longitude_Degree"].ToString());
                decimal longitude_minute = decimal.Parse(row["Longitude_Minute"].ToString());
                decimal longitude_second = decimal.Parse(row["Longitude_Second"].ToString());
                longitude = longitude_degree + (longitude_minute / 60) + (longitude_second / 3600);

                if (row["Longitude_Indicator"].ToString() == "W")
                {
                    longitude = -longitude;
                }
            }
            retVal.Longitude = longitude;

            #endregion

            #region Set the Resource Ref
            retVal.Title     = row["ResourceRef"].ToString();
            retVal.Gazetteer = row["Gazetteer"].ToString();
            retVal.Reason    = row["Reason"].ToString();

            DateTime gpsDate = Convert.ToDateTime(row["DateStamp"].ToString());
            retVal.dateStamp = gpsDate.ToShortDateString() + " " + gpsDate.ToShortTimeString();

            #endregion

            return(retVal);
        }