using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.SimpleControl;
|
|
namespace Shared
|
{
|
[System.Serializable]
|
public class InfraredMode : Common
|
{
|
public InfraredMode () : base ()
|
{
|
this.Type = DeviceType.InfraredMode;
|
//if (InfraredType == InfraredType.TV)
|
DeviceTextID = SimpleControl.R.MyInternationalizationString.TV;
|
//else if (InfraredType == InfraredType.AC)
|
//DeviceTextID = SimpleControl.R.MyInternationalizationString.AC;
|
}
|
public InfraredType InfraredType = InfraredType.NULL;
|
|
//设备码:DeviceID 0:投影机 1:风扇 2:机顶盒 3:DVD 4:TV 5:空调 6:IPTV
|
|
public List<InfraredCustomFunction> TV_CustomFuntion = new List<InfraredCustomFunction> ();
|
|
public string Port = "1";
|
|
//DeviceTextID
|
|
public bool isControlTV = true;
|
|
/// <summary>
|
/// 电视绑定机顶盒的路径
|
/// </summary>
|
public string LinkInfraredMode = string.Empty;
|
|
public string deviceFilePath {
|
get {
|
return "Equipment_InfraredMode_" + SubnetID.ToString () + "_" + DeviceID.ToString () + "_" + (LoopID.ToString ().Length < 2 ? "0" + LoopID.ToString () : LoopID.ToString ());
|
}
|
}
|
|
public bool isOpen = false;
|
|
|
public void InitTVFunction ()
|
{
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
TextID = 4,
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.VolUp,
|
});
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
TextID = 0,
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.VolDown,
|
});
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
TextID = 1,
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.ChannelUp,
|
});
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
TextID = 3,
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.ChannelDown,
|
});
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
TextID = 2,
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.Menu,
|
});
|
|
TV_CustomFuntion.Add (new InfraredCustomFunction () {
|
UnSelectedImagePath = "TV/TVIcon.png",
|
SelectedImagePath = "TV/TV_On.png",
|
TextID = 6,
|
DeviceFilePath = deviceFilePath,
|
FunctionCode = (int)InfraredCode_TV.Mute,
|
});
|
|
IO.FileUtils.SaveEquipmentMessage (this, this.LoopID.ToString ());
|
}
|
|
public List<InfraredCustomChannel> InfraredCustomChannel = new List<InfraredCustomChannel> ();
|
}
|
|
public enum InfraredType
|
{
|
STB = 2,
|
TV = 4,
|
AC = 5,
|
NULL = 255,
|
}
|
|
[System.Serializable]
|
public class InfraredCustomFunction
|
{
|
public int TextID;
|
public bool IsTV = true;
|
public string SelectedImagePath;
|
public string UnSelectedImagePath = "Item/TV_Bottom.png";
|
/// <summary>
|
/// 红外模块回路(红外库)路径
|
/// </summary>
|
public string DeviceFilePath;
|
public int FunctionCode = 254;
|
|
}
|
|
|
/// <summary>
|
/// 用户自定频道
|
/// </summary>
|
[System.Serializable]
|
public class InfraredCustomChannel
|
{
|
public string ChannelName;
|
public string ChannelNumber;
|
public string BackgroundImagePath = "TV/TV3_4.png";
|
public string ChannelIconPath;
|
public bool isTV = true;
|
public byte subnetID;
|
public byte deviceID;
|
public byte loopID;
|
public byte port;
|
|
public void Send ()
|
{
|
for (int i = 0; i < ChannelNumber.Length; i++) {
|
int cn = Convert.ToInt32 (ChannelNumber.Substring (i, 1));
|
Random ran = new Random ();
|
int RandKey = ran.Next (0, 255);
|
if (isTV)
|
Control.ControlBytesSend (Command.InfraredControl, subnetID, deviceID, new byte [] { port, loopID,
|
Convert.ToByte(cn+7), 0, 0, (byte)RandKey });
|
else
|
Control.ControlBytesSend (Command.InfraredControl, subnetID, deviceID, new byte [] { port, loopID,
|
Convert.ToByte(cn+1), 0, 0, (byte)RandKey });
|
}
|
}
|
}
|
}
|