Beispiel #1
0
 private void client_SaveActorCompleted(object sender, SaveActorCompletedEventArgs e)
 {
     try
     {
         if (e.Result.Success)
         {
             RdlTagCollection tags = RdlTagCollection.FromString(e.Result.TagString);
             if (tags != null)
             {
                 foreach (var actor in tags.GetActors())
                 {
                     var tile = _tiles.Where(t => t.Place.ID == actor.OwnerID).FirstOrDefault();
                     if (tile != null)
                     {
                         tile.Place.Actors.Add(actor);
                         this.PlaceChanged(new PlaceEventArgs(tile.Place));
                     }
                 }
             }
         }
     }
     finally
     {
         ctlWait.Hide();
     }
 }
Beispiel #2
0
 private void client_GetActorsCompleted(object sender, GetActorsCompletedEventArgs e)
 {
     if (e.Result.Success && _selectedTile != null)
     {
         _selectedTile.Place.Actors.Clear();
         _selectedTile.Place.Actors.AddRange(RdlTagCollection.FromString(e.Result.TagString).GetActors());
         this.PlaceChanged(new PlaceEventArgs(_selectedTile.Place));
     }
 }
Beispiel #3
0
        private void client_GetMapNamesCompleted(object sender, GetMapNamesCompletedEventArgs e)
        {
            if (e.Result.Success)
            {
                // Handle map names.
                Game.LoadMapDetails(RdlTagCollection.FromString(e.Result.TagString).GetTags <RdlTag>("MAP", "MAP"));

                // Display points on the map where the map details are defined.
                this.Dispatcher.BeginInvoke(() => this.LoadMaps());
            }
        }
        private void LoadTemplates(string tagString, List <RdlActor> list, ActorList control)
        {
            List <RdlActor> actors = RdlTagCollection.FromString(tagString).GetActors();

            if (actors.Count > 0)
            {
                list.Clear();
                list.AddRange(actors);
                control.ItemsSource = list;
            }
        }
Beispiel #5
0
        private static RdlTagCollection GetRdlTagsFromResource(string fileName)
        {
            var info = Application.GetResourceStream(new Uri(String.Concat(Asset.AssetPath, "Data/", fileName), UriKind.Relative));

            if (info == null || info.Stream == null)
            {
                return(new RdlTagCollection());
            }

            using (var sr = new StreamReader(info.Stream))
            {
                return(RdlTagCollection.FromString(sr.ReadToEnd()));
            }
        }
        private void CompleteReceive(Message message)
        {
            CommunicatorResponseEventArgs args = new CommunicatorResponseEventArgs(this,
                                                                                   RdlTagCollection.FromString(message.GetBody <string>()));

            if (_altResponse != null)
            {
                _altResponse(args);
            }
            else
            {
                this.Response(args);
            }

            // Signal the thread pool to start another single asynchronous request to Receive messages from the server
            _waitObject.Set();
        }
 private void client_SaveActorCompleted(object sender, SaveActorCompletedEventArgs e)
 {
     try
     {
         if (e.Result.Success)
         {
             RdlTagCollection tags = RdlTagCollection.FromString(e.Result.TagString);
             if (tags != null)
             {
                 foreach (var actor in tags.GetActors())
                 {
                     ctlMap.UpdateActor(actor);
                 }
             }
         }
     }
     finally
     {
         ctlWait.Hide();
     }
 }
Beispiel #8
0
        private void client_GetPlaceTypesCompleted(object sender, GetPlaceTypesCompletedEventArgs e)
        {
            if (e.Result.Success)
            {
                var placeTypes = RdlTagCollection.FromString(e.Result.TagString).Where(t => t.TagName == "PLACETYPE" && t.TypeName == "PLACETYPE");
                if (placeTypes.Count() > 0)
                {
                    List <PlaceTypeDesc> types = new List <PlaceTypeDesc>();
                    foreach (var pt in placeTypes)
                    {
                        types.Add(new PlaceTypeDesc {
                            Name = pt.GetArg <string>(0)
                        });
                    }
                    this.Dispatcher.BeginInvoke(() => this.BindPlaceTypes(types));
                }

                //BuilderServiceClient client = ServiceManager.CreateBuilderServiceClient();
                //client.GetMapNamesCompleted += new EventHandler<GetMapNamesCompletedEventArgs>(client_GetMapNamesCompleted);
                //client.GetMapNamesAsync(_token);
            }
        }
Beispiel #9
0
 private void client_SavePlacesCompleted(object sender, SavePlacesCompletedEventArgs e)
 {
     _placesSavedCount++;
     if (_placesSavedCount >= _placesToSaveCount)
     {
         _placesSavedCount  = 0;
         _placesToSaveCount = 0;
         ctlWait.Hide();
     }
     if (e.Result.Success)
     {
         // TODO: Display successful save.
         RdlTagCollection tags  = RdlTagCollection.FromString(e.Result.TagString);
         RdlPlace         place = e.UserState as RdlPlace;
         if (place != null)
         {
             var savedPlace = tags.GetPlaces().Where(p => p.X == place.X && p.Y == place.Y && p.Z == place.Z).FirstOrDefault();
             if (savedPlace != null)
             {
                 place = savedPlace;
             }
             var tile = _tiles.Where(t => t.Location.X == place.X &&
                                     t.Location.Y == place.Y &&
                                     t.Location.Z == place.Z).FirstOrDefault();
             if (tile != null)
             {
                 tile.IsModified = false;
                 tile.Refresh(place);
             }
         }
     }
     else
     {
         // TODO: Display error message.
     }
 }