using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; using Shared; using Shared.SimpleControl; using Shared.SimpleControl.Phone.Music; using Shared.SimpleControl.R; using SmartHome.UI.SimpleControl.Phone.Music; namespace SmartHome { public class SetUpPage : FrameLayout { A31MusicModel a31; public void Show (A31MusicModel a31) { this.a31 = a31; AddChidren (new Button { Height = Application.GetRealHeight (36), BackgroundColor=SkinStyle.Current.MusicTopFrameLayout, }); var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight (100), Y = Application.GetRealHeight (36), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }; AddChidren (topFrameLayout); var btnTitle = new Button { TextID = MyInternationalizationString.Musicset, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren (btnTitle); var back = new Button { Width = Application.GetRealWidth (82), Height = Application.GetRealHeight (89), X = Application.GetRealWidth (10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/HomepageBack.png", }; topFrameLayout.AddChidren (back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent (); }; var hdl = new Button { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), Gravity = Gravity.CenterVertical, UnSelectedImagePath = MainPage.LogoString, }; topFrameLayout.AddChidren (hdl); var tempFrameLayout = new FrameLayout { Y = topFrameLayout.Bottom, Height = Application.GetRealHeight (Application.DesignHeight - 136), BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout, }; AddChidren (tempFrameLayout); VerticalScrolViewLayout middle = new VerticalScrolViewLayout (); tempFrameLayout.AddChidren (middle); #region 播放器名称.... var muiscnameLayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; middle.AddChidren (muiscnameLayout); var btnmusicname = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, Text = Language.StringByID (MyInternationalizationString.Playername) + ":", Width = Application.GetRealWidth (250), TextColor = SkinStyle.Current.MusicTextColor, //Text = "播放器名称", }; muiscnameLayout.AddChidren (btnmusicname); var btnpalyername = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (350), TextAlignment = TextAlignment.CenterLeft, //Text =a31.Name==null?"UnKown":a31.Name, Text = a31.Name, Width = Application.GetRealWidth (250), TextColor = SkinStyle.Current.MusicTextColor, }; muiscnameLayout.AddChidren (btnpalyername); var nextmusic = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (550), }; muiscnameLayout.AddChidren (nextmusic); EventHandler musicnameclick = (sender, e) => { MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); A31Rename rename = new A31Rename (); MainPage.MainFrameLayout.AddChidren (rename); rename.show (a31); }); }); }; btnmusicname.MouseUpEventHandler += musicnameclick; muiscnameLayout.MouseUpEventHandler += musicnameclick; nextmusic.MouseUpEventHandler += musicnameclick; btnpalyername.MouseUpEventHandler += musicnameclick; #endregion #region 蓝牙.... var bluetoothlayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; if (a31.A31DeviceType == 918||a31.A31DeviceType == 919|| a31.A31DeviceType == 920) { middle.AddChidren (bluetoothlayout); } var btnbluetoothname = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, TextID = MyInternationalizationString.Musicbluetooth, Width = Application.GetRealWidth (200), TextColor = SkinStyle.Current.MusicTextColor, //Text = "蓝牙", }; bluetoothlayout.AddChidren (btnbluetoothname); var nextbluetooth = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (550), }; bluetoothlayout.AddChidren (nextbluetooth); EventHandler btnbluetoothnameclick = (sender, e) => { Dialog window = new Dialog (); window.Show (); var frameLayout = new FrameLayout { Width = Application.GetRealWidth (580), Height = Application.GetRealHeight (300), X = Application.GetRealWidth (30), Y = Application.GetRealHeight (330), BackgroundColor = 0xffffffff, }; window.AddChidren (frameLayout); var Modifyname = new Button { Width = Application.GetRealWidth (580), Height = Application.GetRealHeight (80), TextID = MyInternationalizationString.newbluetoothname, //Text = "请输入新蓝牙名称", Y = Application.GetRealHeight (10), // TextColor = 0xff000000, TextSize = 16, TextColor = SkinStyle.Current.MusicTipTextColor, }; frameLayout.AddChidren (Modifyname); var bluetoothname = new EditText { Width = Application.GetRealWidth (540), Height = Application.GetRealHeight (80), Y = Application.GetRealHeight (80), X = Application.GetRealWidth (20), Gravity = Gravity.CenterVertical, BackgroundColor = SkinStyle.Current.MusicTipBackgroundColor, //TextColor = 0xff000000, Radius = 1, BorderWidth = 1, BorderColor = SkinStyle.Current.MusicEditBorderColor, TextColor = SkinStyle.Current.MusicTextColor, }; frameLayout.AddChidren (bluetoothname); var ther1 = new Button { Height = Application.GetRealHeight (2), Y = Application.GetRealHeight (218), BackgroundColor = 0xff666666, }; frameLayout.AddChidren (ther1); var cancelrow = new RowLayout { Y = Application.GetRealHeight (220), Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (289), BackgroundColor = 0xffcccccc, }; frameLayout.AddChidren (cancelrow); var cancel = new Button { TextID = MyInternationalizationString.cancel, //TextColor = 0xff000000, TextSize = 18, TextColor = SkinStyle.Current.MusicTextColor, }; cancelrow.AddChidren (cancel); cancel.MouseUpEventHandler += (sender1, e1) => { window.Close (); }; var ther = new Button { Y = Application.GetRealHeight (220), Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (2), X = Application.GetRealHeight (289), BackgroundColor = 0xff666666, }; frameLayout.AddChidren (ther); var confirmrow = new RowLayout { Y = Application.GetRealHeight (220), X = Application.GetRealWidth (291), Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (289), BackgroundColor = 0xffcccccc, }; frameLayout.AddChidren (confirmrow); var confirm = new Button { TextID = MyInternationalizationString.confirm, //TextColor = 0xff000000, TextSize = 18, TextColor = SkinStyle.Current.MusicTextColor, }; confirmrow.AddChidren (confirm); confirm.MouseUpEventHandler += (sender1, e1) => { if (bluetoothname.Text.Trim () == "") { new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.nameisempty), Language.StringByID (MyInternationalizationString.Close)).Show (); return; } send (a31.IPAddress, "MCU+PAS+BT" + bluetoothname.Text.Trim () + "*&"); window.Close (); }; }; bluetoothlayout.MouseUpEventHandler += btnbluetoothnameclick; btnbluetoothname.MouseUpEventHandler += btnbluetoothnameclick; nextbluetooth.MouseUpEventHandler += btnbluetoothnameclick; #endregion #region 均衡器.... var eqthlayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; if (a31.A31DeviceType == 918 || a31.A31DeviceType == 919 || a31.A31DeviceType == 920) { middle.AddChidren(eqthlayout); } var btneq = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, TextID = MyInternationalizationString.equalizer, Width = Application.GetRealWidth (200), TextColor = SkinStyle.Current.MusicTextColor, //Text = "均衡器", }; eqthlayout.AddChidren (btneq); var nexteq = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (550), }; eqthlayout.AddChidren (nexteq); EventHandler btneqnameclick = (sender, e) => { var dialog = new Dialog () { BackgroundColor =SkinStyle.Current.MusicDialogBackgroundColor, //0xFF484848, Width = Application.GetRealWidth (600), Height = Application.GetRealHeight (400), }; dialog.Show (); var titleFrameLayout = new FrameLayout { Width = dialog.Width, BackgroundColor =SkinStyle.Current.MusicTopFrameLayout, //0xFF121212, Height = Application.GetRealHeight (100), }; dialog.AddChidren (titleFrameLayout); var btneqtitle = new Button { TextID = MyInternationalizationString.EqualizerSettings, //Text = "均衡器设置", TextColor = SkinStyle.Current.MusicTextColor, }; titleFrameLayout.AddChidren (btneqtitle); var btneqback = new Button { Width = Application.GetRealWidth (82), Height = Application.GetRealHeight (89), X = Application.GetRealWidth (10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/HomepageBack.png", }; titleFrameLayout.AddChidren (btneqback); btneqback.MouseDownEventHandler += (sender1, e1) => { dialog.Close (); }; var trebleFrameLayout = new FrameLayout { Y = Application.GetRealHeight (130), Width = Application.GetRealWidth (600), Height = Application.GetRealHeight (100), }; dialog.AddChidren (trebleFrameLayout); var btntreblemax = new Button { Width = Application.GetRealWidth (100), Height = Application.GetRealHeight (100), X = Application.GetRealWidth (20), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, //Text = "高音:", TextID = MyInternationalizationString.treble, TextColor = SkinStyle.Current.MusicTextColor, }; trebleFrameLayout.AddChidren (btntreblemax); var btnCurrentTreble = new Button { Width = Application.GetRealWidth (90), Height = Application.GetRealHeight (100), X = Application.GetRealWidth (510), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.MusicTextColor, Text = "0db", }; trebleFrameLayout.AddChidren (btnCurrentTreble); var treblehorizontalSeekBarvol = new HorizontalSeekBar { Width = Application.GetRealWidth (350),//400 //Height = Application.GetRealHeight (100), Radius = (uint)Application.GetRealHeight (25), X = Application.GetRealWidth (120), ProgressColor = 0xffFE5E00, ThumbRadius = 11, ThumbColor = SkinStyle.Current.HorizontalSeekBarThumbColor, }; trebleFrameLayout.AddChidren (treblehorizontalSeekBarvol); int n1 = 5,db1=0; treblehorizontalSeekBarvol.ProgressChanged += (sender2, e2) => { if (0 <= e2 && e2 <= 8) { n1 = 0; db1 = -5; } else if (8 < e2 && e2 <= 17) { n1 = 1; db1 = -4; } else if (17 < e2 && e2 <= 26) { n1 = 2; db1 = -3; } else if (26 < e2 && e2 <= 35) { n1 = 3; db1 = -2; } else if (35 < e2 && e2 <= 44) { n1 = 4; db1 = -1; } else if (44 < e2 && e2 <= 53) { n1 = 5; db1 = 0; } else if (53 < e2 && e2 <= 62) { n1 = 6; db1 = 1; } else if (62 < e2 && e2 <= 71) { n1 = 7; db1 = 2; } else if (71 < e2 && e2 <= 80) { n1 = 8; db1 = 3; } else if (80 < e2 && e2 <= 89) { n1 = 9; db1 = 4; } else if (89 < e2 && e2 <= 100) { n1 = 10; db1 = 5; } if (-5 <= db1 && db1 <= -1) { btnCurrentTreble.Text = db1 + "db"; } else if (1 <= db1 && db1<= 5) { btnCurrentTreble.Text = "+" + db1 + "db"; } else { btnCurrentTreble.Text = "0db"; } send (a31.IPAddress, $"MCU+PAS+EQSet:treble:{n1}&"); //init (e2, "treble"); }; var bassFrameLayout = new FrameLayout { Y = Application.GetRealHeight (270), Width = Application.GetRealWidth (600), Height = Application.GetRealHeight (100), }; dialog.AddChidren (bassFrameLayout); var btnbass = new Button { Width = Application.GetRealWidth (100), Height = Application.GetRealHeight (100), X = Application.GetRealWidth (20), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, //Text = "低音:", TextID = MyInternationalizationString.bass, TextColor = SkinStyle.Current.MusicTextColor, }; bassFrameLayout.AddChidren (btnbass); var btnCurrentbass = new Button { Width = Application.GetRealWidth (90), Height = Application.GetRealHeight (100), X = Application.GetRealWidth (510), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.MusicTextColor, Text = "0db", }; bassFrameLayout.AddChidren (btnCurrentbass); var basshorizontalSeekBarvol = new HorizontalSeekBar { Width = Application.GetRealWidth (350), //Height = Application.GetRealHeight (100), Radius = (uint)Application.GetRealHeight (25), X = Application.GetRealWidth (120), ProgressColor = 0xffFE5E00, ThumbRadius = 11, ThumbColor = SkinStyle.Current.HorizontalSeekBarThumbColor, }; bassFrameLayout.AddChidren (basshorizontalSeekBarvol); int n2 = 5, db2 = 0; basshorizontalSeekBarvol.ProgressChanged += (sender2, e2) => { if (0 <= e2 && e2 <= 8) { n2 = 0; db2 = -5; } else if (8 < e2 && e2 <= 17) { n2 = 1; db2 = -4; } else if (17 < e2 && e2 <= 26) { n2 = 2; db2 = -3; } else if (26 < e2 && e2 <= 35) { n2 = 3; db2 = -2; } else if (35 < e2 && e2 <= 44) { n2 = 4; db2 = -1; } else if (44 < e2 && e2 <= 53) { n2 = 5; db2 = 0; } else if (53 < e2 && e2 <= 62) { n2 = 6; db2 = 1; } else if (62 < e2 && e2 <= 71) { n2 = 7; db2 = 2; } else if (71 < e2 && e2 <= 80) { n2 = 8; db2 = 3; } else if (80 < e2 && e2 <= 89) { n2 = 9; db2 = 4; } else if (89 < e2 && e2 <= 100) { n2 = 10; db2 = 5; } if (-5 <= db2 && db2 <= -1) { btnCurrentbass.Text = db2 + "db"; } else if (1 <= db2 && db2 <= 5) { btnCurrentbass.Text = "+" + db2 + "db"; } else { btnCurrentbass.Text = "0db"; } send (a31.IPAddress, $"MCU+PAS+EQSet:bass:{n2}&"); //init (e2, "bass"); }; var str = EqGetSend (a31.IPAddress, "MCU+PAS+EQGet&"); if (str != null) { try { string [] array = str.Split ('&'); int treblevalue = int.Parse (array [0].Replace ("MCU+PAS+EQ:treble:", "")); var treblval = equpdate (treblevalue); if (treblval != null) { string [] value1 = treblval.Split ('_'); if (value1!=null) { int treblecurrentvol = int.Parse (value1 [0]); int treblecurrentdb = int.Parse (value1 [1]); if (-5<= treblecurrentdb && treblecurrentdb <= -1) { btnCurrentTreble.Text =treblecurrentdb + "db"; } else if (1 < treblecurrentdb && treblecurrentdb <= 5) { btnCurrentTreble.Text = "+" + treblecurrentdb + "db"; } else { btnCurrentTreble.Text = "0db"; } treblehorizontalSeekBarvol.Progress =treblecurrentvol; } } int bassvalue = int.Parse (array [1].Replace ("MCU+PAS+EQ:bass:", "")); var bassval = equpdate (bassvalue); if (bassval != null) { string [] value2 = bassval.Split ('_'); if (value2 != null) { int basscurrentvol = int.Parse (value2 [0]); int basscurrentdb = int.Parse (value2 [1]); if (-5 <= basscurrentdb && basscurrentdb <= -1) { btnCurrentbass.Text = basscurrentdb + "db"; } else if (1 <= basscurrentdb && basscurrentdb <= 5) { btnCurrentbass.Text = "+" + basscurrentdb + "db"; } else { btnCurrentbass.Text = "0db"; } basshorizontalSeekBarvol.Progress = basscurrentvol; } } } catch { } } }; eqthlayout.MouseUpEventHandler += btneqnameclick; btneq.MouseUpEventHandler += btneqnameclick; nexteq.MouseUpEventHandler += btneqnameclick; #endregion #region 设备信息.... var devicelayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; middle.AddChidren (devicelayout); var btndevice = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, TextID = MyInternationalizationString.speakerinfo, Width = Application.GetRealWidth (350), TextColor = SkinStyle.Current.MusicTextColor, //Text = "设备信息", }; devicelayout.AddChidren (btndevice); var nextdevice = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (550), }; devicelayout.AddChidren (nextdevice); EventHandler deviceclick = (sender, e) => { MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); var a31DeviceArgument = new A31DeviceArgument (); MainPage.MainFrameLayout.AddChidren (a31DeviceArgument); a31DeviceArgument.Show (a31); }); }); }; devicelayout.MouseUpEventHandler += deviceclick; btndevice.MouseUpEventHandler += deviceclick; nextdevice.MouseUpEventHandler += deviceclick; #endregion #region IP.... var IPLayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; //middle.AddChidren (IPLayout); var ip1 = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, //TextID = MyInternationalizationString.custom, Width=Application.GetRealWidth(200), Text = "IP :", TextColor = SkinStyle.Current.MusicTextColor, }; IPLayout.AddChidren (ip1); var ip = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (130), TextAlignment = TextAlignment.CenterLeft, Text = a31.IPAddress, TextColor = SkinStyle.Current.MusicTextColor, }; IPLayout.AddChidren (ip); #endregion } System.Threading.Thread thread; void send (string ip, string message) { // System.Console.WriteLine ("发送高低音" + message); if (thread != null) { thread.Abort (); } thread=new System.Threading.Thread(() => { var tcpClient = new TcpClient () { ReceiveTimeout = 1000 }; try { //进行连接 tcpClient.Connect (new IPEndPoint (IPAddress.Parse (ip), 8899)); var buffter = Encoding.UTF8.GetBytes (message); var sendByes = new byte [20 + buffter.Length]; sendByes [0] = 0x18; sendByes [1] = 0x96; sendByes [2] = 0x18; sendByes [3] = 0x20; sendByes [4] = (byte)((buffter.Length & 0x000000FF) >> 0); sendByes [5] = (byte)((buffter.Length & 0x0000FF00) >> 8); sendByes [6] = (byte)((buffter.Length & 0x00FF0000) >> 16); sendByes [7] = (byte)((buffter.Length & 0xFF000000) >> 24); var checkSum = getCheckSum (buffter); sendByes [8] = (byte)((checkSum & 0x000000FF) >> 0); sendByes [9] = (byte)((checkSum & 0x0000FF00) >> 8); sendByes [10] = (byte)((checkSum & 0x00FF0000) >> 16); sendByes [11] = (byte)((checkSum & 0xFF000000) >> 24); sendByes [16] = 0x08; Array.Copy (buffter, 0, sendByes, 20, buffter.Length); tcpClient.GetStream ().Write (sendByes, 0, sendByes.Length); tcpClient.GetStream ().Flush (); thread = null; } catch { } finally{ tcpClient.Close (); } }); thread.Start (); } string EqGetSend (string ip, string message) { //System.Console.WriteLine ("读取高低音" + message); var tcpClient = new TcpClient () { ReceiveTimeout = 1000 }; List list = null; try { //进行连接 tcpClient.Connect (new IPEndPoint (IPAddress.Parse (ip), 8899)); var buffter = Encoding.UTF8.GetBytes (message); var sendByes = new byte [20 + buffter.Length]; sendByes [0] = 0x18; sendByes [1] = 0x96; sendByes [2] = 0x18; sendByes [3] = 0x20; sendByes [4] = (byte)((buffter.Length & 0x000000FF) >> 0); sendByes [5] = (byte)((buffter.Length & 0x0000FF00) >> 8); sendByes [6] = (byte)((buffter.Length & 0x00FF0000) >> 16); sendByes [7] = (byte)((buffter.Length & 0xFF000000) >> 24); var checkSum = getCheckSum (buffter); sendByes [8] = (byte)((checkSum & 0x000000FF) >> 0); sendByes [9] = (byte)((checkSum & 0x0000FF00) >> 8); sendByes [10] = (byte)((checkSum & 0x00FF0000) >> 16); sendByes [11] = (byte)((checkSum & 0xFF000000) >> 24); sendByes [16] = 0x08; Array.Copy (buffter, 0, sendByes, 20, buffter.Length); tcpClient.GetStream ().Write (sendByes, 0, sendByes.Length); tcpClient.GetStream ().Flush (); var len = 0; var bytes = new byte [100]; while (0 < (len = tcpClient.GetStream ().Read (bytes, 0, bytes.Length))) { if (list == null) { list = new List (); } for (int i = 20; i < len; i++) { list.Add (bytes [i]); } } return Encoding.UTF8.GetString (list.ToArray ()); } catch { if (list == null) { return null; } else { return Encoding.UTF8.GetString (list.ToArray ()).TrimEnd ('&'); } } finally { try { tcpClient.Close (); } catch { } } } uint getCheckSum (byte [] buffer) { uint check_sum = 0; for (int i = 0; i < buffer.Length; i++) { check_sum += buffer [i]; } return check_sum; } void init (int val, string str) { int n = 5; if (0 <= val && val <= 8) { n = 0; } else if (8 < val && val <= 17) { n = 1; } else if (17 < val && val <= 26) { n = 2; } else if (26 < val && val <= 35) { n = 3; } else if (35 < val && val <= 44) { n = 4; } else if (44 < val && val <= 53) { n = 5; } else if (53 < val && val <= 62) { n = 6; } else if (62 < val && val <= 71) { n = 7; } else if (71 < val && val <= 80) { n = 8; } else if (80 < val && val <= 89) { n = 9; } else if (89 < val && val <= 100) { n = 10; } send (a31.IPAddress, $"MCU+PAS+EQSet:{str}:{n}&"); } string equpdate (int n) { int val = 50,db=0; if (n == 0) { val = 0; db = -5; } else if (n == 1) { val = 12; db = -4; } else if (n == 2) { val = 21; db = -3; } else if (n == 3) { val = 30; db = -2; } else if (n == 4) { val = 40; db = -1; } else if (n == 5) { val = 50; db = 0; } else if (n == 6) { val = 57; db = 1; } else if (n == 7) { val = 66; db = 2; } else if (n == 8) { val = 76; db = 3; } else if (n == 9) { val = 85; db = 4; } else if (n == 10) { val = 100; db = 5; } return val.ToString()+"_"+db; } } }