Exemplo n.º 1
0
        public void AddFilter(FilterProps fp, Point?desired_pos)  //create new IBaseFilter, add it to DS graph and this graph
        {
            Filter f;

            try
            {
                f = new Filter(fp);
                int hr = graphBuilder.AddFilter(f.BaseFilter, fp.Name);
                DsError.ThrowExceptionForHR(hr);
            }
            catch (COMException e)
            {
                ShowCOMException(e, "Error creating filter " + fp.Name);
                return;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error adding filter");
                return;
            }
            string srcfn = null, dstfn = null;

            if ((f.BaseFilter as IFileSourceFilter) != null)
            {
                srcfn = f.ChooseSrcFileName();
            }

            if ((f.BaseFilter as IFileSinkFilter) != null)
            {
                dstfn = f.ChooseDstFileName();
            }

            AddFilterHere(f, true, desired_pos);
            history.AddFilter(fp, f.Name, srcfn, dstfn, f);
        }