Exemple #1
0
        public static PlayerCommand DeserializeCommandObject(string CommandObjectString)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(PlayerCommand));
            PlayerCommand ObjectToReturn = new PlayerCommand();
            StringReader StringToDeserialize = new StringReader(CommandObjectString);

            try
            {
                ObjectToReturn = (PlayerCommand)serializer.Deserialize(StringToDeserialize);
                return ObjectToReturn;
            }
            finally
            { StringToDeserialize.Close(); }
        }
Exemple #2
0
        public static string SerializeCommandObject(PlayerCommand CommandObject)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(PlayerCommand));
            StringWriter StringToSend = new StringWriter();

            try
            {
                serializer.Serialize(StringToSend, CommandObject);

                return StringToSend.ToString();
            }
            finally
            { StringToSend.Close(); }
        }
        private void previewTidbit()
        {
            if (_selectedTidbit != null)
            {
                PlayerCommand commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                commandToSend.CommandID = Guid.NewGuid().ToString();
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", "TeamTidbitPreview"));

                XmlDataRow xmlRow = new XmlDataRow();

                xmlRow.Add("TIDBIT_1", _selectedTidbit.TidbitText);
                xmlRow.Add("TRICODE_1", _team.Tricode);
                xmlRow.Add("SWATCH_1", _team.SwatchTga.LocalPath);
                xmlRow.Add("TEAMLOGO_1", _team.LogoTgaNoKey.LocalPath);

                commandToSend.TemplateData = xmlRow.GetXMLString();

                OnSendCommand(commandToSend, null);
            }
        }
        private void showPlayerTidbits()
        {
            if (_currentPlayer.Tidbits != null)
            {
                if (_currentPlayerTidbit < _currentPlayer.Tidbits.Count)
                {
                    PlayerCommand commandToSend = new PlayerCommand();

                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", "CurrentSelection"));

                    XmlDataRow xmlRow = new XmlDataRow();

                    xmlRow.Add("CURRENT_SELECTION_STATE", "SHOWTIDBITS");

                    string curSelStr = _currentPlayer.FirstName + " " + _currentPlayer.LastName + " <font EventFranklinGothic Book>" + _currentPlayer.Position + " - " + _currentPlayer.School.Name + "<\\font>";

                    if (_currentPlayer.TradeTidbit.Trim() != "")
                    {
                        curSelStr += " " + _currentPlayer.TradeTidbit;
                    }

                    xmlRow.Add("PLAYER_1", curSelStr);
                    xmlRow.Add("TIDBIT_1", _currentPlayer.Tidbits[_currentPlayerTidbit].TidbitText);

                    _currentPlayerTidbit++;

                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    //raise an event to the main...
                    OnSendCommand(commandToSend, null);
                }
            }
        }
        private void updateTotem(bool changeTotem = false)
        {
            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.CommandID = Guid.NewGuid().ToString();
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Next"));

            XmlDataRow xmlRow = new XmlDataRow();

            Pick nextPick1 = null;
            Pick nextPick2 = null;

            if (Global.GlobalCollections.Instance.OnTheClock != null)
            {
                nextPick1 = (Pick)Global.GlobalCollections.Instance.DraftOrder.SingleOrDefault(p => p.OverallPick == Global.GlobalCollections.Instance.OnTheClock.OverallPick + 1);
                nextPick2 = (Pick)Global.GlobalCollections.Instance.DraftOrder.SingleOrDefault(p => p.OverallPick == Global.GlobalCollections.Instance.OnTheClock.OverallPick + 2);
            }

            if (nextPick1 != null)
            {
                xmlRow.Add("ABBREV_4_1", nextPick1.Team.Tricode);

                if (nextPick2 != null)
                {
                    xmlRow.Add("ABBREV_4_2", nextPick2.Team.Tricode);
                }
                else
                {
                    xmlRow.Add("ABBREV_4_2", "");
                }
            }
            else
            {
                xmlRow.Add("ABBREV_4_1", "");
                xmlRow.Add("ABBREV_4_2", "");
            }

            if (changeTotem)
            {
                xmlRow.Add("CHANGE_TOTEM_FLAG", "1");
            }
            else
            {
                xmlRow.Add("CHANGE_TOTEM_FLAG", "");
            }

            commandToSend.TemplateData = xmlRow.GetXMLString();

            sendCommandToPlayout(commandToSend);
        }
        private void updateClock()
        {
            PlayerCommand commandToSend = new PlayerCommand();

            XmlDataRow xmlRow = new XmlDataRow();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();

            if (_takeClock)
            {
                if (_playlistTabVM.SelectedPlaylist != null)
                {
                    switch (_playlistTabVM.SelectedPlaylist.PlaylistName.ToUpper())
                    {
                        case "PROMPTER":
                            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Prompter"));
                            break;
                        case "BREAK CLOCK":
                            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "BreakClock"));
                            break;
                        default:
                            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
                            xmlRow.Add("TURN_CLOCK_RED", _clockRedUnderMin.ToString().ToUpper());
                            break;
                    }
                }
                else
                {
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
                    xmlRow.Add("TURN_CLOCK_RED", _clockRedUnderMin.ToString().ToUpper());
                }

                if (_playlistTabVM.SelectedPlaylist != null)
                {
                    if (_playlistTabVM.SelectedPlaylist.PlaylistName.ToUpper() != "BREAK CLOCK" && _playlistTabVM.SelectedPlaylist.PlaylistName.ToUpper() != "PROMPTER")
                    {
                        switch (_clockSeconds)
                        {
                            case 0:
                                if (_prevClockSeconds != 0)
                                {
                                    xmlRow.Add("CLOCK_OVERLAY", "PICK IS IN");
                                }
                                break;
                            case 60:
                                if (_clockRedUnderMin)
                                {
                                    xmlRow.Add("CLOCK_COLOR", "RED");
                                }
                                break;
                            default:
                                if (_clockSeconds > _prevClockSeconds && _prevClockSeconds > 0)
                                {
                                    xmlRow.Add("CLOCK_OVERLAY", "PICK IS IN");
                                    xmlRow.Add("CLOCK", "");
                                    _pickIsIn = true;
                                }
                                else
                                {
                                    //if (_useCountdownClock)
                                    //{
                                    //    xmlRow.Add("CLOCK", _countdownClock);
                                    //}
                                    //else
                                    //{
                                    //    if (_pickIsIn == false)
                                    //    {
                                    //        xmlRow.Add("CLOCK", _clock);
                                    //    }
                                    //}

                                    commandToSend.Parameters.Add(new CommandParameter("MergeDataWithoutTransitions", "true"));
                                }

                                break;
                        }

                        if (_clockSeconds == 0)
                        {
                            _takeClock = false;

                        }
                    }
                }
                else
                {
                    _takeClock = true;
                }
            }
            else
            {
                //commandToSend.Parameters.Add(new CommandParameter("MergeDataWithoutTransitions", "true"));
            }

            _prevClockSeconds = _clockSeconds;

            if (_useCountdownClock)
            {
                xmlRow.Add("CLOCK", _countdownClock);
            }
            else
            {
                if (_pickIsIn == false)
                {
                    xmlRow.Add("CLOCK", _clock);
                }
            }

            commandToSend.TemplateData = xmlRow.GetXMLString();

            _clockTalker.Talk(commandToSend);
        }
        private void showPollResults()
        {
            string[] poll = DbConnection.GetPoll(true);

            if (poll != null)
            {
                string pollChip = ConfigurationManager.AppSettings["PollChipDirectory"].ToString() + "\\" + _selectedPollChip.FileName;

                if (File.Exists(pollChip))
                {
                    stopCycle();

                    PlayerCommand commandToSend;

                    commandToSend = new PlayerCommand();

                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Poll"));

                    XmlDataRow xmlRow = new XmlDataRow();

                    xmlRow.Add("TITLE_1", poll[0]);
                    xmlRow.Add("TIDBIT_1", poll[1]);

                    xmlRow.Add("CHIP_1", pollChip);
                    xmlRow.Add("VENT_SWATCH_1", "Images\\Swatches\\black_swatch.tga");

                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    sendCommandToPlayout(commandToSend);
                }
            }
        }
        private void showClock()
        {
            _takeClock = true;
            _pickIsIn = false;

            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

            XmlDataRow xmlRow = new XmlDataRow();

            xmlRow.Add("CLOCK_OVERLAY", "CLOCK");

            commandToSend.TemplateData = xmlRow.GetXMLString();

            sendCommandToPlayout(commandToSend);
        }
        private void sendCommandToPlayout(PlayerCommand commandToSend, Playlist playlist = null)
        {
            try
            {
                PlayoutOutgoingCommand = commandToSend.TemplateData;

                if (playlist == null)
                {
                    _playlistCommands.Add(commandToSend.CommandID, 0);
                }
                else
                {
                    _playlistCommands.Add(commandToSend.CommandID, playlist.PlaylistID);
                }

                _lastCommandID = commandToSend.CommandID;

                _compTalker.Talk(commandToSend);
            }
            catch (Exception ex)
            { }
        }
        private void nextOnTheClock()
        {
            _takeClock = false;

            Global.GlobalCollections.Instance.LoadOnTheClock();

            PlayerCommand commandToSend;

            //send a command to change the clock on-air
            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.CommandID = Guid.NewGuid().ToString();
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

            XmlDataRow xmlRow = new XmlDataRow();

            if (GlobalCollections.Instance.OnTheClock != null)
            {
                xmlRow.Add("ROUND_1", Global.GlobalCollections.Instance.OnTheClock.Round.ToString());
                xmlRow.Add("PICK_1", Global.GlobalCollections.Instance.OnTheClock.OverallPick.ToString());

                if (Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey != null)
                {
                    xmlRow.Add("LOGO_1", Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey.LocalPath);
                }

                if (Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga != null)
                {
                    xmlRow.Add("SWATCH_1", Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga.LocalPath);
                }

                xmlRow.Add("ABBREV_4_1", Global.GlobalCollections.Instance.OnTheClock.Team.Tricode);
            }

            xmlRow.Add("CLOCK_OVERLAY", "ON THE CLOCK");
            xmlRow.Add("CLOCK", "");

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            updateTotem(true);

            sendCommandToPlayout(commandToSend);

            //hide the current selection template
            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "CurrentSelection"));
            //commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            sendCommandToPlayout(commandToSend);

            //show the hashtag on the right side
            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "RightLogo"));

            xmlRow = new XmlDataRow();

            string hashtag = "";

            if (OTCHashtag && SelectedRightLogo != null && SelectedRightLogo.FileName.ToUpper().IndexOf("HASHTAG") > -1)
            {
                hashtag = Global.GlobalCollections.Instance.OnTheClock.Team.Hashtag;
            }

            xmlRow.Add("TIDBIT_1", hashtag);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            sendCommandToPlayout(commandToSend);
        }
        private void cancelAnimateTradeAction(object parameter)
        {
            AskAnimateTrade = false;

            _tradeString = "";

            //maybe just hot change the team on the clock here?

            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

            XmlDataRow xmlRow = new XmlDataRow();

            xmlRow.Add("CLOCK_OVERLAY", "ON THE CLOCK");
            xmlRow.Add("LOGO_1", Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey.LocalPath);
            xmlRow.Add("SWATCH_1", Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga.LocalPath);
            xmlRow.Add("ABBREV_4_1", Global.GlobalCollections.Instance.OnTheClock.Team.Tricode);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            //raise an event to the main...
            OnSendCommand(commandToSend, null);
        }
        private void animateTradeAction(object parameter)
        {
            OnStopCycle();

            AskAnimateTrade = false;

            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
            commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            XmlDataRow xmlRow = new XmlDataRow();

            xmlRow.Add("CLOCK_OVERLAY", "TRADE");
            xmlRow.Add("LOGO_1", Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey.LocalPath);
            xmlRow.Add("SWATCH_1", Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga.LocalPath);
            xmlRow.Add("ABBREV_4_1", Global.GlobalCollections.Instance.OnTheClock.Team.Tricode);

            commandToSend.TemplateData = xmlRow.GetXMLString();

            OnSendCommand(commandToSend, null);

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "TradeInterruption"));

            xmlRow = new XmlDataRow();

            xmlRow.Add("TIDBIT_1", _tradeString);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            OnSendCommand(commandToSend, null);

            _tradeString = "";
        }
        private void updateHashtag()
        {
            //show the hashtag on the right side
            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "RightLogo"));

            XmlDataRow xmlRow = new XmlDataRow();

            string hashtag = "";

            if (OTCHashtag && SelectedRightLogoFilename.ToUpper().IndexOf("HASHTAG") > -1)
            {
                hashtag = Global.GlobalCollections.Instance.OnTheClock.Team.Hashtag;
            }

            xmlRow.Add("TIDBIT_1", hashtag);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            OnSendCommand(commandToSend, null);
        }
        private void updateContent(bool isLastPick)
        {
            PlayerCommand commandToSend = new PlayerCommand();

            if (isLastPick) //show the end of draft template
            {
                commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                commandToSend.CommandID = Guid.NewGuid().ToString();
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", "EndOfDraft"));

                OnSendCommand(commandToSend, null);

                //hide lower3rd templates
                //commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
                //commandToSend.CommandID = Guid.NewGuid().ToString();
                //commandToSend.Parameters = new List<CommandParameter>();
                //commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Lower3rd_Connected"));
                //commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

                //OnSendCommand(commandToSend, null);

                //commandToSend = new PlayerCommand();

                //commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
                //commandToSend.CommandID = Guid.NewGuid().ToString();
                //commandToSend.Parameters = new List<CommandParameter>();
                //commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Lower3rd_Separated"));

                //OnSendCommand(commandToSend, null);
            }
            else
            {
                //hide the current selection template
                commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
                commandToSend.CommandID = Guid.NewGuid().ToString();
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", "CurrentSelection"));

                OnSendCommand(commandToSend, null);

                //commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
                //commandToSend.CommandID = Guid.NewGuid().ToString();
                //commandToSend.Parameters = new List<CommandParameter>();
                //commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Lower3rd_Connected"));

                //OnSendCommand(commandToSend, null);
            }
        }
        private void updateClock(bool isLastPick)
        {
            PlayerCommand commandToSend;

            //send a command to change the clock on-air
            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

            XmlDataRow xmlRow = new XmlDataRow();

            if (isLastPick)
            {
                xmlRow.Add("CLOCK_OVERLAY", "OVERLAY");
                xmlRow.Add("CHIP_1", ConfigurationManager.AppSettings["ClockOverlayDirectory"].ToString() + "\\" + ConfigurationManager.AppSettings["EndOfDraftChip"].ToString());
            }
            else
            {
                xmlRow.Add("ROUND_1", Global.GlobalCollections.Instance.OnTheClock.Round.ToString());
                xmlRow.Add("PICK_1", Global.GlobalCollections.Instance.OnTheClock.OverallPick.ToString());
                xmlRow.Add("LOGO_1", Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey.LocalPath);
                xmlRow.Add("SWATCH_1", Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga.LocalPath);
                xmlRow.Add("ABBREV_4_1", Global.GlobalCollections.Instance.OnTheClock.Team.Tricode);

                xmlRow.Add("CLOCK_OVERLAY", "ON THE CLOCK");
                xmlRow.Add("CLOCK", "");

                updateTotem(true);
            }

            //xmlRow.Add("CLOCK_COLOR", "NORMAL");

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            OnSendCommand(commandToSend, null);
        }
        private void compTalkerDataArrival(PlayerCommand CommandToProcess, string ID)
        {
            KeyValuePair<string, int>? playlistCommand = null;

            setPlayoutFeedbackDelegate handler = setPlayoutFeedback;

            handler(CommandToProcess.Command.ToString());

            switch (CommandToProcess.Command.ToString())
            {
                case "CommandSuccessful":
                    if (CommandToProcess.CommandID != null)
                    {
                        if (CommandToProcess.CommandID.ToString() == "INIT")
                        {
                            _playoutInitialized = true;
                        }
                        else
                        {
                            playlistCommand = _playlistCommands.SingleOrDefault(p => p.Key == CommandToProcess.CommandID.ToString());

                            if (playlistCommand != null)
                            {
                                int playlistID = playlistCommand.Value.Value;

                                if (_playlistTimerRunning)
                                {
                                    Playlist loadedPlaylist = PlaylistTabVM.LoadedPlaylists.SingleOrDefault(p => p.PlaylistID == playlistID);
                                    System.Timers.Timer timer = null;

                                    if (loadedPlaylist != null)
                                    {
                                        timer = loadedPlaylist.Timer;
                                    }

                                    if (timer != null) { timer.Start(); }
                                }

                                if (_playlistCommands.Count > 0)
                                {
                                    try
                                    {
                                        _playlistCommands.Remove(playlistCommand.Value.Key);
                                    }
                                    catch (Exception ex)
                                    { }
                                }
                            }
                            else
                            {
                                if (_playlistTimerRunning)
                                {
                                    playlistCommand = _playlistCommands.SingleOrDefault(p => p.Key == CommandToProcess.CommandID.ToString());

                                    if (playlistCommand != null)
                                    {
                                        int playlistID = playlistCommand.Value.Value;

                                        if (_playlistTimerRunning)
                                        {
                                            System.Timers.Timer timer = PlaylistTabVM.LoadedPlaylists.FirstOrDefault(p => p.PlaylistID == playlistID).Timer;

                                            if (timer != null) { timer.Start(); }
                                        }

                                        _playlistCommands.Remove(playlistCommand.Value.Key);
                                    }
                                }
                            }
                        }
                    }
                    break;
                case "CommandFailed":
                    if (_playlistTimerRunning)
                    {
                        int playlistID = 0;

                        try
                        {
                            playlistCommand = _playlistCommands.SingleOrDefault(p => p.Key == CommandToProcess.CommandID.ToString());

                            if (playlistCommand != null)
                            {
                                playlistID = playlistCommand.Value.Value;

                                //if (_playlistTimerRunning)
                                //{
                                //Playlist loadedPlaylist = PlaylistTabVM.LoadedPlaylists.FirstOrDefault(p => p.PlaylistID == playlistID);
                                //System.Timers.Timer timer = null;

                                //if (loadedPlaylist != null)
                                //{
                                //timer = loadedPlaylist.Timer;

                                //if (timer != null) { timer.Start(); }
                                //}
                                //}

                                if (playlistCommand.Value.Key != null)
                                {
                                    _playlistCommands.Remove(playlistCommand.Value.Key);
                                }

                            }
                        }
                        catch (Exception ex)
                        { }
                        finally
                        {
                            Playlist loadedPlaylist = PlaylistTabVM.LoadedPlaylists[0];

                            if (playlistID > 0)
                            {
                                loadedPlaylist = PlaylistTabVM.LoadedPlaylists.FirstOrDefault(p => p.PlaylistID == playlistID);
                            }

                            System.Timers.Timer timer = null;

                            if (loadedPlaylist != null)
                            {
                                timer = loadedPlaylist.Timer;

                                if (timer != null) { timer.Start(); }
                            }
                        }
                    }

                    break;
            }
        }
        private void initializePlayoutAction(object parameter)
        {
            AskInitializePlayout = false;

            PlayerCommand commandToSend = new PlayerCommand();

            //uncomment this if we want the admin to initialize the playout when the app starts...
            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "Initialize");
            commandToSend.CommandID = "INIT";
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateDirectory", ConfigurationManager.AppSettings["TemplateDirectory"].ToString()));
            commandToSend.Parameters.Add(new CommandParameter("WorkingDirectory", ConfigurationManager.AppSettings["TemplateDirectory"].ToString()));
            commandToSend.Parameters.Add(new CommandParameter("OutputType", ConfigurationManager.AppSettings["OutputType"].ToString()));

            sendCommandToPlayout(commandToSend);
            //*************************************************************************************

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            //commandToSend.Parameters.Add(new CommandParameter("TemplateDirectory", ConfigurationManager.AppSettings["TemplateDirectory"].ToString()));
            //commandToSend.Parameters.Add(new CommandParameter("WorkingDirectory", ConfigurationManager.AppSettings["TemplateDirectory"].ToString()));
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Background"));
            commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            sendCommandToPlayout(commandToSend);

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
            commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            sendCommandToPlayout(commandToSend);

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Next"));
            commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            sendCommandToPlayout(commandToSend);

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "RightLogo"));

            sendCommandToPlayout(commandToSend);

            //nextL3Item();
            //nextRTItem();
        }
        private void hideTradeInterruption()
        {
            OnResetCycle();

            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
            commandToSend.Parameters.Add(new CommandParameter("QueueCommand", "true"));

            XmlDataRow xmlRow = new XmlDataRow();

            xmlRow.Add("CLOCK_OVERLAY", "ON THE CLOCK");
            xmlRow.Add("LOGO_1", Global.GlobalCollections.Instance.OnTheClock.Team.LogoTgaNoKey.LocalPath);
            xmlRow.Add("SWATCH_1", Global.GlobalCollections.Instance.OnTheClock.Team.SwatchTga.LocalPath);
            xmlRow.Add("ABBREV_4_1", Global.GlobalCollections.Instance.OnTheClock.Team.Tricode);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            OnSendCommand(commandToSend, null);

            //show the hashtag on the right side
            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "RightLogo"));

            xmlRow = new XmlDataRow();

            string hashtag = "";

            if (OTCHashtag && SelectedRightLogoFilename != null && SelectedRightLogoFilename.ToUpper().IndexOf("HASHTAG") > -1)
            {
                hashtag = Global.GlobalCollections.Instance.OnTheClock.Team.Hashtag;
            }

            xmlRow.Add("TIDBIT_1", hashtag);

            commandToSend.TemplateData = xmlRow.GetXMLString();
            commandToSend.CommandID = Guid.NewGuid().ToString();

            OnSendCommand(commandToSend, null);

            commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
            commandToSend.CommandID = Guid.NewGuid().ToString();
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "TradeInterruption"));

            OnSendCommand(commandToSend, null);
        }
 private void sendCommandNoTransitions(PlayerCommand commandToSend)
 {
     _clockTalker.Talk(commandToSend);
 }
        private void tradePickAction(object parameter)
        {
            AskTradePick = false;

            if (DbConnection.TradePick(_selectedPick, _selectedTradePickTeam))
            {
                if (Global.GlobalCollections.Instance.OnTheClock != null)
                {
                    int currentPick = Global.GlobalCollections.Instance.OnTheClock.OverallPick;

                    OnSetStatusBarMsg("#" + _selectedPick.OverallPick + " overall pick traded to " + _selectedTradePickTeam.Name, "Green");

                    int pick = _selectedPick.OverallPick;

                    string fromTeam = "";
                    string toTeam = "";

                    if (_selectedPick.Team.Name.ToUpper() == "49ERS")
                    {
                        fromTeam = "49ers";
                    }
                    else
                    {
                        fromTeam = _selectedPick.Team.Name.ToUpper();
                    }

                    if (_selectedTradePickTeam.Name.ToUpper() == "49ERS")
                    {
                        toTeam = "49ers";
                    }
                    else
                    {
                        toTeam = _selectedTradePickTeam.Name.ToUpper();
                    }

                    _tradeString = "<font EventFranklinGothic-Demi>" + fromTeam + "<\\font> trade pick to <font EventFranklinGothic-Demi>" + toTeam + "<\\font>";

                    Global.GlobalCollections.Instance.LoadDraftOrder();
                    Global.GlobalCollections.Instance.LoadOnTheClock();

                    if (pick == currentPick)
                    {
                        OnStopCycle();

                        PromptMessage = "Animate this trade?";
                        AskAnimateTrade = true;
                    }
                    else if (pick == currentPick + 1 || pick == currentPick + 2)
                    {
                        PlayerCommand commandToSend = new PlayerCommand();

                        commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                        commandToSend.Parameters = new List<CommandParameter>();
                        commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Next"));

                        XmlDataRow xmlRow = new XmlDataRow();

                        Pick nextPick1;
                        Pick nextPick2;

                        nextPick1 = (Pick)Global.GlobalCollections.Instance.DraftOrder.SingleOrDefault(p => p.OverallPick == currentPick + 1);
                        nextPick2 = (Pick)Global.GlobalCollections.Instance.DraftOrder.SingleOrDefault(p => p.OverallPick == currentPick + 2);

                        xmlRow.Add("ABBREV_4_1", nextPick1.Team.Tricode);
                        xmlRow.Add("ABBREV_4_2", nextPick2.Team.Tricode);
                        xmlRow.Add("CHANGE_TOTEM_FLAG", "0");

                        commandToSend.TemplateData = xmlRow.GetXMLString();
                        commandToSend.CommandID = Guid.NewGuid().ToString();

                        OnSendCommand(commandToSend, null);
                    }
                }
                else
                {
                    //just reload the draft order
                    Global.GlobalCollections.Instance.LoadDraftOrder();
                }
            }
        }
        private void sendCommandToPlayout(PlayerCommand commandToSend)
        {
            PlayoutOutgoingCommand = commandToSend.Command + "; " + commandToSend.TemplateData;

            _compTalker.Talk(commandToSend);
        }
        protected void OnSendCommand(PlayerCommand command, Playlist playlist)
        {
            SendCommandEventHandler handler = SendCommandEvent;

            if (handler != null)
            {
                handler(command, playlist);
            }
        }
        private void showClockOverlay()
        {
            if (_selectedClockOverlay != null)
            {
                PlayerCommand commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

                XmlDataRow xmlRow = new XmlDataRow();

                if (_selectedClockOverlay.FileName == "<NONE>")
                {
                    xmlRow.Add("CLOCK_OVERLAY", "ON THE CLOCK");
                }
                else
                {
                    xmlRow.Add("CLOCK_OVERLAY", "OVERLAY");
                    xmlRow.Add("CHIP_1", ConfigurationManager.AppSettings["ClockOverlayDirectory"].ToString() + "\\" + _selectedClockOverlay.FileName);
                }

                commandToSend.TemplateData = xmlRow.GetXMLString();
                commandToSend.CommandID = Guid.NewGuid().ToString();

                sendCommandToPlayout(commandToSend);
            }
        }
        protected void OnSendCommandNoTransitions(PlayerCommand command)
        {
            SendCommandNoTransitionsEventHandler handler = SendCommandNoTransitionsEvent;

            if (handler != null)
            {
                handler(command);
            }
        }
        private void showRightLogo()
        {
            if (_selectedRightLogo != null)
            {
                PlayerCommand commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", "RightLogo"));

                XmlDataRow xmlRow = new XmlDataRow();

                if (_selectedRightLogo.FileName == "<NONE>")
                {
                    xmlRow.Add("CHIP_1", "");
                    xmlRow.Add("VISIBLE", "0");
                }
                else
                {
                    xmlRow.Add("CHIP_1", ConfigurationManager.AppSettings["RightLogoDirectory"].ToString() + "\\" + _selectedRightLogo.FileName);
                    xmlRow.Add("VISIBLE", "1");
                }

                if (_selectedRightLogo.FileName.ToUpper().IndexOf("HASHTAG") > -1)
                {
                    xmlRow.Add("TIDBIT_1", _rightSideHashtag);
                }

                commandToSend.TemplateData = xmlRow.GetXMLString();
                commandToSend.CommandID = Guid.NewGuid().ToString();

                sendCommandToPlayout(commandToSend);
            }
        }
        private void showInterruption()
        {
            if (this.SelectedTidbitText != null && this.SelectedTidbitText != "")
            {
                if (OnStopCycle != null) OnStopCycle();

                PlayerCommand commandToSend = new PlayerCommand();

                commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                commandToSend.CommandID = Guid.NewGuid().ToString();
                commandToSend.Parameters = new List<CommandParameter>();
                commandToSend.Parameters.Add(new CommandParameter("TemplateName", Category.Template));

                XmlDataRow xmlRow = new XmlDataRow();

                if (Category.LogoTga != null)
                {
                    xmlRow.Add("CHIP_1", Category.LogoTga.LocalPath);
                }

                if (Category.SwatchFile != null)
                {
                    xmlRow.Add("SWATCH_1", Category.SwatchFile.LocalPath);
                }

                xmlRow.Add("TIDBIT_1", SelectedTidbitText.Trim());

                commandToSend.TemplateData = xmlRow.GetXMLString();

                OnSendCommand(commandToSend, null);
            }
        }
        private void updateCountdownClock()
        {
            if (_useCountdownClock)
            {
                if (_playlistTabVM.SelectedPlaylist != null)
                {
                    PlayerCommand commandToSend = new PlayerCommand();

                    XmlDataRow xmlRow = new XmlDataRow();

                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");

                    commandToSend.Parameters = new List<CommandParameter>();

                    if (_playlistTabVM.SelectedPlaylist.PlaylistName.ToUpper() == "PROMPTER")
                    {
                        commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Prompter"));
                    }
                    else
                    {
                        commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));
                    }

                    commandToSend.Parameters.Add(new CommandParameter("MergeDataWithoutTransitions", "true"));

                    xmlRow.Add("CLOCK", _countdownClock);

                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    _clockTalker.Talk(commandToSend);
                }
            }
        }
 private void clockTalkerDataArrival(PlayerCommand CommandToProcess, string ID)
 {
 }
        private void animateBand()
        {
            PlayerCommand commandToSend = new PlayerCommand();

            XmlDataRow xmlRow = new XmlDataRow();

            switch (_animate)
            {
                case "Animate Off":
                    //MJF
                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", "BandCover"));

                    //xmlRow.Add("ANIMATE_ALL", "1");

                    //commandToSend.TemplateData = xmlRow.GetXMLString();
                    sendCommandToPlayout(commandToSend);

                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "HidePage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("AnimateAll", "1"));

                    xmlRow.Add("ANIMATE_ALL", "1");

                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    //MJF

                    Animate = "Animate On";

                    break;
                case "Animate On":
                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", "BandCover"));

                    //xmlRow.Add("ANIMATE_ALL", "1");

                    //commandToSend.TemplateData = xmlRow.GetXMLString();
                    sendCommandToPlayout(commandToSend);

                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                    commandToSend.CommandID = Guid.NewGuid().ToString();
                    commandToSend.Parameters = new List<CommandParameter>();
                    commandToSend.Parameters.Add(new CommandParameter("AnimateAll", "1"));

                    xmlRow.Add("ANIMATE_ALL", "1");

                    commandToSend.TemplateData = xmlRow.GetXMLString();

                    Animate = "Animate Off";

                    break;
            }

            sendCommandToPlayout(commandToSend);
        }
        private void showPickIsIn()
        {
            //int lastPick = Global.GlobalCollections.Instance.OnTheClock.OverallPick - 1;

            //CurrentPlayer = DbConnection.GetPlayerByPick(lastPick);

            PlayerCommand commandToSend = new PlayerCommand();

            commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
            commandToSend.CommandID = Guid.NewGuid().ToString();
            commandToSend.Parameters = new List<CommandParameter>();
            commandToSend.Parameters.Add(new CommandParameter("TemplateName", "Clock"));

            XmlDataRow xmlRow = new XmlDataRow();

            xmlRow.Add("CLOCK_OVERLAY", "PICK IS IN");
            //xmlRow.Add("CLOCK_COLOR", "NORMAL");

            commandToSend.TemplateData = xmlRow.GetXMLString();

            OnSendCommand(commandToSend, null);
        }