Exemplo n.º 1
0
        private void SetLiveSettings()
        {
            if (m_liveEnabled)
            {
                // stop the live
                File.Delete(Config.GetFile(Config.Dir.Config, LiveSettingsFileName));
                m_liveEnabled = false;
                SetLiveStatus();
            }
            else
            {
                // create a settings with all live settings
                var liveList = m_center.Scores.Items.Where(sc => sc.IsLive() && !sc.IsVirtual());
                if (liveList.Count() == 0)
                {
                    // no live score configure
                    GUIDialogText ww = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT);
                    ww.SetHeading("ScoreCenter");
                    ww.SetText(LocalizationManager.GetString(Labels.NoLiveScore));
                    ww.DoModal(GetID);
                }
                else
                {
                    // create new score center
                    ScoreCenter liveExport = new ScoreCenter();
                    liveExport.Parameters = m_center.Parameters;
                    liveExport.Setup      = m_center.Setup;
                    liveExport.Styles     = m_center.Styles;

                    // clone the scores
                    foreach (BaseScore sc in liveList)
                    {
                        m_center.ReadChildren(sc);
                    }

                    liveList = m_center.Scores.Items.Where(sc => sc.IsLive() && sc.IsScore());
                    var ll = new List <BaseScore>(liveList.Count());
                    foreach (BaseScore score in liveList)
                    {
                        BaseScore livescore = score.Clone(score.Id);
                        BaseScore parent    = m_center.FindScore(livescore.Parent);
                        if (parent != null)
                        {
                            // use parent icon and name for notification
                            livescore.Name  = parent.LocName;
                            livescore.Image = parent.Image;
                        }
                        livescore.ApplyRangeValue(true);
                        ll.Add(livescore);
                    }
                    liveExport.Scores       = new ScoreCenterScores();
                    liveExport.Scores.Items = ll.ToArray();

                    // create the settings
                    Tools.SaveSettings(Config.GetFile(Config.Dir.Config, LiveSettingsFileName), liveExport, false, true);

                    // update the status
                    m_liveEnabled = true;
                    SetLiveStatus();
                }
            }
        }