| | |
| | | /// <summary> |
| | | /// 动态加载按钮列表 |
| | | /// </summary> |
| | | /// <param name="vv">父控件</param> |
| | | /// <param name="list">数据列表</param> |
| | | /// <param name="action">回调</param> |
| | | /// <param name="if_bool">表示是否显示删除图标</param> |
| | | public void AddButton2(VerticalScrolViewLayout vv, List<Entity.AttributesStatus> list, Action<Entity.AttributesStatus> action, bool if_bool) |
| | | { |
| | | //定义一个变量记录行数 |
| | | int sum = 0; |
| | | if (list.Count % 3 == 0) |
| | | { |
| | | sum = list.Count / 3; |
| | | } |
| | | else |
| | | { |
| | | sum = list.Count / 3 + 1; |
| | | } |
| | | //计算加载出来的数据需要的高度 |
| | | int h = 16 + sum * (16 + 44) + 104 + 76; |
| | | int line = 0; |
| | | //按钮的父控件 |
| | | var FLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealWidth(h), |
| | | }; |
| | | vv.AddChidren(FLayout); |
| | | for (int i = 1, j = 0; i <= list.Count; i++, j++) |
| | | { |
| | | var nameObj = list[i - 1]; |
| | | //按钮 |
| | | var buttonNameBtn = new Button |
| | | { |
| | | |
| | | Y = Application.GetRealHeight(16 + line * (16 + 44)), |
| | | X = Application.GetRealWidth(16 + (16 + 104) * j), |
| | | Width = Application.GetRealWidth(104), |
| | | Height = Application.GetRealHeight(44), |
| | | Text = nameObj.value, |
| | | TextSize = TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Radius = (uint)Application.GetRealHeight(18), |
| | | BorderWidth = 1, |
| | | BorderColor = CSS.CSS_Color.textCancelColor, |
| | | }; |
| | | FLayout.AddChidren(buttonNameBtn); |
| | | //删除图标 |
| | | var delIconBtn = new Button |
| | | { |
| | | UnSelectedImagePath = "PirIcon/delbuton.png", |
| | | Y = Application.GetRealHeight(12 + line * (16 + 44)), |
| | | X = Application.GetRealWidth((16 + 92) + (104 + 16) * j), |
| | | Width = Application.GetRealWidth(16), |
| | | Height = Application.GetRealWidth(16), |
| | | Tag = nameObj, |
| | | }; |
| | | if (if_bool) |
| | | { |
| | | FLayout.AddChidren(delIconBtn); |
| | | } |
| | | //删除图标的点击事件 |
| | | delIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var obj = delIconBtn.Tag as Entity.AttributesStatus; |
| | | action(obj); |
| | | }; |
| | | if (i % 3 == 0) |
| | | { |
| | | //满一行重置j=0值; |
| | | j = -1; |
| | | line += 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 动态加载按钮列表 |
| | | /// </summary> |
| | | /// <param name="FLayout">父控件</param> |
| | | /// <param name="action">回调</param> |
| | | /// <param name="sum">多少个FrameLayout控件</param> |
| | |
| | | break; |
| | | case 5: |
| | | { |
| | | iconPath = "PirIcon/dvd.png"; |
| | | deviceNameIndex = StringId.dvd; |
| | | iconPath = "PirIcon/projector.png"; |
| | | deviceNameIndex = StringId.touyingyi; |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | iconPath = "PirIcon/projector.png"; |
| | | deviceNameIndex = StringId.touyingyi; |
| | | iconPath = "PirIcon/dvd.png"; |
| | | deviceNameIndex = StringId.dvd; |
| | | } |
| | | break; |
| | | case 7: |
| | |
| | | case 3: |
| | | { |
| | | //风扇 |
| | | // type = "fan-" + SPK.ElectricFan; |
| | | type = "fan-" + SPK.FanIr; |
| | | } |
| | | break; |
| | | case 4: |
| | | { |
| | | //机顶盒 |
| | | // type = "set_top_box-" + SPK.ElectricTV; |
| | | type = "set_top_box-" + SPK.StbIr; |
| | | } |
| | | break; |
| | | case 5: |
| | | { |
| | | //影碟机 |
| | | // type = "dvd-" + SPK.ElectricTV; |
| | | //投影仪 |
| | | type = "projector-" + SPK.PjtIr; |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | //投影仪 |
| | | // type = "projector-" + SPK.ElectricTV; |
| | | //影碟机 |
| | | type = "dvd-" + SPK.DvDIr; |
| | | |
| | | } |
| | | break; |
| | | |
| | | |
| | | } |
| | | return type; |
| | | } |