예제 #1
0
        private void sendToPreview()
        {
            if (_selectedShotItem != null)
            {
                if (_itemsOnPreview != null)
                {
                    SocketCommand commandToSend = new SocketCommand();

                    XmlDataRow xmlRow = new XmlDataRow();

                    //send the item to the preview scene, will need to add instancing so more than one item can be put on each layer
                    switch (_selectedShotItem.Type)
                    {
                    case "LONGESTDRIVE":
                    case "PLAYERSHOT":
                        _selectedShotItem.Template = "DistanceMarker";

                        xmlRow.Add("Marker_Translate", _selectedShotItem.Shots[0].VirtualLocation.ToString());
                        xmlRow.Add("Distance", _selectedShotItem.Shots[0].VirtualDistance.ToString());
                        xmlRow.Add("Name", _selectedShotItem.Shots[0].Player.LastName);
                        xmlRow.Add("Headshot", _selectedShotItem.Shots[0].Player.Headshot.AbsolutePath);

                        _selectedShotItem.Shots[0].TemplateData = xmlRow.ToString();

                        break;

                    case "BIRDIES":
                    case "PARS":
                    case "BOGEYS":
                    case "DBLBOGEYS":
                        _selectedShotItem.Template = "ScoreMarker";

                        foreach (Shot shot in _selectedShotItem.Shots)
                        {
                            xmlRow.Add("Marker_Translate", shot.VirtualLocation.ToString());
                            shot.TemplateData += xmlRow.ToString();
                        }

                        break;
                    }

                    commandToSend.Command    = CommandType.ShowPage;
                    commandToSend.CommandID  = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List <CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", _selectedShotItem.Template));
                    commandToSend.Parameters.Add(new CommandParameter("DestScene", "Preview"));
                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    _talker.Talk(commandToSend);

                    //update the items on preview list (may have to wait for an acknowledgement from the scene first...
                    ShotItem _previewItem = _itemsOnPreview.SingleOrDefault(i => i.Description == _selectedShotItem.Description);

                    if (_previewItem == null)
                    {
                        ItemsOnPreview.Add(_selectedShotItem);
                    }
                }
                else
                {
                    ItemsOnPreview.Add(_selectedShotItem);
                }
            }
        }