void PlayerService_SetTunerDevice(string displayName, TunerDevice dev)
        {
            FormJanelaFinal window = playerWindows[displayName];

            if (window.Controls.OfType <DigitalTVScreen>().Count() == 1)
            {
                DigitalTVScreen temp = window.Controls.OfType <DigitalTVScreen>().ToList()[0];

                temp.Devices.TunerDevice = DigitalTVScreen.DeviceStuff.TunerDevices.Values.Single(x => x.DevicePath == dev.DevicePath);
            }
        }
        public Channel GetChannel()
        {
            DigitalTVScreen temp = null;

            foreach (var control in this.Controls)
            {
                if (control is DigitalTVScreen)
                {
                    temp = control as DigitalTVScreen;
                }
            }
            return(temp.Channels.CurrentChannel);
        }
        public void SetTunerDevice(TunerDevice dev)
        {
            DigitalTVScreen temp = null;

            if (this.Controls.OfType <DigitalTVScreen>().Count() > 0)
            {
                temp = this.Controls.OfType <DigitalTVScreen>().ToList()[0];
            }
            else
            {
                return;
            }

            temp.Devices.TunerDevice = DigitalTVScreen.DeviceStuff.TunerDevices.Single(x => x.Value.DevicePath == dev.DevicePath).Value;
        }
        public void SetChannel(Channel ch)
        {
            DigitalTVScreen temp = null;

            if (this.Controls.OfType <DigitalTVScreen>().Count() > 0)
            {
                temp = this.Controls.OfType <DigitalTVScreen>().ToList()[0];
            }
            else
            {
                return;
            }

            temp.Channels.TuneChannel(ch);
        }
        public TunerDevice GetTunerDevice()
        {
            DigitalTVScreen temp = null;

            if (this.Controls.OfType <DigitalTVScreen>().Count() > 0)
            {
                temp = this.Controls.OfType <DigitalTVScreen>().ToList()[0];
            }
            else
            {
                return(null);
            }

            return(new TunerDevice()
            {
                Name = temp.Devices.TunerDevice.Name, DevicePath = temp.Devices.TunerDevice.DevicePath
            });
        }
        public void AddItemFromConfiguration(ItemConfiguration config)
        {
            try
            {
                if (config is DateTimeComposer)//MUDAR QUANDO FIZER O CONFIG CERTO
                {
                }
                else if (config is MarkeeConfiguration)
                {
                    MarkeeConfiguration temp = config as MarkeeConfiguration;

                    float newFontSize = this.ScaledFontSize(temp.Resolution.Height, temp.FinalResolution.Height, temp.Font.Size);

                    Font scaledFont = new Font(temp.Font.Name, newFontSize, temp.Font.Style, temp.Font.Unit, temp.Font.GdiCharSet, temp.Font.GdiVerticalFont);

                    Markee markee = new Markee(ComponentTargetSite.Player)
                    {
                        Location         = temp.FinalLocation,
                        Size             = temp.FinalSize,
                        TextList         = temp.Text,
                        Speed            = temp.Speed,
                        MarkeeFont       = scaledFont,
                        BackColor        = temp.BackColor,
                        TextColor        = temp.TextColor,
                        ContextMenuStrip = contextMSFooter
                    };

                    this.Controls.Add(markee);

                    markee.Run();
                }
                else if (config is ImageComposer)//MUDAR
                {
                }
                else if (config is PriceListComposer)//MUDAR
                {
                }
                else if (config is SlideShowComposer)//MUDAR
                {
                }
                else if (config is TVConfiguration)
                {
                    var temp = config as TVConfiguration;

                    #region using DigitalTVScreen

                    /*
                     * DigitalTVScreen tvDisplay = new DigitalTVScreen() { Location = temp.FinalLocation, Size = temp.FinalSize };
                     * tvDisplay.ChannelListChanged += tvDisplay_ChannelListChanged;
                     * tvDisplay.Frequencia = 754000;
                     * tvDisplay.Start();
                     * tvDisplay.Tune();
                     *
                     * tvDisplay.ContextMenuStrip = contextMSTV;
                     *
                     * this.Controls.Add(tvDisplay);
                     */
                    #endregion

                    DigitalTVScreen tvScreen = new DigitalTVScreen()
                    {
                        Location = temp.FinalLocation,
                        Size     = temp.FinalSize
                    };

                    tvScreen.Channels.Frequency = temp.Frequency;
                    tvScreen.Channels.ForceRebuildOnChannelTune = true;

                    DirectShowLib.DsDevice dev;
                    if (DigitalTVScreen.DeviceStuff.TunerDevices.TryGetValue(temp.TunerDevicePath, out dev))
                    {
                        tvScreen.Devices.TunerDevice = dev;
                    }

                    tvScreen.ContextMenuStrip = contextMSTV;

                    this.Controls.Add(tvScreen);

                    try
                    {
                        tvScreen.Channels.LoadFromXML();
                    }
                    catch (Exception)
                    {
                        tvScreen.Channels.RefreshChannels(); //Só funciona em Portugal. Compor o ecra de opçoes no composer
                        tvScreen.Channels.SaveToXML();
                    }

                    foreach (var ch in tvScreen.Channels.ChannelList)
                    {
                        (contextMSTV.Items["canalTVTSMItem"] as ToolStripMenuItem).DropDownItems.Add(ch.Name, null, (object sender, EventArgs e) => { tvScreen.Channels.TuneChannel(ch); });
                    }

                    if (tvScreen.Channels.ChannelList.Count > 0)
                    {
                        tvScreen.Channels.TuneChannel(tvScreen.Channels.ChannelList[0]);
                    }

                    //tvScreen.Start();
                }
                else if (config is VideoComposer)//MUDAR
                {
                }
                else if (config is WaitListComposer)//MUDAR
                {
                }
                else if (config is WeatherComposer)//MUDAR
                {
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.Message);
#endif
            }
        }