Exemplo n.º 1
0
        public bool UpdateTemplate(int channel, int layer, string xmlStr, int flags)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                CGLayer cglayer = null;

                if (flags > 0)
                {
                    cglayer = layers.Where(o => o.Layer == layerMain).FirstOrDefault();
                }
                else
                {
                    cglayer = layers.Where(o => o.Layer == layerLoad).FirstOrDefault();
                }

                if (cglayer != null)
                {
                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            if (flags > 0)
                            {
                                components.AddComponent("Append", "1");
                            }
                            components.AddComponent("text", xmlStr);
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(cglayer.Layer, 1, toStandarXml(xmlStr));
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                }
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool UpdateField(int channel, int layer, string fieldId, string value, int flags)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                CGLayer cglayer = null;

                if (flags > 0)
                {
                    cglayer = layers.Where(o => o.Layer == layerMain).FirstOrDefault();
                }
                else
                {
                    cglayer = layers.Where(o => o.Layer == layerLoad).FirstOrDefault();
                }

                if (cglayer != null)
                {
                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            if (flags > 0)
                            {
                                components.AddComponent("Append", "1");
                            }
                            components.AddComponent(fieldId, value);
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(cglayer.Layer, 1, components);
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            if (fieldId.ToLower() == "videopath")
                            {
                                casparLoadBGOK = false;
                                caspar_.Channels[channel].LoadBG(cglayer.Layer, value, false);
                                for (int time = 0; !casparLoadBGOK && caspar_.IsConnected && time < timeOut_; time += 100)
                                {
                                    Thread.Sleep(100);
                                }
                                if (casparLoadBGOK)
                                {
                                    return(true);
                                }
                            }
                            else
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                }

                return(false);
            }
        }