Ejemplo n.º 1
0
        ////////////
        /// Test Get/Put Caption
        private void TestCaption()
        {
            int    hr;
            string s;

            hr = m_ivw.put_Caption("Foo Bar");
            Marshal.ThrowExceptionForHR(hr);

            hr = m_ivw.get_Caption(out s);
            Marshal.ThrowExceptionForHR(hr);

            // Make sure the value we set is what we just read
            Debug.Assert(s == "Foo Bar", "Get/Set Caption");
        }
Ejemplo n.º 2
0
        public override void Init()
        {
            if (!isPlaying)
            {
                string Filename = "";
                float size = 0;
                double Max = 0;
                int volume = 0;

                graph = new FilterGraph() as IFilterGraph;
                media = graph as IMediaControl;
                eventEx = media as IMediaEventEx;
                igb = media as IGraphBuilder;
                imp = igb as IMediaPosition;
                master.form.Invoke((MethodInvoker)delegate()
                {
                    Filename = master.form.M_Filename.Text;
                    media.RenderFile(Filename);
                    size = (float)master.form.M_PrevSize.Value;
                    master.form.M_PrevSize.Enabled = false;
                    imp.get_Duration(out Max);
                    master.form.M_Seek.Maximum = (int)(Max);
                    master.form.M_Seek.Value = 0;
                    volume = master.form.M_Volume.Value;
                    span = (uint)(1000000.0f / master.form.M_CollectFPS);
                });
                graph.FindFilterByName("Video Renderer", out render);
                if (render != null)
                {
                    window = render as IVideoWindow;
                    window.put_WindowStyle(
                        WindowStyle.Caption | WindowStyle.Child
                        );
                    window.put_WindowStyleEx(
                        WindowStyleEx.ToolWindow
                        );
                    window.put_Caption("ElectronicBoard - VideoPrev -");

                    int Width, Height, Left, Top;
                    window.get_Width(out Width);
                    window.get_Height(out Height);
                    window.get_Left(out Left);
                    window.get_Top(out Top);
                    renderSize.Width = (int)(Width * size);
                    renderSize.Height = (int)(Height * size);
                    Aspect = (float)renderSize.Height / (float)renderSize.Width;
                    window.SetWindowPosition(Left, Top, renderSize.Width, renderSize.Height);

                    eventEx = media as IMediaEventEx;
                    eventEx.SetNotifyWindow(master.form.Handle, WM_DirectShow, IntPtr.Zero);
                    media.Run();
                    foreach (Process p in Process.GetProcesses())
                    {
                        if (p.MainWindowTitle == "ElectronicBoard - VideoPrev -")
                        {
                            renderwindow = p.MainWindowHandle;
                            break;
                        }
                    }
                    isPlaying = true;
                    iba = media as IBasicAudio;
                    iba.put_Volume(volume);

                    //master.form.checkBox3_CheckedChanged(null, null);
                    master.Start();
                }
            }
        }
Ejemplo n.º 3
0
        public void ReloadName()
        {
            try
            {
                if (basefilter == null)
                {
                    return;
                }
                FilterInfo fi;
                basefilter.QueryFilterInfo(out fi);
                name    = fi.achName;
                orgname = fi.achName;

                IFileSourceFilter fsrc = basefilter as IFileSourceFilter;
                if (fsrc != null && fsrc.GetCurFile(out srcfilename, null) == 0 && srcfilename != null && !name.Contains(srcfilename))
                {
                    name += " " + srcfilename.Substring(srcfilename.LastIndexOf('\\') + 1);
                }

                IFileSinkFilter fdst = basefilter as IFileSinkFilter;
                if (fdst != null && fdst.GetCurFile(out dstfilename, null) == 0 && dstfilename != null && !name.Contains(dstfilename))
                {
                    name += " " + dstfilename.Substring(dstfilename.LastIndexOf('\\') + 1);
                }

                string dspname = filterProps.DisplayName;
                if (dspname != null && dspname.Length > 0)
                {
                    if (!dispnames.ContainsKey(orgname))
                    {
                        dispnames.Add(orgname, dspname);
                    }
                }
                else //have no display name
                {
                    if (dispnames.TryGetValue(orgname, out dspname))
                    {
                        filterProps.DisplayName = dspname;
                    }
                }

                IVideoWindow vw = basefilter as IVideoWindow;
                if (vw != null)
                {
                    //string s;
                    //vw.get_Caption(out s);
                    string gname = Graph.Form.Text + ": " + name;// +": ";
                    vw.put_Caption(gname);
                    //vw.SetWindowForeground(OABool.False);
                    //vw.put_AutoShow(OABool.True);
                    //vw.put_Owner(Program.mainform.Handle); hangs
                    WindowStyleEx wex;
                    vw.get_WindowStyleEx(out wex);
                    vw.put_WindowStyleEx(wex | WindowStyleEx.Topmost);
                }
            }
            catch (COMException e)
            {
                Graph.ShowCOMException(e, "Problem occured while examining filter " + Name);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Exception caught while examining filter " + Name);
            }
        }