Display matrix status of Device Control

Source: Internet
Author: User

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);
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.