During device control, it is troublesome to display the signal of devices connected to the matrix output end (such as projectors and monitors,
The method I used is as follows:
First, create an interface:
public interface IUseVideoMatrix {
bool UseVideoOutput(int output);
void BindVideoSignal(int input, int output);
}
UseVideoOutput is used to determine whether the device is connected to the output end of the matrix. If true is returned, BindVideoSignal is used
Input is bound to this device.
UserControl of each device connected to the output end of the matrix inherits this interface. For example, each input end of the Odin device is connected to the output end of the matrix,
Odin interface:
The UserControl of the Odin device is as follows:
Code
Public partial class OdinPanel: UserControl, IUseVideoMatrix {
Public OdinPanel (){
InitializeComponent ();
Register ();
}
Private void Register (){
VideoOutput2Label. Add (1, label1); // 1 indicates output 1 of the matrix.
VideoOutput2Label. Add (2, label2 );
VideoOutput2Label. Add (3, label3 );
VideoOutput2Label. Add (4, label4 );
VideoOutput2Label. Add (5, label5 );
VideoOutput2Label. Add (6, label6 );
VideoOutput2Label. Add (7, label7 );
VideoOutput2Label. Add (8, label8 );
}
Public bool UseVideoOutput (int output ){
Return VideoOutput2Label. ContainsKey (output );
}
Public void BindVideoSignal (int input, int output ){
If (input <0 | input> Room. Instance. VideoMatrix. VideoInputNames. Count) {return ;}
Label label = VideoOutput2Label [output];
Label. Text = Room. Instance. VideoMatrix. GetInputNameByInput (input );
}
Private Dictionary <int, Label> VideoOutput2Label = new Dictionary <int, Label> ();
}
This UserControl inherits and implements IUseVideoMatrix.
Create an IUseVideoMatrix list in the management class and add the UserControl that inherits this interface to the list, as shown below:
Code
public void InstallUseMatrixPanel() {
UseVideoMatrixPanels.Add(odinPanel1);
UseVideoMatrixPanels.Add(recordPanel1);
UseVideoMatrixPanels.Add(voicePanel1);
UseVideoMatrixPanels.Add(multiplierPanel1);
}
private List<IUseVideoMatrix> UseVideoMatrixPanels = new List<IUseVideoMatrix>();
When receiving the matrix switch command, repeat this list. If UseVideoOutput returns true, call BindVideoSignal to refresh the signal corresponding to the device,
The Code is as follows:
Code
private void VideoMatrixNotifyHandler(Notify notify) {
VideoMatrixNotify videoMatrixNotify = notify as VideoMatrixNotify;
int input = videoMatrixNotify.Input;
int output = videoMatrixNotify.Output;
foreach (var each in UseVideoMatrixPanels) {
if (each.UseVideoOutput(output)) {
each.BindVideoSignal(input, output);
}
}
}