如何:在 .NET User Control 中處理多個相機參數類型#
「Live View」範例(pylon C# Windows Forms)使用 User Control 來存取相機 Property。根據 Property 類型,有不同的 User Control(例如 FloatSliderUserControl.cs、IntSliderUserControl.cs 等)。
Basler 相機支援不同版本的 GenICam Standard Feature Naming Convention (SFNC)。因此,某個特性的 Property 類型可能會因相機而異。
一個例子是 Gain Property,它在不同的 SFNC 版本之間有所不同:
- Gain:Float Property
- GainAbs:Float Property
- GainRaw:Integer Property
如果您想在應用程式中使用不同的相機(這些相機為某個特性(如 Gain)實作了不同的 Property 類型)並在 GUI 中呈現它們,您有兩種選擇:
- 在 GUI 上放置兩個 User Control。根據 Property 類型,顯示其中一個並隱藏另一個。
- 在 User Control 中實作這兩種 Property 類型(整數、浮點數),並根據需要切換它們。
pylon Live View sample 實作了新的 User Control DualSliderUserControl.cs,允許存取 Float Property 和 Integer Property。
在初始化期間,根據相機類型,將 Float Property 或 Integer Property 綁定到相機特性。對 DualSliderUserControl 針對 Gain Property 的使用說明見 MainForm.cs 內部 deviceListView_SelectedIndexChanged() 事件處理常式。