private void MenuItem_Click_ON(object sender, RoutedEventArgs e) { byte[] msg = new byte[] { 0xfe, 0xef, 0x30, 0x0c, 0x00, 0x02, }; var pin = paperdata.SelectedItem as ExcelPin; if (pin != null) { short led = (short)SQliteDbContext.GetOneFixtureBaseInfo(pin.FixtureType).LEDAddress; byte[] addr = BitConverter.GetBytes(led).Reverse().ToArray(); List <byte> datas = new List <byte>(); datas.AddRange(msg); datas.AddRange(addr); Messenger.Default.Send <byte[]>(datas.ToArray(), "Send"); } }
private void MenuItem_ON(object sender, RoutedEventArgs e) { var mi = sender as MenuItem; var cm = mi.Parent as ContextMenu; var lstItem = cm.PlacementTarget as ListViewItem; if (lstItem == null) { return; } string tag = lstItem.Content.ToString(); List <byte> msg = new List <byte> { 0xfe, 0xef, 0x30, 0x0c }; List <string> leftCodes = GetCodes(tag.Split('+')[0]); List <string> rightCodes = GetCodes(tag.Split('+')[1]); List <byte> datas = new List <byte>(); if (leftCodes[2] != "" && leftCodes[2].Trim().Length != 0) { short led = (short)SQliteDbContext.GetOneFixtureBaseInfo(leftCodes[2]).LEDAddress; byte[] addr = BitConverter.GetBytes(led).Reverse().ToArray(); datas.AddRange(addr); } if (rightCodes[2] != "" && rightCodes[2].Trim().Length != 0) { short led = (short)SQliteDbContext.GetOneFixtureBaseInfo(rightCodes[2]).LEDAddress; byte[] addr = BitConverter.GetBytes(led).Reverse().ToArray(); datas.AddRange(addr); } msg.AddRange(BitConverter.GetBytes((short)datas.Count).Reverse()); msg.AddRange(datas); Messenger.Default.Send <byte[]>(msg.ToArray(), "Send"); }