コード例 #1
0
        void TestFileName()
        {
            int         hr;
            string      fn;
            AMMediaType pmt = new AMMediaType();

            hr = m_ppsink.GetCurFile(out fn, pmt);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(fn == FileName, "GetCurFile");
            Debug.Assert(pmt.majorType == MediaType.Stream, "GetCurFile type");

            Marshal.AddRef(pmt.unkPtr);

            hr = m_ppsink.SetFileName(@"c:\foo2.out", pmt);
            DsError.ThrowExceptionForHR(hr);

            hr = m_ppsink.GetCurFile(out fn, pmt);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(fn == @"c:\foo2.out", "GetCurFile2");
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public DSFilterNode(IBaseFilter filter, bool manualAdded)
        {
            _filter      = filter;
            _manualAdded = manualAdded;

            AssociatedUINode = typeof(DSFilterNodeUI).AssemblyQualifiedName;

            // if it's a filesource filter, get the filename for it
            IFileSourceFilter fs = filter as IFileSourceFilter;

            if (fs != null)
            {
                IAMOpenProgress op = filter as IAMOpenProgress;
                if (op != null)
                {
                    // it wants a URL (thought you were being sneaky huh?)
                    string      url   = string.Empty;
                    AMMediaType mtype = new AMMediaType();
                    fs.GetCurFile(out url, mtype);
                    if (url == null)
                    {
                        URLDialog ud = new URLDialog();
                        if (ud.ShowDialog() == DialogResult.OK)
                        {
                            fs.Load(ud.URL, null);
                        }
                        ud.Dispose();
                        ud = null;
                    }
                    fs = null;
                }
                else
                {
                    // it wants a filename
                    string      filename = string.Empty;
                    AMMediaType mtype    = new AMMediaType();
                    fs.GetCurFile(out filename, mtype);
                    if (filename == null)
                    {
                        OpenFileDialog ofd = new OpenFileDialog();
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            fs.Load(ofd.FileName, null);
                        }
                        ofd.Dispose();
                        ofd = null;
                    }
                    fs = null;
                }
            }

            // if it's a filewriter, get the filename for it
            IFileSinkFilter fw = filter as IFileSinkFilter;

            if (fw != null)
            {
                string      filename = string.Empty;
                AMMediaType mtype    = new AMMediaType();
                fw.GetCurFile(out filename, mtype);
                if (filename == null)
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        fw.SetFileName(sfd.FileName, null);
                    }
                }
                fw = null;
            }

            // create and add all DaggerPins for this filter
            SyncPins();
        }