Inheritance: System.Windows.Forms.UserControl
コード例 #1
0
ファイル: VideoForm.cs プロジェクト: friman/Digital-Signage
        public void UpdateSize()
        {
            if (videoMode == VideoMode.TV)
            {
                Trace.WriteLineIf(MainForm.trace.TraceInfo, "VideoForm_Resize(...)");
                if (Controls.Count > 0 && Controls[0] is VideoControl)
                {
                    VideoControl videoControl = Controls[0] as VideoControl;
                    if (videoControl.CurrentGraphBuilder != null)
                    {
                        Size   targetSize  = videoControl.CurrentGraphBuilder.CurrentVideoTargetRectangle.Size;
                        double ratioClient = (double)ClientSize.Height / (double)ClientSize.Width;
                        double ratioTarget = (double)targetSize.Height / (double)targetSize.Width;
                        Trace.WriteLineIf(MainForm.trace.TraceVerbose, string.Format(("\tClientSize {0}, TargetSize {1}"), ClientSize, targetSize));
                        Trace.WriteLineIf(MainForm.trace.TraceVerbose, string.Format(("\tratioClient {0}, ratioTarget {1}"), ratioClient, ratioTarget));
                        if (ratioClient != ratioTarget)
                        {
                            Trace.WriteLineIf(MainForm.trace.TraceVerbose, "\tratioClient != ratioTarget");

                            //Size newClientSize = ClientSize;

                            if (ratioClient > ratioTarget)
                            {
                                Height += (int)((double)ClientSize.Width * ratioTarget) - ClientSize.Height;
                            }
                            //newClientSize.Height = (int)((double)newClientSize.Width * ratioTarget);
                            else
                            {
                                Width += (int)((double)ClientSize.Height / ratioTarget) - ClientSize.Width;
                            }
                            //newClientSize.Width = (int)((double)newClientSize.Height / ratioTarget);
                            //if (ClientSize.Width < targetSize.Width)
                            //    newClientSize.Width = (int)((double)newClientSize.Height / ratioTarget);
                            //else
                            //    newClientSize.Height = (int)((double)newClientSize.Width * ratioTarget);

                            //ClientSize = newClientSize;
                            videoControl.Invalidate();
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: GraphBuilderBDA.cs プロジェクト: dgis/CodeTV
 public GraphBuilderBDA(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #3
0
ファイル: GraphBuilderBase.cs プロジェクト: dgis/CodeTV
        public GraphBuilderBase(VideoControl renderingControl)
        {
            this.hostingControl = renderingControl;

            //directDraw.Init();
        }
コード例 #4
0
ファイル: GraphBuilderWDM.cs プロジェクト: zhiqiang-li/CodeTV
 public GraphBuilderWDM(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #5
0
 public GraphBuilderPlayer(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #6
0
 public GraphBuilderBDATimeShifting(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #7
0
 public GraphBuilderBDAMosaic(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #8
0
ファイル: GraphBuilderPlayer.cs プロジェクト: dgis/CodeTV
 public GraphBuilderPlayer(VideoControl renderingControl)
     : base(renderingControl)
 {
 }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: dgis/CodeTV
        public GraphBuilderTV TuneChannel(Channel channel, bool needRebuild, GraphBuilderBase currentGraph, VideoControl hostingControl)
        {
            if (needRebuild && currentGraph != null)
            {
                ClearGraph();
                //OnGraphStop();
                //currentGraph.Dispose();
                //currentGraph = null;
            }

            GraphBuilderTV currentGraphTV = currentGraph as GraphBuilderTV;

            if (channel is ChannelDVB)
            {
                ChannelDVB channelDVB = channel as ChannelDVB;

                if (needRebuild)
                {
                    GraphBuilderBDA newGraph = null;
                    switch(this.graphBuilderType)
                    {
                        case GraphBuilderType.BDA:
                            newGraph = new GraphBuilderBDA(hostingControl);
                            break;
                        case GraphBuilderType.BDATimeShifting:
                            newGraph = new GraphBuilderBDATimeShifting(hostingControl);
                            break;
                        case GraphBuilderType.BDAMosaic:
                            newGraph = new GraphBuilderBDAMosaic(hostingControl);
                            break;
                    }
                    newGraph.GraphStarted += new EventHandler(newGraph_GraphStarted);
                    newGraph.GraphEnded += new EventHandler(newGraph_GraphEnded);
                    newGraph.PossibleChanged += new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged);
                    newGraph.Settings = Settings;
                    currentGraphTV = newGraph;

                    newGraph.ReferenceClock = channelDVB.ReferenceClock;

                    newGraph.AudioDecoderType = channelDVB.AudioDecoderType;
                    DsDevice device;
                    if (!string.IsNullOrEmpty(channelDVB.AudioDecoderDevice))
                    {
                        if (GraphBuilderBDA.AudioDecoderDevices.TryGetValue(channelDVB.AudioDecoderDevice, out device))
                            newGraph.AudioDecoderDevice = device;
                        else
                            throw new Exception(string.Format(Properties.Resources.AudioDeviceNotFound, channelDVB.AudioDecoderDevice));
                    }
                    if (channelDVB.VideoDecoderType == ChannelDVB.VideoType.MPEG2)
                    {
                        if (!string.IsNullOrEmpty(channelDVB.MPEG2DecoderDevice))
                        {
                            if (GraphBuilderBDA.MPEG2DecoderDevices.TryGetValue(channelDVB.MPEG2DecoderDevice, out device))
                                newGraph.Mpeg2DecoderDevice = device;
                            else
                                throw new Exception(string.Format(Properties.Resources.MPEG2DecoderDeviceNotFound, channelDVB.MPEG2DecoderDevice));
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(channelDVB.H264DecoderDevice))
                        {
                            if (GraphBuilderBDA.H264DecoderDevices.TryGetValue(channelDVB.H264DecoderDevice, out device))
                                newGraph.H264DecoderDevice = device;
                            else
                                throw new Exception(string.Format(Properties.Resources.H264DecoderDeviceNotFound, channelDVB.H264DecoderDevice));
                        }
                    }
                    if (!string.IsNullOrEmpty(channelDVB.AudioRendererDevice))
                    {
                        if (GraphBuilderBDA.AudioRendererDevices.TryGetValue(channelDVB.AudioRendererDevice, out device))
                            newGraph.AudioRendererDevice = device;
                        else
                            throw new Exception(string.Format(Properties.Resources.AudioRendererDeviceNotFound, channelDVB.AudioRendererDevice));
                    }
                    if (!string.IsNullOrEmpty(channelDVB.TunerDevice))
                    {
                        if (GraphBuilderBDA.TunerDevices.TryGetValue(channelDVB.TunerDevice, out device))
                            newGraph.TunerDevice = device;
                        else
                            throw new Exception(string.Format(Properties.Resources.TunerDeviceNotFound, channelDVB.TunerDevice));
                    }
                    if (!string.IsNullOrEmpty(channelDVB.CaptureDevice))
                    {
                        if (GraphBuilderBDA.CaptureDevices.TryGetValue(channelDVB.CaptureDevice, out device))
                            newGraph.CaptureDevice = device;
                        else
                            throw new Exception(string.Format(Properties.Resources.CaptureDeviceNotFound, channelDVB.CaptureDevice));
                    }

                    IDVBTuningSpace tuningSpace = (IDVBTuningSpace)new DVBTuningSpace();
                    if (channel is ChannelDVBT)
                    {
                        tuningSpace.put_UniqueName("DVBT TuningSpace");
                        tuningSpace.put_FriendlyName("DVBT TuningSpace");
                        tuningSpace.put_NetworkType(CLSID.DVBTNetworkProvider);
                        tuningSpace.put_SystemType(DVBSystemType.Terrestrial);
                    }
                    else if (channel is ChannelDVBC)
                    {
                        tuningSpace.put_UniqueName("DVBC TuningSpace");
                        tuningSpace.put_FriendlyName("DVBC TuningSpace");
                        tuningSpace.put_NetworkType(CLSID.DVBCNetworkProvider);
                        tuningSpace.put_SystemType(DVBSystemType.Cable);
                    }
                    else if (channel is ChannelDVBS)
                    {
                        tuningSpace.put_UniqueName("DVBS TuningSpace");
                        tuningSpace.put_FriendlyName("DVBS TuningSpace");
                        tuningSpace.put_NetworkType(CLSID.DVBSNetworkProvider);
                        tuningSpace.put_SystemType(DVBSystemType.Satellite);
                    }
                    newGraph.TuningSpace = tuningSpace as ITuningSpace;
                    newGraph.BuildGraph();
                }

                currentGraphTV.SubmitTuneRequest(channel);

                currentGraphTV.VideoZoomMode = channelDVB.VideoZoomMode;
                currentGraphTV.VideoKeepAspectRatio = channelDVB.VideoKeepAspectRatio;
                currentGraphTV.VideoOffset = channelDVB.VideoOffset;
                currentGraphTV.VideoZoom = channelDVB.VideoZoom;
                currentGraphTV.VideoAspectRatioFactor = channelDVB.VideoAspectRatioFactor;

                currentGraphTV.RunGraph();
                //currentGraph.VideoResizer();
                currentGraphTV.CurrentChannel = channel;
            }
            else if (channel is ChannelAnalogic)
            {
                ChannelAnalogic channelAnalogic = channel as ChannelAnalogic;

                if (needRebuild)
                {
                    GraphBuilderWDM newGraph = new GraphBuilderWDM(hostingControl);
                    newGraph.GraphStarted += new EventHandler(newGraph_GraphStarted);
                    newGraph.GraphEnded += new EventHandler(newGraph_GraphEnded);
                    newGraph.PossibleChanged += new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged);
                    newGraph.Settings = Settings;
                    currentGraphTV = newGraph;

                    DsDevice device;
                    if (GraphBuilderWDM.AudioRendererDevices.TryGetValue(channelAnalogic.AudioRendererDevice, out device))
                        newGraph.AudioRendererDevice = device;
                    if (GraphBuilderWDM.VideoInputDevices.TryGetValue(channelAnalogic.VideoCaptureDeviceName, out device))
                        newGraph.VideoCaptureDevice = device;
                    if (GraphBuilderWDM.AudioInputDevices.TryGetValue(channelAnalogic.AudioCaptureDeviceName, out device))
                        newGraph.AudioCaptureDevice = device;

                    newGraph.FormatOfCapture = channelAnalogic.FormatOfCapture;

                    newGraph.BuildGraph();
                }

                bool goodTuning = true;
                try
                {
                    currentGraphTV.SubmitTuneRequest(channel);
                }
                catch (COMException)
                {
                    goodTuning = false;
                }
                if (goodTuning)
                {
                    currentGraphTV.VideoZoomMode = channelAnalogic.VideoZoomMode;
                    currentGraphTV.VideoKeepAspectRatio = channelAnalogic.VideoKeepAspectRatio;
                    currentGraphTV.VideoOffset = channelAnalogic.VideoOffset;
                    currentGraphTV.VideoZoom = channelAnalogic.VideoZoom;
                    currentGraphTV.VideoAspectRatioFactor = channelAnalogic.VideoAspectRatioFactor;

                    currentGraphTV.RunGraph();
                    //currentGraph.VideoResizer();
                    currentGraphTV.CurrentChannel = channel;
                }
                else
                    currentGraphTV.CurrentChannel = null;
            }
            return currentGraphTV;
        }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: dgis/CodeTV
        // Contructor
        public MainForm()
        {
            mainForm = this;

            InitializeComponent();

            // Disabled the screensaver
            SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, ref this.screenSaverWasEnabled, 0);
            if (this.screenSaverWasEnabled)
                SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, false, IntPtr.Zero, 0);

            // Disabled power saving
            this.powerSavingPreviousState = SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);

            // Miscellaneous initialization
            ToolStripManager.LoadSettings(this, RegistryBaseKey);

            this.dockPanel.SuspendLayout();
            this.panelChannel = new PanelChannel();
            this.panelChannelProperties = new PanelChannelProperties();
            this.panelEPG = new PanelEPG();
            this.panelInfos = new PanelInfos();
            this.panelMediaTuning = new PanelMediaTuning();
            this.panelSettings = new PanelSettings();
            this.panelTimeLine = new PanelTimeLine();
            this.panelTimeLine.ShowHint = DockState.DockBottom;
            this.panelVideo = new PanelVideo();
            this.videoControl = new VideoControl();
            this.videoControl.BackColor = System.Drawing.Color.Black;
            this.videoControl.ContextMenuStrip = this.contextMenuStripPanelVideo;
            this.videoControl.Name = "videoControl";
            this.videoControl.Dock = DockStyle.Fill;
            this.videoControl.DoubleClick += new System.EventHandler(this.videoControl_DoubleClick);
            this.videoControl.Resize += new System.EventHandler(this.videoControl_Resize);
            this.videoControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.videoControl_KeyDown);
            this.videoControl.MouseWheel += new MouseEventHandler(videoControl_MouseWheel);
            this.panelVideo.Controls.Add(this.videoControl);

            this.deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            try
            {
                this.dockPanel.LoadFromXml(FileUtils.WorkingDirectory + "\\" + AssemblyName + ".Settings.UI.xml", deserializeDockContent);
            }
            catch (FileNotFoundException)
            {
                this.dockPanel.DockBottomPortion = 58;
                this.dockPanel.DockTopPortion = 58;
                this.panelChannelProperties.Show(this.dockPanel, DockState.DockRightAutoHide);
                this.panelSettings.Show(this.dockPanel, DockState.DockRightAutoHide);
                this.panelChannel.Show(this.dockPanel, DockState.DockLeft);
                this.panelMediaTuning.Show(this.panelChannel.Pane, DockAlignment.Bottom, 0.3);
                this.panelTimeLine.Show(this.dockPanel, DockState.DockBottom);
            }
            this.panelVideo.Show(this.dockPanel);

            this.videoForm.FormClosing += new FormClosingEventHandler(videoForm_FormClosing);

            // Load the default channels
            FileStream fileStream = null;
            try
            {
                fileStream = new FileStream(FileUtils.WorkingDirectory + "\\" + AssemblyName + ".Channels.xml", FileMode.Open);
                this.panelChannel.LoadChannels(fileStream);
            }
            catch
            {
                firstLaunch = true;
            }
            finally
            {
                if (fileStream != null)
                    fileStream.Close();
            }

            // Settings
            this.panelMediaTuning.trackBarVolume.Value = MainForm.Settings.Volume;
            this.panelMediaTuning.trackBarBalance.Value = MainForm.Settings.Balance;

            this.editToolStripMenuItem.DropDown = this.contextMenuStripPanelVideo;

            this.aspecRatio169toolStripMenuItem.Checked = Settings.UseVideo169Mode;
            ChangeSetting("UseVideo169Mode");
            this.toolStripButtonTimeShifting.Checked = Settings.TimeShiftingActivated;
            ChangeSetting("TimeShiftingActivated");
            ChangeSetting("UseWPF");
            ChangeSetting("VideoBackgroundColor");
            ChangeSetting("UseWinLIRC");

            this.dockPanel.ResumeLayout();

            beforeLaunchWindowState = WindowState;
            switch (Settings.StartVideoMode)
            {
                case VideoMode.TV:
                    ExecuteCommand(CommandName.VideoModeTV);
                    //WindowState = FormWindowState.Minimized;
                    break;
                case VideoMode.Fullscreen:
                    ExecuteCommand(CommandName.VideoModeFullscreen);
                    //WindowState = FormWindowState.Minimized;
                    break;
            }
        }
コード例 #11
0
 public GraphBuilderBDATimeShifting(VideoControl renderingControl)
     : base(renderingControl)
 {
 }