using System; namespace Shared.SimpleControl.Phone { public class UserTVNumberView :FrameLayout { public void Show (InfraredMode infraredTV) { this.BackgroundColor = SkinStyle.Current.MainColor; Random ran = new Random (); InfraredMode linkSTB; Button tv_1 = new Button () { X = Application.GetRealWidth (45), Y = Application.GetRealHeight (90), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_1.png", SelectedImagePath = "TV/TV2_1_on.png", }; this.AddChidren (tv_1); tv_1.MouseDownEventHandler += (sender, e) => { tv_1.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.One, 0, 0, (byte)RandKey }); } else{ linkSTB = null; Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.One, 0, 0, (byte)RandKey }); } //if (!infraredTV.isControlTV) { // Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.One, 0, 0, (byte)RandKey }); //} else // Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.One, 0, 0, (byte)RandKey }); }; tv_1.MouseUpEventHandler += (sender, e) => { tv_1.IsSelected = false; }; Button tv_2 = new Button () { X = Application.GetRealWidth (248), Y = Application.GetRealHeight (90), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_2.png", SelectedImagePath = "TV/TV2_2_on.png", }; this.AddChidren (tv_2); tv_2.MouseDownEventHandler += (sender, e) => { tv_2.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Two, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Two, 0, 0, (byte)RandKey }); }; tv_2.MouseUpEventHandler += (sender, e) => { tv_2.IsSelected = false; }; Button tv_3 = new Button () { X = Application.GetRealWidth (450), Y = Application.GetRealHeight (90), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_3.png", SelectedImagePath = "TV/TV2_3_on.png", }; this.AddChidren (tv_3); tv_3.MouseDownEventHandler += (sender, e) => { tv_3.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Three, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Three, 0, 0, (byte)RandKey }); }; tv_3.MouseUpEventHandler += (sender, e) => { tv_3.IsSelected = false; }; Button tv_4 = new Button () { X = Application.GetRealWidth (45), Y = Application.GetRealHeight (287), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_4.png", SelectedImagePath = "TV/TV2_4_on.png", }; this.AddChidren (tv_4); tv_4.MouseDownEventHandler += (sender, e) => { tv_4.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Four, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Four, 0, 0, (byte)RandKey }); }; tv_4.MouseUpEventHandler += (sender, e) => { tv_4.IsSelected = false; }; Button tv_5 = new Button () { X = Application.GetRealWidth (248), Y = Application.GetRealHeight (287), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_5.png", SelectedImagePath = "TV/TV2_5_on.png", }; this.AddChidren (tv_5); tv_5.MouseDownEventHandler += (sender, e) => { tv_5.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Five, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Five, 0, 0, (byte)RandKey }); }; tv_5.MouseUpEventHandler += (sender, e) => { tv_5.IsSelected = false; }; Button tv_6 = new Button () { X = Application.GetRealWidth (450), Y = Application.GetRealHeight (287), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_6.png", SelectedImagePath = "TV/TV2_6_on.png", }; this.AddChidren (tv_6); tv_6.MouseDownEventHandler += (sender, e) => { tv_6.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Six, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Six, 0, 0, (byte)RandKey }); }; tv_6.MouseUpEventHandler += (sender, e) => { tv_6.IsSelected = false; }; Button tv_7 = new Button () { X = Application.GetRealWidth (45), Y = Application.GetRealHeight (483), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_7.png", SelectedImagePath = "TV/TV2_7_on.png", }; this.AddChidren (tv_7); tv_7.MouseDownEventHandler += (sender, e) => { tv_7.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Seven, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Seven, 0, 0, (byte)RandKey }); }; tv_7.MouseUpEventHandler += (sender, e) => { tv_7.IsSelected = false; }; Button tv_8 = new Button () { X = Application.GetRealWidth (248), Y = Application.GetRealHeight (483), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_8.png", SelectedImagePath = "TV/TV2_8_on.png", }; this.AddChidren (tv_8); tv_8.MouseDownEventHandler += (sender, e) => { tv_8.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Eight, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Eight, 0, 0, (byte)RandKey }); }; tv_8.MouseUpEventHandler += (sender, e) => { tv_8.IsSelected = false; }; Button tv_9 = new Button () { X = Application.GetRealWidth (450), Y = Application.GetRealHeight (483), Width = Application.GetMinRealAverage (151), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_9.png", SelectedImagePath = "TV/TV2_9_on.png", }; this.AddChidren (tv_9); tv_9.MouseDownEventHandler += (sender, e) => { tv_9.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Nine, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Nine, 0, 0, (byte)RandKey }); }; tv_9.MouseUpEventHandler += (sender, e) => { tv_9.IsSelected = false; }; Button tv_0 = new Button () { X = Application.GetRealWidth (50), Y = Application.GetRealHeight (680), Width = Application.GetMinRealAverage (232), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_0.png", SelectedImagePath = "TV/TV2_0_on.png", }; this.AddChidren (tv_0); tv_0.MouseDownEventHandler += (sender, e) => { tv_0.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Zero, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Zero, 0, 0, (byte)RandKey }); }; tv_0.MouseUpEventHandler += (sender, e) => { tv_0.IsSelected = false; }; Button tv_ok = new Button () { X = Application.GetRealWidth (370), Y = Application.GetRealHeight (680), Width = Application.GetMinRealAverage (232), Height = Application.GetMinRealAverage (132), UnSelectedImagePath = "TV/TV2_OK.png", SelectedImagePath = "TV/TV2_OK_on.png", }; this.AddChidren (tv_ok); tv_ok.MouseDownEventHandler += (sender, e) => { tv_ok.IsSelected = true; int RandKey = ran.Next (0, 255); if (!string.IsNullOrEmpty (infraredTV.LinkInfraredMode)) { linkSTB = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (infraredTV.LinkInfraredMode))); } else linkSTB = null; if (linkSTB != null) { Control.ControlBytesSend (Command.InfraredControl, linkSTB.SubnetID, linkSTB.DeviceID, new byte [] { Convert.ToByte (linkSTB.Port), linkSTB.LoopID, (byte)InfraredCode_STB.Confrim, 0, 0, (byte)RandKey }); } else Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Confrim, 0, 0, (byte)RandKey }); }; tv_ok.MouseUpEventHandler += (sender, e) => { tv_ok.IsSelected = false; }; FrameLayout bottomNull = new FrameLayout () { BackgroundColor = SkinStyle.Current.MainColor, Height = Application.GetRealHeight(70), Y = Application.GetRealHeight(910), }; AddChidren (bottomNull); } } }