惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
G
Google Developers Blog
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
C
Check Point Blog
F
Fortinet All Blogs
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
博客园 - 【当耐特】
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
M
MIT News - Artificial intelligence
Vercel News
Vercel News
博客园 - 司徒正美
Recorded Future
Recorded Future
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Webroot Blog
Webroot Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net
Y
Y Combinator Blog
J
Java Code Geeks
B
Blog
A
About on SuperTechFans
O
OpenAI News
aimingoo的专栏
aimingoo的专栏
T
Tor Project blog
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
AWS News Blog
AWS News Blog
GbyAI
GbyAI
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
V
V2EX
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
Help Net Security
Help Net Security
W
WeLiveSecurity
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - cjfwu

设计模式学习4-Bridge模式 设计模式学习3-Strategy模式 设计模式学习2-Adapter模式 设计模式学习1-Facade模式 设备控制(反馈处理) 通过System.IO.Packaging实现打包和解包 将目录添加环境变量 windows shell 编程3(函数解释) windows shell 编程2(浏览文件夹) windows shell 编程1(概念) 不同命名空间下名称和结构相同的类相互序列化与反序列化 通过SvcUtil.exe生成客户端代码和配置 分组 在“添加引用”对话框中显示需要的Assembly 只运行一个实例 SVN操作 托盘操作 获得树节点的高度 枚举的操作
设备控制之矩阵状态显示
cjfwu · 2010-07-18 · via 博客园 - cjfwu

在做设备控制的时候,比较麻烦的是连接到矩阵输出端上的设备(比如:投影机,显示器)的信号显示问题,

下面说下我用的方法:

首先建个接口:

public interface IUseVideoMatrix {
bool UseVideoOutput(int output);
void BindVideoSignal(int input, int output);
}

UseVideoOutput用于判断设备是否连到矩阵的输出端output,如果返回true,则通过BindVideoSignal将矩阵对应的

输入端input绑定给此设备。

每个连到矩阵输出端的设备对应的UserControl继承此接口,比如Odin设备的每个输入端接在矩阵的输出端上,

下图为Odin的界面:

Odin设备对应的UserControl如下:

代码

public partial class OdinPanel : UserControl, IUseVideoMatrix {
public OdinPanel() {
InitializeComponent();

Register();
}

private void Register() {
VideoOutput2Label.Add(
1, label1); //1表示矩阵的输出端1
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>();
}

此UserControl继承并实现了IUseVideoMatrix。

在管理类里建个IUseVideoMatrix的列表,并将继承此接口的UserControl添加到列表中,如下:

代码

public void InstallUseMatrixPanel() {
UseVideoMatrixPanels.Add(odinPanel1);
UseVideoMatrixPanels.Add(recordPanel1);
UseVideoMatrixPanels.Add(voicePanel1);
UseVideoMatrixPanels.Add(multiplierPanel1);
}
private List<IUseVideoMatrix> UseVideoMatrixPanels = new List<IUseVideoMatrix>();

在收到矩阵切换的命令时,遍列此列表,如果UseVideoOutput返回true,则调用BindVideoSignal刷新设备对应的信号,

代码如下:

代码

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