private void showChatMessages() { try { if (this.caspar_.IsConnected) { // Clear old data cgData = this.getChatComment(); if (cgData == null) { s_sameMessageCounter++; // Check if to clear the chat. if (s_sameMessageCounter > 3) { StopTickerExternal(); } return; } s_sameMessageCounter = 0; System.Diagnostics.Debug.WriteLine("Add"); System.Diagnostics.Debug.WriteLine(cgData.ToXml()); this.caspar_.Channels[0].CG.Add(Properties.Settings.Default.GraphicsLayerExternalTicker, Properties.Settings.Default.TemplateNameFacebookBottom, true, cgData); } else { MessageBox.Show("There is no Caspar connected.", "Caspar", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOnVideo_Click(object sender, EventArgs e) { if (cboVideoLayer.SelectedIndex < 0) { HDMessageBox.Show("Please select one layer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtVideo.Text == "") { HDMessageBox.Show("Please select file to play", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { CasparCGDataCollection cgData = new CasparCGDataCollection(); List <Object.Property> runtimeProperties = new List <Object.Property>(); runtimeProperties.Add(new Object.Property() { Name = "VideoPath", Value = txtVideo.Text }); runtimeProperties.Add(new Object.Property() { Name = "Loops", Value = ckVideoLoop.Checked ? "true" : "false" }); OnTemplate(int.Parse(cboVideoLayer.Text), "PlayVideo", 0, null, runtimeProperties); } }
protected override void SetData(CasparCGDataCollection cgData) { if (!string.IsNullOrEmpty(m_refTime)) { cgData.SetData("ref_time", m_refTime); } cgData.SetData("show_tenth", m_showTenth ? "true" : "false"); }
private CasparCGDataCollection _getContainerData(ITemplated template) { var data = new CasparCGDataCollection(); foreach (var field in template.Fields) { data.DataPairs.Add(new CGDataPair(field.Key, new CGTextFieldData(field.Value))); } return(data); }
private void TeamC_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Punten") { CasparCGDataCollection _dataCollection = new CasparCGDataCollection(); _dataCollection.SetData("score3", _control.TeamC.Punten.ToString()); _caspar.Channels[(int)Consumer.A].CG.Update(11, _dataCollection); _caspar.Channels[(int)Consumer.B].CG.Update(11, _dataCollection); } }
protected void NeedToRefreshGraphics() { if (m_casparDevice.IsConnected && m_casparDevice.Channels.Count > 0 && m_isPlaying) { CasparCGDataCollection cgData = new CasparCGDataCollection(); SetData(cgData); m_casparDevice.Channels[Properties.Settings.Default.CasparChannel].CG .Update(GraphicsLayer, cgData); } }
private void _engine_EngineOperation(object sender, EngineOperationEventArgs e) { Debug.WriteLine($"Plugin notification received for {e.Event}"); if (e.Event == null) { return; } if (MediaCategory != null && e.Event.Media?.MediaCategory != MediaCategory) { return; } try { if (e.Operation == TEngineOperation.Play) { var data = new CasparCGDataCollection(); foreach (var dataItem in Data) { switch (dataItem.Value) { case DataValueKind.CurrentItemName: data.SetData(dataItem.Name, e.Event.EventName); break; case DataValueKind.CurrentItemDurationInSeconds: data.SetData(dataItem.Name, e.Event.Duration.TotalSeconds.ToString(CultureInfo.InvariantCulture)); break; case DataValueKind.NextItemName: data.SetData(dataItem.Name, e.Event.GetSuccessor()?.EventName ?? string.Empty); break; case DataValueKind.NextShowName: data.SetData(dataItem.Name, FindNextShowName(e.Event)?.EventName ?? string.Empty); break; case DataValueKind.NextNextItemName: data.SetData(dataItem.Name, e.Event.GetSuccessor()?.GetSuccessor()?.EventName ?? string.Empty); break; case DataValueKind.NextNextShowName: data.SetData(dataItem.Name, FindNextNextShowName(e.Event)?.EventName ?? string.Empty); break; } } Engine.Execute($"{CommandOnPlay} {data.ToAMCPEscapedXml()}"); } } catch (Exception exception) { Logger.Error(exception); } }
private void btnReset_Click(object sender, EventArgs e) { CasparCGDataCollection _dataCollection = new CasparCGDataCollection(); _dataCollection.SetData("reset", "1"); _dataCollection.SetData("woord1", _antwoorden[_huidigeVraag][0]); _dataCollection.SetData("woord2", _antwoorden[_huidigeVraag][1]); _dataCollection.SetData("woord3", _antwoorden[_huidigeVraag][2]); _dataCollection.SetData("woord4", _antwoorden[_huidigeVraag][3]); _dataCollection.SetData("woord5", _antwoorden[_huidigeVraag][4]); this.Caspar.Channels[(int)Consumer.A].CG.Update(11, _dataCollection); }
private void LoadGraphic() { // create datacollection CasparCGDataCollection DataCollection = new CasparCGDataCollection(); DataCollection.SetData("Lijn1", txtLijn1.Text); DataCollection.SetData("Lijn2", txtLijn2.Text); DataCollection.SetData("Color", $"0x{cdColorPicker.Color.R.ToString("X2")}{cdColorPicker.Color.G.ToString("X2")}{cdColorPicker.Color.B.ToString("X2")}"); // load template with datacollection _device.Channels[0].CG.Add(0, "kdg/lowerthird", DataCollection); _device.Channels[0].CG.Play(0); }
private void nudTimeTeamB_ValueChanged(object sender, EventArgs e) { // wanneer de timer niet loopt en er worden punten aangepast -> sync met timer object if (!this.TimerTeamB.IsRunning) { this.TimerTeamB.Sync(TimeSpan.FromSeconds((int)nudTimeTeamB.Value)); } // stuur tijd van team B naar caspar CasparCGDataCollection _dataCollection = new CasparCGDataCollection(); _dataCollection.SetData("tijd2", this.nudTimeTeamB.Value.ToString()); this.Caspar.Channels[(int)Consumer.A].CG.Update(11, _dataCollection); }
public void Play() { if (m_casparDevice.IsConnected && m_casparDevice.Channels.Count > 0) { CasparCGDataCollection cgData = new CasparCGDataCollection(); SetData(cgData); string templateName = m_templateFolder + "/" + TemplateName; m_casparDevice.Channels[Properties.Settings.Default.CasparChannel].CG .Add(GraphicsLayer, templateName, true, cgData); SetIsPlaying(true); } }
private void btnAntwoord_Click(object sender, EventArgs e) { // tel 20 seconden af bij het andere team if (this.rbTeamA.Checked) { // check of we 10 punten kunnen aftrekken if ((this.nudTimeTeamB.Value - 10) < 0) { this.nudTimeTeamB.Value = 0; } else { this.nudTimeTeamB.Value -= 10; } } else { // check of we 10 punten kunnen aftrekken if ((this.nudTimeTeamA.Value - 10) < 0) { this.nudTimeTeamA.Value = 0; } else { this.nudTimeTeamA.Value -= 10; } } // check of er 1 van de 2 tijden op 0 staat -> stop de aftelklokken if (this.nudTimeTeamA.Value == 0 || this.nudTimeTeamB.Value == 0) { this.TimerTeamA.Stop(); this.TimerTeamB.Stop(); } // cast object naar button om te weten welke button heeft gedrukt -> nodig om te weten welk antwoord er werd gedrukt Button _button = sender as Button; int buttonId = Convert.ToInt32(_button.Tag); string _antwoord = _antwoorden[_huidigeVraag][buttonId]; // stuur geselecteerde antwoord door naar caspar CasparCGDataCollection _dataCollection = new CasparCGDataCollection(); _dataCollection.SetData("woord" + (buttonId + 1).ToString() + "goed", _antwoord); this.Caspar.Channels[(int)Consumer.A].CG.Update(11, _dataCollection); }
private static void CgUpdate() { var channel = casparCGServer.Channels.FirstOrDefault(); if (channel == null) { Console.WriteLine("No channel found"); return; } Console.WriteLine("Before update do a cg add"); Console.WriteLine("Please provide text to update:"); var data = new CasparCGDataCollection(); data.Add("f0", Console.ReadLine()); channel.CG.Update(10, 1, data); EnterToContinue(); }
private void button1_Click(object sender, EventArgs e) { if (casparDevice.IsConnected) { if (cb_ClockOnClears.Checked) { ClearChannel((int)tb_channel.Value); } CasparCGDataCollection CGdata = new CasparCGDataCollection(); string time = DateTime.Now.ToString("HH:mm:ss"); CGdata.SetData("f0", time); casparDevice.Channels[(int)tb_channel.Value - 1].CG.Add(0, 0, "ORASZILVESZTER", true, CGdata); clockIsOn = true; lbl_help.Text = "Kész is vagy!"; } }
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { string time = DateTime.Now.ToString("HH:mm:ss"); lbl_Clock.Text = time; //23:58-kor kirakja az orat magatol, ha meg nincs fenn /*if (time == "23:58:00" && !clockIsOn) * { * //ClearChannel(1); * clockIsOn = true; * //casparDevice.Channels[(int)tb_channel.Value - 1].LoadBG(9, "ADAS_PLAYOUT/01_DISZLET", false, TransitionType.MIX, 5); * casparDevice.Channels[(int)tb_channel.Value - 1].CG.Add(10, 0, "SZILVESZTER/ORASZILVESZTER", true); * * }*/ if (casparDevice.IsConnected && (clockIsOn)) { CasparCGDataCollection CGdata = new CasparCGDataCollection(); CGdata.SetData("f0", time); casparDevice.Channels[(int)tb_channel.Value - 1].CG.Update(10, 0, CGdata); if (time == /*"00:00:05"*/ dtp_SpeechStartTime.Value.ToString("HH:mm:ss") && speechIsLocked) //ha elerkezik az ido, ami meg van adva, akkor elinditja az Elnoki beszedet { dtp_SpeechStartTime.Enabled = false; lb_MediaFiles.Enabled = false; casparDevice.Channels[(int)tb_channel.Value - 1].CG.Remove(10, 0); clockIsOn = false; System.Diagnostics.Debug.WriteLine((string)lb_MediaFiles.SelectedItem); casparDevice.Channels[(int)tb_channel.Value - 1].LoadBG(10, /*"ADAS_PLAYOUT/HIMNUSZ_BESZED"*/ (string)lb_MediaFiles.SelectedItem, false, TransitionType.MIX, 5); casparDevice.Channels[(int)tb_channel.Value - 1].Play(10); } } l_ClockOn.Visible = clockIsOn; }
protected override void SetData(CasparCGDataCollection cgData) { cgData.SetData("title_class", m_className); //UpdateCurrentResultList(); var list = m_currentResultList.Skip((m_currentResultListPage - 1) * NumResultsPerPage).Take(NumResultsPerPage).ToList(); cgData.SetData("title_class_description", GetDescription()); int lastTime = -1; int pos = (m_currentResultListPage - 1) * NumResultsPerPage + 1; if (m_currentResultList.Length > 0) { int winnerTime = m_currentResultList[0].Time; for (int i = 0; i < list.Count; i++) { string sPos = list[i].Time != lastTime?pos.ToString() : "="; pos++; lastTime = list[i].Time; cgData.SetData("res_name_" + i, list[i].Runner.Name); cgData.SetData("res_club_" + i, list[i].Runner.Club); cgData.SetData("res_place_" + i, list[i].Status == 0 ? sPos : "-"); cgData.SetData("res_time_" + i, Helpers.FormatTime(list[i].Time, list[i].Status, false, true, false)); if (list[i].Status == 0) { cgData.SetData("res_timeplus_" + i, "+" + Helpers.FormatTime(list[i].Time - winnerTime, list[i].Status, false, true, false)); } else { cgData.SetData("res_timeplus_" + i, "-"); } } } }
private CasparCGDataCollection getChatComment() { string[] message = this.getLastChatMessage(); if (message == null) { return(null); } // Check if it's a new message. if (message.SequenceEqual(s_chatMessage)) { return(null); } s_chatMessage = (string[])message.Clone(); CasparCGDataCollection cgCollection = new CasparCGDataCollection(); cgCollection.SetData("f0", message[0]); cgCollection.SetData("f1", message[1]); return(cgCollection); }
private void LoadAnswers(int index) { // laadt antwoorden uit file this.btnAntwoord1.Text = _antwoorden[index][0]; this.btnAntwoord2.Text = _antwoorden[index][1]; this.btnAntwoord3.Text = _antwoorden[index][2]; this.btnAntwoord4.Text = _antwoorden[index][3]; this.btnAntwoord5.Text = _antwoorden[index][4]; // stuur antwoorden naar caspar CasparCGDataCollection _dataCollection = new CasparCGDataCollection(); _dataCollection.SetData("tijd1", _teamA.Punten.ToString()); _dataCollection.SetData("tijd2", _teamB.Punten.ToString()); _dataCollection.SetData("woord1", _antwoorden[index][0]); _dataCollection.SetData("woord2", _antwoorden[index][1]); _dataCollection.SetData("woord3", _antwoorden[index][2]); _dataCollection.SetData("woord4", _antwoorden[index][3]); _dataCollection.SetData("woord5", _antwoorden[index][4]); _dataCollection.SetData("resetLayer", "1"); this.Caspar.Channels[(int)Consumer.A].CG.Update(11, _dataCollection); }
public MainForm() { InitializeComponent(); cDevice = new CasparDevice(); cData = new CasparCGDataCollection(); playoutList = new Queue <SMSMessage>(); cache = new List <SMSMessage>(); screenText = new StringBuilder(); playoutdataGridView.ColumnCount = 4; playoutdataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; playoutdataGridView.ColumnHeadersVisible = true; playoutdataGridView.Columns[0].Name = "Time"; playoutdataGridView.Columns[1].Name = "Sender"; playoutdataGridView.Columns[2].Name = "Nickname"; playoutdataGridView.Columns[3].Name = "Message"; m_conn = new MySqlConnection(); m_command = new MySqlCommand(); string mConnectionString = "server=localhost;user=root;database=sms2tv;port=3306;password='';"; m_conn.ConnectionString = mConnectionString; m_command.Connection = m_conn; mds = new DataSet(); }
protected override void SetData(CasparCGDataCollection cgData) { m_nextForcedUpdate = DateTime.MaxValue; cgData.SetData("title", "Förvarnade"); int follIdx = 0; //Finished within 10sek var curRealTime = DateTime.Now.Hour * 360000 + DateTime.Now.Minute * 6000 + DateTime.Now.Second * 100; bool hadRunnerFinishedWithin10sek = false; foreach (var prewarned in m_emmaMysqlClient.GetAllRunners() .Where(x => x.Time > 0 && (x.StartTime + x.Time) > curRealTime - 10 * 100 && x.Status == 0) .OrderBy(x => x.StartTime + x.Time)) { int startTime = prewarned.StartTime; if ((curRealTime - 10 * 100) > startTime + prewarned.Time) { continue; } var betterResInclass = m_emmaMysqlClient.GetRunnersInClass(prewarned.Class) .Where(x => x.Time > 0 && x.Time < prewarned.Time && x.Status == 0).OrderBy(x => x.Time).ToArray(); var leader = betterResInclass.Any() ? betterResInclass[0] : null; cgData.SetData("res_name_" + follIdx, prewarned.Name); cgData.SetData("res_club_" + follIdx, prewarned.Club); cgData.SetData("res_class_" + follIdx, prewarned.Class); var pTime = prewarned.Time; cgData.SetData("res_place_" + follIdx, betterResInclass.Count() + 1 + ""); cgData.SetData("res_time_" + follIdx, Helpers.FormatTime(prewarned.Time, prewarned.Status, false, true, true)); cgData.SetData("res_timeplus_" + follIdx, "+" + Helpers.FormatTime(prewarned.Time - (leader != null ? leader.Time : prewarned.Time), prewarned.Status, false, true, true)); follIdx++; hadRunnerFinishedWithin10sek = true; if (follIdx > 15) { break; } } if (hadRunnerFinishedWithin10sek) { m_nextForcedUpdate = DateTime.Now.AddSeconds(11); } double minTimeUntilUpdatePlaceRequired = double.MaxValue; foreach (var prewarned in m_emmaMysqlClient.GetAllRunners() .Where(x => x.Time <= 0 && (x.Status == 0 || x.Status == 9 || x.Status == 10) && x.SplitTimes != null && x.SplitTimes.Any(y => Array.IndexOf(m_prewarningControls, y.Control) >= 0)) .OrderBy(x => x.StartTime + x.SplitTimes.Max(m => m.Time))) { var classResults = m_emmaMysqlClient.GetRunnersInClass(prewarned.Class).Where(x => x.Time > 0 && x.Status == 0) .OrderBy(x => x.Time).ToArray(); Runner leader = classResults.Any() ? classResults[0] : null; int startTime = prewarned.StartTime; var curTime = DateTime.Now.Hour * 360000 + DateTime.Now.Minute * 6000 + DateTime.Now.Second * 100 - startTime; cgData.SetData("res_name_" + follIdx, prewarned.Name); cgData.SetData("res_class_" + follIdx, prewarned.Class); cgData.SetData("res_club_" + follIdx, prewarned.Club); cgData.SetData("res_tref_" + follIdx, (curTime / 100).ToString()); if (classResults.Any()) { var nextRunner = classResults.Where(x => x.Time > curTime).OrderBy(x => x.Time).FirstOrDefault(); if (nextRunner != null) { var timeUntilPlaceChanges = (nextRunner.Time - curTime) / 100; if (timeUntilPlaceChanges < minTimeUntilUpdatePlaceRequired) { minTimeUntilUpdatePlaceRequired = timeUntilPlaceChanges; } } } if (leader != null) { string place = (prewarned.Status != 9 && prewarned.Status != 10 && prewarned.Status != 0 && Helpers.ContainsRunnerStatus(prewarned.Status)) ? Helpers.RunnerStatus(prewarned.Status) : (classResults.Count(x => x.Time <= curTime) + 1).ToString(); cgData.SetData("res_tplusref_" + follIdx, ((curTime - leader.Time) / 100).ToString()); cgData.SetData("res_place_" + follIdx, "(" + place + ")"); } else { string place = (prewarned.Status != 9 && prewarned.Status != 10 && prewarned.Status != 0 && Helpers.ContainsRunnerStatus(prewarned.Status)) ? Helpers.RunnerStatus(prewarned.Status) : "1"; cgData.SetData("res_tplusref_" + follIdx, "-999999"); cgData.SetData("res_place_" + follIdx, "(" + place + ")"); } follIdx++; if (follIdx > 16) { break; } } if (minTimeUntilUpdatePlaceRequired < double.MaxValue) { if (DateTime.Now.AddSeconds(minTimeUntilUpdatePlaceRequired) < m_nextForcedUpdate) { m_nextForcedUpdate = DateTime.Now.AddSeconds(minTimeUntilUpdatePlaceRequired); } } }
protected override void SetData(CasparCGDataCollection cgData) { cgData.SetData("title_class", m_className + " - " + m_resultPositionName); UpdateCurrentResultList(); var list = m_currentResultList; int lastTime = -1; int pos = 1; int selItemEstimated_Place = -1; if (m_followRunner != null) { cgData.SetData("follow_name", m_followRunner.Name); cgData.SetData("follow_club", m_followRunner.Club); var runnerInResults = m_currentResultList.FirstOrDefault(x => x.Runner.ID == m_followRunner.ID); if (runnerInResults == null) { int h = (int)(m_followRunner.StartTime / (100.0 * 60 * 60)); int m = (int)((m_followRunner.StartTime - h * 60 * 60 * 100) / (100.0 * 60)); int s = (int)((m_followRunner.StartTime - h * 60 * 60 * 100 - m * 60 * 100) / (100.0)); var now = DateTime.Now; var startDate = new DateTime(now.Year, now.Month, now.Day, h, m, s); var runnerCurrentTime = (DateTime.Now - startDate).TotalSeconds * 100; var runnerCurrentPlace = m_currentResultList.Count(x => x.Status == 0 && x.Time > 0 && x.Time < runnerCurrentTime) + 1; selItemEstimated_Place = runnerCurrentPlace; cgData.SetData("follow_place", "(" + runnerCurrentPlace + ")"); cgData.SetData("follow_starttime", h + "," + m + "," + s); if (m_currentResultList.Length > 0) { cgData.SetData("follow_tref", "" + (int)((runnerCurrentTime - m_currentResultList[0].Time) / 100)); } else { cgData.SetData("follow_tref", "" + (int)((runnerCurrentTime) / 100)); } var nextResultItem = m_currentResultList.FirstOrDefault(x => x.Time > runnerCurrentTime); if (nextResultItem != null) { m_nextForcedUpdate = DateTime.Now.AddSeconds((nextResultItem.Time - runnerCurrentTime) / 100); } else { m_nextForcedUpdate = DateTime.MaxValue; } } else { int place = m_currentResultList.Count(x => x.Status == 0 && x.Time > 0 && x.Time < runnerInResults.Time) + 1; selItemEstimated_Place = place; cgData.SetData("follow_place", place.ToString()); if (place == 1) { cgData.SetData("follow_time", Helpers.FormatTime(runnerInResults.Time, 0, false, true, true)); } else { cgData.SetData("follow_time", "+" + Helpers.FormatTime(runnerInResults.Time - m_currentResultList[0].Time, 0, false, true, true)); } } } if (m_currentResultList.Length > 0) { int leaderTime = m_currentResultList[0].Time; int p = 0; for (int i = 0; i < list.Count(); i++) { string sPos = list[i].Time != lastTime?pos.ToString() : "="; pos++; lastTime = list[i].Time; cgData.SetData("res_name_" + p, list[i].Runner.Name); cgData.SetData("res_club_" + p, list[i].Runner.Club); cgData.SetData("res_place_" + p, list[i].Status == 0 ? sPos : "-"); var time = i == 0 ? list[i].Time : list[i].Time - leaderTime; cgData.SetData("res_time_" + p, (i > 0 ? "+" : "") + Helpers.FormatTime(time, list[i].Status, false, true, false)); if (i == 0 && selItemEstimated_Place > 3 && m_currentResultList.Length > 5) { i = Math.Min(selItemEstimated_Place - 3, list.Length - 5); pos = i + 2; } p++; if (i == 0 && m_followTail && list.Count() > 5) { i = list.Count() - 5; pos = i + 2; } if (p > 4) { break; } } if (m_followTail) { cgData.SetData("tail_plus_time", ((int)(DateTime.Now.TimeOfDay.TotalSeconds - (m_currentResultList[0].Runner.StartTime + m_currentResultList[0].Time) / 100)) + ""); } } else { if (m_followTail) { cgData.SetData("tail_plus_time", ((int)(DateTime.Now.TimeOfDay.TotalSeconds - (10 * 3600))) + ""); } } }
public bool Play(Event aEvent) { var channel = _casparChannel; if (CheckConnected(channel)) { var eventType = aEvent.EventType; if (eventType == TEventType.Live || eventType == TEventType.Movie || eventType == TEventType.StillImage) { Event visible; if (!(_visible.TryGetValue(aEvent.Layer, out visible) && visible == aEvent)) { Event loaded; if (!(_loadedNext.TryGetValue(aEvent.Layer, out loaded) && loaded == aEvent)) { var item = _getItem(aEvent); if (item != null) { channel.LoadBG(item); } } } channel.Play((int)aEvent.Layer); _visible[aEvent.Layer] = aEvent; Event removed; _loadedNext.TryRemove(aEvent.Layer, out removed); Debug.WriteLine(aEvent, $"CasparPlay Layer {aEvent.Layer}"); return(true); } if (eventType == TEventType.Animation) { var eTemplated = aEvent as ITemplated; if (eTemplated != null) { switch (eTemplated.Method) { case TemplateMethod.Add: var media = (aEvent.Engine.PlayoutChannelPRI == this) ? aEvent.ServerMediaPRI : aEvent.ServerMediaSEC; if (media != null && media.FileExists()) { CasparCGDataCollection f = new CasparCGDataCollection(); foreach (var field in eTemplated.Fields) { f.SetData(field.Key, field.Value); } channel.CG.Add((int)aEvent.Layer, eTemplated.TemplateLayer, Path.GetFileNameWithoutExtension(media.FileName).ToUpperInvariant(), true, f); } break; case TemplateMethod.Clear: channel.CG.Clear((int)aEvent.Layer); break; case TemplateMethod.Next: channel.CG.Next((int)aEvent.Layer, eTemplated.TemplateLayer); break; case TemplateMethod.Play: channel.CG.Play((int)aEvent.Layer, eTemplated.TemplateLayer); break; case TemplateMethod.Remove: channel.CG.Remove((int)aEvent.Layer, eTemplated.TemplateLayer); break; case TemplateMethod.Stop: channel.CG.Stop((int)aEvent.Layer, eTemplated.TemplateLayer); break; case TemplateMethod.Update: CasparCGDataCollection uf = new CasparCGDataCollection(); foreach (var field in eTemplated.Fields) { uf.SetData(field.Key, field.Value); } channel.CG.Update((int)aEvent.Layer, eTemplated.TemplateLayer, uf.ToAMCPEscapedXml()); break; default: Debug.WriteLine("Method CG {0} not implemented", eTemplated.Method, null); break; } } } if (eventType == TEventType.CommandScript) { CommandScriptEvent csi = aEvent as CommandScriptEvent; string command = csi?.Command; return(Execute(command)); } } return(false); }
protected override void SetData(CasparCGDataCollection cgData) { cgData.SetData("label_name", m_name); cgData.SetData("label_title", m_titleClub); }
protected abstract void SetData(CasparCGDataCollection cgData);
private void OnTemplate(int layer, string templateFileName, int fadeUpDuration = 3, List <Object.Property> DesignProperties = null, List <Object.Property> RuntimeProperties = null) { string templateFile = templateFileName; if (templateFileName != "PlayVideo") { templateFile = "HDTemplates\\" + templateFileName; } #region Parameter if ((DesignProperties != null && DesignProperties.Count > 0) || (RuntimeProperties != null && RuntimeProperties.Count > 0)) { CasparCGDataCollection cgData = new CasparCGDataCollection(); cgData.Clear(); if (DesignProperties != null) { foreach (var property in DesignProperties) { cgData.SetData(property.Name, property.Value); } } if (RuntimeProperties != null) { foreach (var property in RuntimeProperties) { cgData.SetData(property.Name, property.Value); } } cgParameter = cgData.ToAMCPEscapedXml(); } #endregion if (!cgServer.Connect()) { HDMessageBox.Show("Not connect to cg server!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!cgServer.LoadCG(templateFile, layer)) { HDMessageBox.Show("Can't load cg template", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cgParameter != "") { if (!cgServer.SetParameters(layer, cgParameter)) { HDMessageBox.Show("Can't send parameter to cg server", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } bool upOK = false; var tempInfoView = gvFootballPlaylist.GetFocusedRow() as View.tempInfo; try { //Đảm bảo data được update mới nhất var lstData = Utils.GetObject <List <Object.tempUpdating> >(_updateDataXml); dicTemplateData.Clear(); foreach (var data in lstData) { dicTemplateData.Add(data.Name, data.Data); } if (dicTemplateData.ContainsKey(templateFile)) { if (templateFile == "HDTemplates\\ThongBao_ThongBaoChung.ft") { upOK = cgServer.FadeUp(layer, fadeUpDuration, dicTemplateData[templateFile].Replace("\\n", "\n")); } else { upOK = cgServer.FadeUp(layer, fadeUpDuration, dicTemplateData[templateFile].Replace("\\", "\\\\")); } } else { upOK = cgServer.CutUp(layer); } } catch (Exception ex) { HDMessageBox.Show("Không thể lấy thông tin update! - " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } System.Threading.Timer timer = null; if (tempInfoView.tempObj.Duration > 0) { timer = new System.Threading.Timer((obj) => { OffTemplate(tempInfoView.tempObj.Layer); timer.Dispose(); }, null, tempInfoView.tempObj.Delay + tempInfoView.tempObj.Duration, Timeout.Infinite); } } }