コード例 #1
0
        void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
        {
            StarMap = e.Result;
            StarMap.Initialize();

            MapCanvas.Children.Clear();

            // add bodies and orbits to canvas
            foreach (var star in StarMap.CelestialObjects.Where(o => o.CelestialObjectType == CelestialObjectType.Star))
            {
                var starIcon = new StarIcon(star, this);
                MapCanvas.Children.Add(starIcon);
                MapCanvas.Children.Add(new OrbitIcon(starIcon, this));
                ProcessSatellites(starIcon, StarMap.CelestialObjects);
            }

            MapIcons = MapCanvas.Children.OfType <IMapIcon>().Where(icon => icon.Body != null).ToDictionary(icon => icon.Body.CelestialObjectID);

            // add links to canvas
            foreach (var link in e.Result.ObjectLinks)
            {
                var linkIcon = new LinkIcon(MapIcons[link.FirstObjectID].Body, MapIcons[link.SecondObjectID].Body, this);
                MapCanvas.Children.Add(linkIcon);
            }

            // add transits to canvas
            foreach (var transit in e.Result.Transits)
            {
                MapCanvas.Children.Add(new TransitIcon(transit, this));
            }

            PlanetTree.ItemsSource = e.Result.CelestialObjects.Where(body => body.OrbitNestingLevel == 0);
        }
コード例 #2
0
        void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
        {
            StarMap = e.Result;
            StarMap.Initialize();

            MapCanvas.Children.Clear();

            // add bodies and orbits to canvas
            foreach (var star in StarMap.CelestialObjects.Where(o => o.CelestialObjectType == CelestialObjectType.Star)) {
                var starIcon = new StarIcon(star, this);
                MapCanvas.Children.Add(starIcon);
                MapCanvas.Children.Add(new OrbitIcon(starIcon, this));
                ProcessSatellites(starIcon, StarMap.CelestialObjects);
            }

            MapIcons = MapCanvas.Children.OfType<IMapIcon>().Where(icon => icon.Body != null).ToDictionary(icon => icon.Body.CelestialObjectID);

            // add links to canvas
            foreach (var link in e.Result.ObjectLinks) {
                var linkIcon = new LinkIcon(MapIcons[link.FirstObjectID].Body, MapIcons[link.SecondObjectID].Body, this);
                MapCanvas.Children.Add(linkIcon);
            }

            // add transits to canvas
            foreach (var transit in e.Result.Transits) {
                MapCanvas.Children.Add(new TransitIcon(transit, this));
            }

            PlanetTree.ItemsSource = e.Result.CelestialObjects.Where(body => body.OrbitNestingLevel == 0);
        }
コード例 #3
0
        void client_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                m_mapDataList = new ObservableCollection <MapData>();
                m_mapDataList = e.Result;
                double avgLongitude = Convert.ToDouble(m_mapDataList.Average(m => m.Longitude));
                double avgLatitude  = Convert.ToDouble(m_mapDataList.Average(m => m.Latitude));

                foreach (MapData mapData in m_mapDataList)
                {
                    m_pushPinButton       = new Button();
                    m_toolTip             = new ToolTip();
                    m_toolTip.DataContext = mapData;
                    m_toolTip.Template    = Application.Current.Resources["MapToolTipTemplate"] as ControlTemplate;
                    ToolTipService.SetToolTip(m_pushPinButton, m_toolTip);
                    m_pushPinButton.Content = mapData.CompanyMapAcronym;
                    if (mapData.DeviceType == "Device")
                    {
                        m_pushPinButton.Template = Application.Current.Resources["BluePushPinButtonTemplate"] as ControlTemplate;
                    }
                    else if (mapData.Desired == true)
                    {
                        m_pushPinButton.Template = Application.Current.Resources["YellowPushPinButtonTemplate"] as ControlTemplate;
                    }
                    else
                    {
                        m_pushPinButton.Template = Application.Current.Resources["WhitePushPinButtonTemplate"] as ControlTemplate;
                    }
                    //pushPinButton.SetValue(MapLayer.MapPositionProperty, new Location(Convert.ToDouble(mapData.Latitude), Convert.ToDouble(mapData.Longitude)));
                    //pushPinButton.SetValue(MapLayer.MapPositionMethodProperty, PositionMethod.Center);
                    (VirtualEarthPlanningMap.FindName("PushpinLayer") as MapLayer).AddChild(m_pushPinButton, new Location(Convert.ToDouble(mapData.Latitude), Convert.ToDouble(mapData.Longitude)));
                }
                VirtualEarthPlanningMap.Center = new Location(avgLatitude, avgLongitude);
            }
            else
            {
                SystemMessages sm;
                if (e.Error is FaultException <CustomServiceFault> )
                {
                    FaultException <CustomServiceFault> fault = e.Error as FaultException <CustomServiceFault>;
                    sm = new SystemMessages(new Message()
                    {
                        UserMessage = fault.Detail.UserMessage, SystemMessage = fault.Detail.SystemMessage, UserMessageType = MessageType.Error
                    },
                                            ButtonType.OkOnly);
                }
                else
                {
                    sm = new SystemMessages(new Message()
                    {
                        UserMessage = "Failed to Retrieve Planning Map Data", SystemMessage = e.Error.Message, UserMessageType = MessageType.Error
                    },
                                            ButtonType.OkOnly);
                }

                sm.ShowPopup();
            }
        }
