【问题标题】:C# : How to open configuration Pin Dialog?C#:如何打开配置 Pin 对话框?
【发布时间】:2011-06-08 12:18:18
【问题描述】:

我想知道要运行什么进程

 System.Diagnostics.Process.Start("", "");

即打开此对话框。谢谢 此对话框来自 MS Expression 编码器的直播项目,所选设备的 Config pin Dialog。

【问题讨论】:

  • 来自 MS Expression Encoder 4 , Live Broadcasting Project, This Dialog show to configure the selected video device.

标签: c# configuration video properties dialog


【解决方案1】:

没有任何程序可以通过该行运行来调出该对话框。 (当然,除非你制作一个。)

【讨论】:

    【解决方案2】:

    此对话框不是一个单独的可执行文件,您可以使用System.Diagnostics.Process.Start 运行它。这是捕获设备的配置对话框。您的捕获设备表示为 DirectShow 捕获设备。该设备是一个实现ISpecifyPropertyPages 的COM 对象,这是您正在查看的特定屏幕的来源。 Here 是一篇关于如何显示 DirectShow 过滤器的属性页的 MSDN 文章。

    【讨论】:

    • 不使用Directshow可以执行吗?表达式编码器库可以执行吗?
    • 我不知道如何在不创建过滤器和查询其页面的情况下获取对话框。如果您知道属性页的 GUIDS,您可以将它们传递到 OleCreatePropertyFrame,但我不知道您是否可以在不查询对象的情况下获取 GUIDS。
    【解决方案3】:

    如果您使用的是 Expression Encoder SDK 4,则可以显示此对话框和其他配置窗口,如下所示:

     LiveDeviceSource _deviceSource;   
     ....
     if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCapturePinDialog))
     {              
           _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCapturePinDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle)));
     }
    

    您可以通过探索 Microsoft.Expression.Encoder.Live.ConfigurationDialog 类型来查看所有支持的配置对话框。

    【讨论】:

    • 是否可以以非模式/对话框的非模式形式显示 VideoCapturePinDialog?如果我们想直接知道设置的变化,在按下确定按钮应用之前。
    【解决方案4】:

    使用 Expression Encoder SDK 中的LiveDeviceSource.ShowConfigurationDialog 函数通常是一个不错的选择。然而,就我而言,如果配置错误,我有一些捕获源无法被 Expression Encoder 正确实例化。为了正确配置它们,我需要它们的配置对话框。所以,我使用DirectShow.NET 整合了这个解决方案:

    /// <summary>
    /// Retrieves the IBaseFilter with the requested name
    /// </summary>
    /// <param name="deviceName">The friendly name of the device to retrieve</param>
    /// <param name="deviceType">The type of device to retrieve</param>
    /// <returns>Returns the filter with the given friendly name, or null if no such filter exists</returns>
    public static IBaseFilter GetDeviceFilterByName(string deviceName, EncoderDeviceType deviceType)
    {
        int hr = 0;
        IEnumMoniker classEnum = null;
        IMoniker[] moniker = new IMoniker[1];
    
        // Create the system device enumerator
        ICreateDevEnum devEnum = (ICreateDevEnum)new CreateDevEnum();
    
        // Create an enumerator for the video or audio capture devices
        if (deviceType == EncoderDeviceType.Audio)
        {
            hr = devEnum.CreateClassEnumerator(FilterCategory.AudioInputDevice, out classEnum, 0);
        } else
        {
            hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum, 0);
        }
    
        DsError.ThrowExceptionForHR(hr);
        Marshal.ReleaseComObject(devEnum);
    
        // no enumerators for video/audio input devices
        if (classEnum == null)
        {
            return null;
        }
    
        IBaseFilter foundFilter = null;
        // enumerate all input devices, looking for one with the desired friendly name
        while(classEnum.Next(moniker.Length, moniker, IntPtr.Zero) == 0)
        {
            Guid iid = typeof(IPropertyBag).GUID;
            object props;
            moniker[0].BindToStorage(null, null, ref iid, out props);
            object currentName;
            (props as IPropertyBag).Read("FriendlyName", out currentName, null);
    
            if ((string)currentName == deviceName)
            {
                object filter;
                iid = typeof(IBaseFilter).GUID;
                moniker[0].BindToObject(null, null, ref iid, out filter);
                foundFilter = (IBaseFilter)filter;
    
                Marshal.ReleaseComObject(moniker[0]);
                break;
            }
            Marshal.ReleaseComObject(moniker[0]);
        }
    
        Marshal.ReleaseComObject(classEnum);
        return foundFilter;
    }
    
    /// <summary>
    /// Opens the property pages for the filter with the given name
    /// </summary>
    /// <param name="filter">The filter for which we wish to retrieve and open the property pages</param>
    public static void ShowDevicePropertyPages(IBaseFilter filter, IntPtr handle)
    {
        // get the ISpecifyPropertyPages for the filter
        ISpecifyPropertyPages pProp = filter as ISpecifyPropertyPages;
        int hr = 0;
        if (pProp == null)
        {
            // if the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead
            IAMVfwCompressDialogs compressDialog = filter as IAMVfwCompressDialogs;
            if (compressDialog != null)
            {
                hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero);
                DsError.ThrowExceptionForHR(hr);
            }
            return;
        }
    
        // get the name of the filter from the FilterInfo struct
        FilterInfo filterInfo;
        hr = filter.QueryFilterInfo(out filterInfo);
        DsError.ThrowExceptionForHR(hr);
    
        // get the propertypages from the property bag
        DsCAUUID caGUID;
        hr = pProp.GetPages(out caGUID);
        DsError.ThrowExceptionForHR(hr);
    
        // create and display the OlePropertyFrame
        object[] oDevice = new[] {(object)filter};
        hr = OleCreatePropertyFrame(handle, 0, 0, filterInfo.achName, 1, oDevice,
                                    caGUID.cElems, caGUID.ToGuidArray(), 0, 0, 0);
        DsError.ThrowExceptionForHR(hr);
    
        // release COM objects
        Marshal.FreeCoTaskMem(caGUID.pElems);
        Marshal.ReleaseComObject(pProp);
        if (filterInfo.pGraph != null)
        {
            Marshal.ReleaseComObject(filterInfo.pGraph);
        }
    }
    
    [DllImport("oleaut32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
    static extern int OleCreatePropertyFrame(IntPtr hwndOwner,
        int x,
        int y,
        [MarshalAs(UnmanagedType.LPWStr)] string lpszCaption,
        int cObjects,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
        int cPages,
        [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
        int lcid,
        int dwReserved,
        int lpvReserved);
    

    用法:

    var device = GetDeviceFilterByName(_settingsViewModel.VideoEncoderDevice.Name, EncoderDeviceType.Video);
    ShowDevicePropertyPages(device, new HandleRef(ConfigurationDialogHost, 
                        ConfigurationDialogHost.Handle).Handle);
    

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2017-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多