using System;
using System.Collections.Generic;
using Shared;
using Shared.SimpleControl;
using Shared.SimpleControl.R;
namespace Shared
{
///
/// 红外发射
///
[System.Serializable]
public class InfraredMode : Common
{
public InfraredMode () : base ()
{
this.Type = DeviceType.InfraredMode;
DeviceTextID = 41; //SimpleControl.R.MyInternationalizationString.TV;
}
//设备码:DeviceID 0:投影机 1:风扇 2:机顶盒 3:DVD 4:TV 5:空调 6:IPTV
public InfraredType InfraredType = InfraredType.NULL;
public List infraredFuntionList = new List ();
public List infraredInherentFunctions = new List ();
public string Port = "1";
///
/// 是否是通用开关控制
///
public bool IsUniversalSwitch = false;
///
/// 虚拟记录当前设备到开关状
/// 用来app显示图标到状态
///
public bool isOpen = false;
///
/// app初始化默认到红外控制按键
///
public void InitFunction ()
{
//Confrim,//00021=确定
//Up,//00022=上
//Left,//00023=左
//Right,//00024=右
//Down,//00025=下
infraredFuntionList = new List ();
if (InfraredType == InfraredType.TV) {
//One,//00008=1
//Two,//00009=2
//Three,//00010=3
//Four,//00011=4
//Five,//00012=5
//Six,//00013=6
//Seven,//00014=7
//Eight,//00015=8
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 8,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 9,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 10,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 11,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 12,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 13,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 14,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 15,
});
//Back,//00020=返回
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 20,
});
//Nine,//00016=9
//Zero,//00018=0
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 16,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 18,
});
//Menu,//00003=菜单
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 3,
});
//Power,//00006=电源键
//VolDown = 1,
//VolUp,//00005=音量+
//Mute,//00007=静音
//infraredFuntionList.Add (new InfraredCustomKey () {
// functionCode = 6,
//});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 5,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 1,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 7,
});
//ChannelUp,//00002=频道+
//ChannelDown,//00004=频道-
//Change,//00017=-/--
//AV_TV,//00019=AV/TV
//infraredFuntionList.Add (new InfraredCustomKey () {
// functionCode = 4,
//});
//infraredFuntionList.Add (new InfraredCustomKey () {
// functionCode = 17,
//});
//infraredFuntionList.Add (new InfraredCustomKey () {
// functionCode = 19,
//});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 2,
});
} else if(InfraredType == InfraredType.STB) {
//One,2
//Two,3
//Three,
//Four,
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 2,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 3,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 4,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 5,
});
//Five,6
//Six,7
//Seven,8
//Eight,9
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 6,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 7,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 8,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 9,
});
//Back,13
//Nine,10
//Zero,12
//Menu,23
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 13,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 10,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 12,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 23,
});
//Standby = 1,
//HomePage,11
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 1,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 11,
});
//VolUp,19
//VolDown,20
//ChannelUp,21
//ChannelDown,22
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 20,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 19,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 22,
});
infraredFuntionList.Add (new InfraredCustomKey () {
functionCode = 21,
});
//Up,14
//Left,15
//Confrim,16
//Right,17
//Down,18
}
IO.FileUtils.SaveEquipmentMessage (this, this.LoopID.ToString ());
}
///
/// 初始化固有按键
///
public void InitInherentFunction ()
{
if(InfraredType == InfraredType.TV) {
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Up", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Up});
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Down", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Down});
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Left", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Left});
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Right", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Right});
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "OK", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Confrim});
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Power", universalSwitchId = 0 , functionCode = (byte)InfraredCode_TV.Confrim});
}else if (InfraredType == InfraredType.STB) {
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Up", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Up });
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Down", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Down });
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Left", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Left });
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Right", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Right });
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "OK", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Confrim });
infraredInherentFunctions.Add (new InfraredCustomKey () { functionName = "Power", universalSwitchId = 0, functionCode = (byte)InfraredCode_STB.Confrim });
}
}
public List InfraredCustomChannel = new List ();
}
///
/// 红外控制类型
///
public enum InfraredType
{
STB = 2,
TV = 4,
AC = 5,
NULL = 255,
}
///
/// 自定义功能
///
[System.Serializable]
public class InfraredCustomKey
{
public string functionName = "";
///
/// 按键号、序号
///
public byte functionCode = 254;
///
/// 通用开关号
///
public byte universalSwitchId = 0;
public byte GetUniversalSwitchId (InfraredType infraredType)
{
byte id = 254;
if(infraredType == InfraredType.TV) {
}
return id;
}
///
/// 获取选中状态图片
///
public string GetSelectedImagePath (InfraredType infraredType)
{
string imagePath = "";
if (infraredType == InfraredType.TV) {
switch (functionCode) {
case 1://VolDown = 1,
imagePath = "TVIcon/20_On.png";
break;
case 2:
imagePath = "TVIcon/16_On.png";
break;
case 3:
imagePath = "TVIcon/11_On.png";
break;
case 4:
imagePath = "TVIcon/15_On.png";
break;
case 5:
imagePath = "TVIcon/18_On.png";
break;
case 6:
imagePath = "TVIcon/12_On.png";
break;
case 7:
imagePath = "TVIcon/19_On.png";
break;
case 8:
imagePath = "TVIcon/0_On.png";
break;
case 9:
imagePath = "TVIcon/1_On.png";
break;
case 10:
imagePath = "TVIcon/2_On.png";
break;
case 11:
imagePath = "TVIcon/3_On.png";
break;
case 12:
imagePath = "TVIcon/4_On.png";
break;
case 13:
imagePath = "TVIcon/5_On.png";
break;
case 14:
imagePath = "TVIcon/6_On.png";
break;
case 15:
imagePath = "TVIcon/7_On.png";
break;
case 16:
imagePath = "TVIcon/9_On.png";
break;
case 17:
imagePath = "TVIcon/21_On.png";
break;
case 18:
imagePath = "TVIcon/10_On.png";
break;
case 19:
imagePath = "TVIcon/21_On.png";
break;
case 20:
imagePath = "TVIcon/8_On.png";
break;
case 26:
imagePath = "TVIcon/Guide_On.png";
break;
case 27:
imagePath = "TVIcon/Source_On.png";
break;
case 28:
imagePath = "TVIcon/Info_On.png";
break;
case 29:
imagePath = "TVIcon/Exit_On.png";
break;
case 30:
imagePath = "TVIcon/Tools_On.png";
break;
case 31:
imagePath = "TVIcon/SmartHub_On.png";
break;
case 32:
imagePath = "TVIcon/Netflix_On.png";
break;
}
} else if (infraredType == InfraredType.STB) {
//Up,14
//Left,15
//Confrim,16
//Right,17
//Down,18
switch (functionCode) {
//VolDown,20
case 20:
imagePath = "TVIcon/20_On.png";
break;
//ChannelUp,21
case 21:
imagePath = "TVIcon/13_On.png";
break;
//Menu,23
case 23:
imagePath = "TVIcon/11_On.png";
break;
//ChannelDown,22
case 22:
imagePath = "TVIcon/14_On.png";
break;
//VolUp,19
case 19:
imagePath = "TVIcon/18_On.png";
break;
//Standby = 1,
case 1:
imagePath = "TVIcon/12_On.png";
break;
//One,
case 2:
imagePath = "TVIcon/0_On.png";
break;
//Two,3
case 3:
imagePath = "TVIcon/1_On.png";
break;
//Three,4
case 4:
imagePath = "TVIcon/2_On.png";
break;
//Four,5
case 5:
imagePath = "TVIcon/3_On.png";
break;
//Five,6
case 6:
imagePath = "TVIcon/4_On.png";
break;
//Six,7
case 7:
imagePath = "TVIcon/5_On.png";
break;
//Seven,8
case 8:
imagePath = "TVIcon/6_On.png";
break;
//Eight,9
case 9:
imagePath = "TVIcon/7_On.png";
break;
//Back,13
case 13:
imagePath = "TVIcon/8_On.png";
break;
//Nine,10
case 10:
imagePath = "TVIcon/9_On.png";
break;
case 17://00017=-/--
imagePath = "TVIcon/21_On.png";
break;
//Zero,12
case 12:
imagePath = "TVIcon/10_On.png";
break;
//------机顶盒自定义按键
case 24:
imagePath = "TVIcon/Info_On.png";
break;
case 25:
imagePath = "TVIcon/Guide_On.png";
break;
case 26:
imagePath = "TVIcon/Tools_On.png";
break;
case 27:
imagePath = "TVIcon/Next_On.png";
break;
case 28:
imagePath = "TVIcon/RedKey_On.png";
break;
case 29:
imagePath = "TVIcon/GreenKey_On.png";
break;
case 30:
imagePath = "TVIcon/YellowKey_On.png";
break;
case 31:
imagePath = "TVIcon/BlueKey_On.png";
break;
case 32:
imagePath = "TVIcon/Confirm_On.png";
break;
case 33:
imagePath = "TVIcon/19_On.png";
break;
//VolDown,20
case 11:
imagePath = "TVIcon/17_On.png";
break;
case 34://=-/--
imagePath = "TVIcon/21_On.png";
break;
}
}
return imagePath;
}
///
/// 获取文本
///
public string GetText(InfraredType infraredType)
{
string str = "";
if (infraredType == InfraredType.TV) {
switch (functionCode) {
case 1://VolDown = 1,
str = Language.StringByID (MyInternationalizationString.VolumeDown);
break;
case 2:
str = Language.StringByID (MyInternationalizationString.ChannelUp);
break;
case 3:
str = Language.StringByID (MyInternationalizationString.Menu);
break;
case 4:
str = Language.StringByID (MyInternationalizationString.ChannelDown);
break;
case 5:
str = Language.StringByID (MyInternationalizationString.VolumeUp);
break;
case 7:
str = Language.StringByID (MyInternationalizationString.Mute);
break;
case 13:
str = Language.StringByID (MyInternationalizationString.back);
break;
case 20:
str = Language.StringByID (MyInternationalizationString.back);
break;
case 26:
str = "Guide";
break;
case 27:
str = "Source";
break;
case 28:
str = "Info";
break;
case 29:
str = "Exit";
break;
case 30:
str = "Tools";
break;
case 31:
str = "SmartHub";
break;
case 32:
str = "Netflix";
break;
}
} else if (infraredType == InfraredType.STB) {
switch (functionCode) {
//VolUp,19
//VolDown,20
//ChannelUp,21
//ChannelDown,22
//Menu,23
case 20://VolDown = 1,
str = Language.StringByID (MyInternationalizationString.Volume);
break;
case 19:
str = Language.StringByID (MyInternationalizationString.Volume);
break;
case 23:
str = Language.StringByID (MyInternationalizationString.Menu);
break;
case 22:
str = Language.StringByID (MyInternationalizationString.Channel);
break;
case 21:
str = Language.StringByID (MyInternationalizationString.Channel);
break;
//------机顶盒自定义按键
case 24:
str = "Info";
break;
case 25:
str = "Guide";
break;
case 26:
str = "Tools";
break;
case 27:
str = "Next";
break;
case 32:
str = "Confirm";
break;
case 33:
str = "Mute";
break;
case 11:
str = "Home";
break;
case 13:
str = Language.StringByID (MyInternationalizationString.back);
break;
case 34://=-/--
str = @"AV/TV";
break;
}
}
return str;
}
///
/// 获取未选中状态图片
///
public string GetUnSelectedImagePath(InfraredType infraredType)
{
string imagePath = "";
if (infraredType == InfraredType.TV) {
switch (functionCode) {
case 1://VolDown = 1,
imagePath = "TVIcon/20.png";
break;
case 2://00002=频道+
imagePath = "TVIcon/16.png";
break;
case 3://00003=菜单
imagePath = "TVIcon/11.png";
break;
case 4://00004=频道-
imagePath = "TVIcon/15.png";
break;
case 5://00005=音量+
imagePath = "TVIcon/18.png";
break;
case 6://00006=电源键
imagePath = "TVIcon/12.png";
break;
case 7://00007=静音
imagePath = "TVIcon/19.png";
break;
case 8://00008=1
imagePath = "TVIcon/0.png";
break;
case 9://00009=2
imagePath = "TVIcon/1.png";
break;
case 10://00010=3
imagePath = "TVIcon/2.png";
break;
case 11://00011=4
imagePath = "TVIcon/3.png";
break;
case 12://00012=5
imagePath = "TVIcon/4.png";
break;
case 13://00013=6
imagePath = "TVIcon/5.png";
break;
case 14://00014=7
imagePath = "TVIcon/6.png";
break;
case 15://00015=8
imagePath = "TVIcon/7.png";
break;
case 16://00016=9
imagePath = "TVIcon/9.png";
break;
case 17://00017=-/--
imagePath = "TVIcon/21.png";
break;
case 18://00019=AV/TV
imagePath = "TVIcon/10.png";
break;
case 19://00019=AV/TV
imagePath = "TVIcon/21.png";
break;
case 20://00020=返回
imagePath = "TVIcon/8.png";
break;
//----------
case 26:
imagePath = "TVIcon/Guide.png";
break;
case 27:
imagePath = "TVIcon/Source.png";
break;
case 28:
imagePath = "TVIcon/Info.png";
break;
case 29:
imagePath = "TVIcon/Exit.png";
break;
case 30:
imagePath = "TVIcon/Tools.png";
break;
case 31:
imagePath = "TVIcon/SmartHub.png";
break;
case 32:
imagePath = "TVIcon/Netflix.png";
break;
}
} else if (infraredType == InfraredType.STB) {
//Up,14
//Left,15
//Confrim,16
//Right,17
//Down,18
switch (functionCode) {
case 34://=-/--
imagePath = "TVIcon/21.png";
break;
//VolDown,20
case 11:
imagePath = "TVIcon/17.png";
break;
case 20:
imagePath = "TVIcon/20.png";
break;
//ChannelUp,21
case 21:
imagePath = "TVIcon/13.png";
break;
//Menu,23
case 23:
imagePath = "TVIcon/11.png";
break;
//ChannelDown,22
case 22:
imagePath = "TVIcon/14.png";
break;
//VolUp,19
case 19:
imagePath = "TVIcon/18.png";
break;
//Standby = 1,
case 1:
imagePath = "TVIcon/12.png";
break;
//One,
case 2:
imagePath = "TVIcon/0.png";
break;
//Two,3
case 3:
imagePath = "TVIcon/1.png";
break;
//Three,4
case 4:
imagePath = "TVIcon/2.png";
break;
//Four,5
case 5:
imagePath = "TVIcon/3.png";
break;
//Five,6
case 6:
imagePath = "TVIcon/4.png";
break;
//Six,7
case 7:
imagePath = "TVIcon/5.png";
break;
//Seven,8
case 8:
imagePath = "TVIcon/6.png";
break;
//Eight,9
case 9:
imagePath = "TVIcon/7.png";
break;
//Back,13
case 13:
imagePath = "TVIcon/8.png";
break;
//Nine,10
case 10:
imagePath = "TVIcon/9.png";
break;
case 17://00017=-/--
imagePath = "TVIcon/21.png";
break;
//Zero,12
case 12:
imagePath = "TVIcon/10.png";
break;
//------机顶盒自定义按键
case 24:
imagePath = "TVIcon/Info.png";
break;
case 25:
imagePath = "TVIcon/Guide.png";
break;
case 26:
imagePath = "TVIcon/Tools.png";
break;
case 27:
imagePath = "TVIcon/Next.png";
break;
case 28:
imagePath = "TVIcon/RedKey.png";
break;
case 29:
imagePath = "TVIcon/GreenKey.png";
break;
case 30:
imagePath = "TVIcon/YellowKey.png";
break;
case 31:
imagePath = "TVIcon/BlueKey.png";
break;
case 32:
imagePath = "TVIcon/Confirm.png";
break;
case 33:
imagePath = "TVIcon/19.png";
break;
}
}
return imagePath;
}
}
///
/// 电视按键
///
public enum TVKeys
{
VolDown = 1,
ChannelUp,//00002=频道+
Menu,//00003=菜单
ChannelDown,//00004=频道-
VolUp,//00005=音量+
Power,//00006=电源键
Mute,//00007=静音
One,//00008=1
Two,//00009=2
Three,//00010=3
Four,//00011=4
Five,//00012=5
Six,//00013=6
Seven,//00014=7
Eight,//00015=8
Nine,//00016=9
Change,//00017=-/--
Zero,//00018=0
AV_TV,//00019=AV/TV
Back,//00020=返回
OK,//00021=确定
Up,//00022=上
Left,//00023=左
Right,//00024=右
Down,//00025=下
//------电视自定义按键
Guide=26,
Source,
Info,
Exit,
Tools,
SmartHub,
Netflix,
}
///
/// 通用开关命令列表
///
public enum STBKeys
{
Standby = 1,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine=10,
HomePage,
Zero,
Back,
Up,
Left,
OK,
Right,
Down,
VolUp,
VolDown=20,
ChannelUp,
ChannelDown,
Menu,
//------机顶盒自定义按键
Info = 24,
Guide,
Tools,
Next,
RedKey,
GreenKey,
YellowKey=30,
BlueKey,
Confirm,
Mute,
AV_TV,
}
///
/// 用户自定频道
///
[System.Serializable]
public class InfraredCustomChannel
{
public string ChannelName;
public string ChannelNumber;
public string BackgroundImagePath = "TV/TV3_4.png";
public string ChannelIconPath;
public byte loopID;
public byte port;
public void Send (byte subnetID,byte deviceID, InfraredType infraredType, bool isUV)
{
try {
for (int i = 0; i < ChannelNumber.Length; i++) {
if (isUV) {
byte cn = Convert.ToByte (ChannelNumber.Substring (i, 1));
Control.ControlBytesSend (Command.SetCommonSwitch, subnetID, deviceID, new byte [] { cn, 255 });
} else {
int cn = Convert.ToInt32 (ChannelNumber.Substring (i, 1));
int RandKey = new Random ().Next (0, 255);
byte codeId = Convert.ToByte (cn + 7);//默认控制电视
if (infraredType == InfraredType.STB) {
codeId = Convert.ToByte (cn + 7);
}
Control.ControlBytesSend (Command.InfraredControl, subnetID, deviceID, new byte [] { port, loopID,
codeId, 0, 0, (byte)RandKey });
}
}
} catch { }
}
}
}