コード例 #4
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     mapData = e.Result;
     if (App.UserName != null) {
         App.Player = mapData.Players.SingleOrDefault(p => p.Name == App.UserName); //todo: don't use linear search?
         if (App.Player == null) App.Service.GetMapDataAsync(App.UserName, App.Password);
     }
 }
コード例 #5
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     mapData = e.Result;
     if (App.UserName != null)
     {
         App.Player = mapData.Players.SingleOrDefault(p => p.Name == App.UserName); //todo: don't use linear search?
         if (App.Player == null)
         {
             App.Service.GetMapDataAsync(App.UserName, App.Password);
         }
     }
 }
コード例 #6
0
ファイル: PlanningMap.xaml.cs プロジェクト: JiahuiGuo/openPDC
        void client_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                m_mapDataList = new ObservableCollection<MapData>();
                m_mapDataList = e.Result;
                double avgLongitude = Convert.ToDouble(m_mapDataList.Average(m => m.Longitude));
                double avgLatitude = Convert.ToDouble(m_mapDataList.Average(m => m.Latitude));

                foreach (MapData mapData in m_mapDataList)
                {
                    m_pushPinButton = new Button();
                    m_toolTip = new ToolTip();
                    m_toolTip.DataContext = mapData;
                    m_toolTip.Template = Application.Current.Resources["MapToolTipTemplate"] as ControlTemplate;
                    ToolTipService.SetToolTip(m_pushPinButton, m_toolTip);
                    m_pushPinButton.Content = mapData.CompanyMapAcronym;
                    if (mapData.DeviceType == "Device")
                        m_pushPinButton.Template = Application.Current.Resources["BluePushPinButtonTemplate"] as ControlTemplate;
                    else if (mapData.Desired == true)
                        m_pushPinButton.Template = Application.Current.Resources["YellowPushPinButtonTemplate"] as ControlTemplate;
                    else
                        m_pushPinButton.Template = Application.Current.Resources["WhitePushPinButtonTemplate"] as ControlTemplate;
                    //pushPinButton.SetValue(MapLayer.MapPositionProperty, new Location(Convert.ToDouble(mapData.Latitude), Convert.ToDouble(mapData.Longitude)));
                    //pushPinButton.SetValue(MapLayer.MapPositionMethodProperty, PositionMethod.Center);
                    (VirtualEarthPlanningMap.FindName("PushpinLayer") as MapLayer).AddChild(m_pushPinButton, new Location(Convert.ToDouble(mapData.Latitude), Convert.ToDouble(mapData.Longitude)));
                }
                VirtualEarthPlanningMap.Center = new Location(avgLatitude, avgLongitude);
            }
            else
            {
                SystemMessages sm;
                if (e.Error is FaultException<CustomServiceFault>)
                {
                    FaultException<CustomServiceFault> fault = e.Error as FaultException<CustomServiceFault>;
                    sm = new SystemMessages(new Message() { UserMessage = fault.Detail.UserMessage, SystemMessage = fault.Detail.SystemMessage, UserMessageType = MessageType.Error },
                        ButtonType.OkOnly);
                }
                else
                    sm = new SystemMessages(new Message() { UserMessage = "Failed to Retrieve Planning Map Data", SystemMessage = e.Error.Message, UserMessageType = MessageType.Error },
                        ButtonType.OkOnly);

                sm.ShowPopup();
            }
        }
コード例 #7
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     e.Result.Initialize();
 }
コード例 #8
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     e.Result.Initialize();
 }
コード例 #9
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     bodies = e.Result.CelestialObjects;
     view   = new PagedCollectionView(bodies);
     PlanetGrid.ItemsSource = view;
 }
コード例 #10
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     bodies = e.Result.CelestialObjects;
     view = new PagedCollectionView(bodies);
     PlanetGrid.ItemsSource = view;
 }
コード例 #11
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     PlanetGrid.ItemsSource = e.Result.Players;
 }
コード例 #12
0
 void Service_GetMapDataCompleted(object sender, GetMapDataCompletedEventArgs e)
 {
     PlanetGrid.ItemsSource = e.Result.Players;
 }