Example #1
0
        private void sendToAir()
        {
            if (_selectedItemOnPreview != null)
            {
                if (_itemsOnAir != null)
                {
                    SocketCommand commandToSend = new SocketCommand();

                    XmlDataRow xmlRow = new XmlDataRow();

                    //send the item to the output scene, will need to add instancing so more than one item can be put on each layer
                    foreach (ShotItem shotItem in _itemsOnPreview)
                    {
                        string templateData = "";

                        foreach (Shot shot in shotItem.Shots)
                        {
                            templateData += shot.TemplateData;
                        }

                        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", "AIR"));
                        commandToSend.TemplateData = templateData;

                        _talker.Talk(commandToSend);
                    }



                    //update the items on the air list
                    ShotItem _airItem = _itemsOnAir.SingleOrDefault(i => i.Description == _selectedItemOnPreview.Description);

                    if (_airItem == null)
                    {
                        ItemsOnAir.Add(_selectedItemOnPreview);
                    }
                }
                else
                {
                    ItemsOnAir.Add(_selectedItemOnPreview);
                }
            }
        }
Example #2
0
        private void loadPlayerPreviousShots()
        {
            for (int i = _shotItems.Count - 1; i >= 0; i--)
            {
                if (_shotItems[i].Type == "PLAYERSHOT")
                {
                    _shotItems.RemoveAt(i);
                }
            }

            if (_selectedPlayer != null && _selectedHole != null)
            {
                List <Shot> shots = DbConnection.GetShots(_selectedHole.HoleID, 1, _selectedPlayer.PlayerID.ToString(), _players.ToList());

                foreach (Shot shot in shots)
                {
                    if (shot.Round.RoundID != _selectedRound.RoundID) //don't put the current round's shot up there.  it may not have been saved yet, and it will be put on preview by clicking on live preview
                    {
                        ShotItem shotItem = new ShotItem();
                        shotItem.Type  = "PLAYERSHOT";
                        shotItem.Shots = new List <Shot>();
                        shotItem.Shots.Add(shot);

                        string distance = "";

                        if (shot.VirtualDistance.Trim() != "")
                        {
                            distance = "(" + shot.VirtualDistance + " yds)";
                        }

                        shotItem.Description = _selectedPlayer.LastName + " - Round " + shot.Round.RoundNum.ToString() + " drive " + distance;

                        ShotItems.Add(shotItem);
                    }
                }
            }
        }
Example #3
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);
                }
            }
        }
Example #4
0
        private void loadExtraItems()
        {
            if (_selectedHole != null && _players != null)
            {
                ObservableCollection <ShotItem> items = new ObservableCollection <ShotItem>();

                ShotItem item = null;

                //birdies
                item = new ShotItem();
                List <Shot> birdies = DbConnection.GetShots(_selectedHole.HoleID, 1, -1, _players.ToList());
                item.Description = "All Birdies";
                item.Type        = "BIRDIES";
                item.Shots       = birdies;
                items.Add(item);

                //pars
                item = new ShotItem();
                List <Shot> pars = DbConnection.GetShots(_selectedHole.HoleID, 1, 0, _players.ToList());
                item.Description = "All Pars";
                item.Type        = "PARS";
                item.Shots       = pars;
                items.Add(item);

                //bogeys
                item = new ShotItem();
                List <Shot> bogeys = DbConnection.GetShots(_selectedHole.HoleID, 1, 1, _players.ToList());
                item.Description = "All Bogeys";
                item.Type        = "BOGEYS";
                item.Shots       = bogeys;
                items.Add(item);

                //double bogeys or worse
                item = new ShotItem();
                List <Shot> dblbogeys = DbConnection.GetShots(_selectedHole.HoleID, 1, 2, _players.ToList());
                item.Description = "All Double Bogeys or Worse";
                item.Type        = "DBLBOGEYS";
                item.Shots       = dblbogeys;
                items.Add(item);

                //longest drive(s)

                item = new ShotItem();
                List <Shot> longestDrive = DbConnection.GetLongestDrive(_selectedHole.HoleID, 1, _players.ToList());

                string desc = "Longest Drive Overall";

                if (longestDrive.Count > 0)
                {
                    desc += " (";

                    foreach (Shot shot in longestDrive)
                    {
                        desc += shot.Player.LastName + ", ";
                    }

                    desc = desc.Substring(0, desc.Length - 2);

                    desc += " - " + longestDrive[0].VirtualDistance + " yds)";
                }
                else
                {
                    desc += " (none)";
                }

                item.Description = desc;
                item.Type        = "LONGESTDRIVE";
                item.Shots       = longestDrive;
                items.Add(item);

                for (int i = 1; i <= 4; i++)
                {
                    item         = new ShotItem();
                    longestDrive = DbConnection.GetLongestDrive(_selectedHole.HoleID, 1, _players.ToList(), i);


                    desc = "Longest Drive Round " + i.ToString();

                    if (longestDrive.Count > 0)
                    {
                        desc += " (";

                        foreach (Shot shot in longestDrive)
                        {
                            desc += shot.Player.LastName + ", ";
                        }

                        desc = desc.Substring(0, desc.Length - 2);

                        desc += " - " + longestDrive[0].VirtualDistance + " yds)";
                    }
                    else
                    {
                        desc += " (none)";
                    }

                    item.Description = desc;
                    item.Type        = "LONGESTDRIVE";
                    item.Shots       = longestDrive;
                    items.Add(item);
                }


                ShotItems = items;
            }
        }