2011-01-13 19 views
0

私は、このダイアログを開きC#:ピンダイアログの設定方法?

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

を実行するためにどのようなプロセスを知りたいです。 alt text このダイアログは、MSエクスプレッションエンコーダのライブブロードキャストプロジェクトからのもので、選択したデバイスのコンフィギュレーションピンのダイアログです。 alt text

+2

? – Justin

+0

MSエクスプレッションエンコーダー4、ライブブロードキャストプロジェクト、このダイアログでは、選択したビデオデバイスを構成します。 –

答えて

4

このダイアログは、System.Diagnostics.Process.Startで実行することができる独立した実行可能ファイルではありません。これはキャプチャデバイスの設定ダイアログです。キャプチャデバイスは、DirectShowキャプチャデバイスとして表されます。このデバイスは、ISpecifyPropertyPagesを実装するCOMオブジェクトです。これは、特定の画面が表示される場所です。 Hereは、DirectShowフィルタのプロパティページを表示する方法に関するMSDNの記事です。

+0

DirectShowを使わずに実行できますか?式エンコーダライブラリはそれを実行できますか? –

+0

フィルタを作成してそのページに問い合わせることなく、ダイアログを表示する方法がわかりません。プロパティページのGUIDを知っていれば、OleCreatePropertyFrameに渡すことができますが、オブジェクトを照会せずにGUIDを取得できることはわかりません。 – heavyd

1

この行で実行してそのダイアログを表示できるプログラムはありません。

2

あなたは式エンコーダSDK 4を使用している場合は、次のようにこのダイアログと他の設定ウィンドウを表示することができます。

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

あなたはMicrosoft.Expression.Encoder.Liveを探索によってサポートされているすべての設定ダイアログを見ることができます.ConfigurationDialog型。

+0

VideoCapturePinDialogをモーダル/ダイアログではなくモーダルフォームで表示することはできますか? OKボタンを押す前に、セッティングの変更を直接知りたい場合は、適用してください。 –

1

通常、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); 
関連する問題