| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using Shared; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class PublicInterface |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 单选择 |
| | | /// </summary> |
| | | /// <param name="frame">显示在哪个界面的父控件</param> |
| | | /// <param name="list">显示数据源</param> |
| | | /// <param name="titleText"></param> |
| | | /// <param name="stateText">之前状态文本</param> |
| | | /// <param name="action">返回值</param> |
| | | /// <param name="textSize">显示文本字体大小</param> |
| | | public void SingleSelectionShow(FrameLayout frame, List<FuntionControlView.Aks.Entity.RemoteControlEntity> list, string titleText, string stateText, Action<int> action, int textSize = LogicView.TextSize.text14) |
| | | { |
| | | if (list == null) |
| | | { |
| | | return; |
| | | } |
| | | FrameLayout frameLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | frame.AddChidren(frameLayout); |
| | | |
| | | LogicView.DateView view = new LogicView.DateView(); |
| | | view.btnTitle.Text = titleText; |
| | | view.FLayoutView(frameLayout, list.Count); |
| | | view.btnCancel.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //移除fLayout界面 |
| | | frameLayout.RemoveFromParent(); |
| | | }; |
| | | ///定义一个Btn记录选中状态 |
| | | Button checkBtn = new Button |
| | | { |
| | | Tag = "unknown", |
| | | }; |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | FuntionControlView.Aks.Entity.RemoteControlEntity remoteControl = list[i]; |
| | | LogicView.CheckView checkView = new LogicView.CheckView(); |
| | | checkView.frameLayout.Y = Application.GetRealHeight(56 + 50 * i); |
| | | checkView.btnText.TextSize = textSize; |
| | | view.frameLayout.AddChidren(checkView.FLayoutView()); |
| | | checkView.btnText.Text = remoteControl.name; |
| | | checkView.btnClick.Tag = i;//标记 |
| | | |
| | | if (stateText == remoteControl.name) |
| | | { |
| | | //显示之前的选中状态 |
| | | checkBtn.IsSelected = false; |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | checkBtn = checkView.btnCheckIcon; |
| | | checkBtn.Tag = checkView.btnClick.Tag.ToString(); |
| | | } |
| | | //点击事件 |
| | | checkView.btnClick.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | checkBtn.IsSelected = false; |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | checkBtn = checkView.btnCheckIcon; |
| | | checkBtn.Tag = checkView.btnClick.Tag.ToString(); |
| | | }; |
| | | |
| | | } |
| | | view.btnConfirm.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | if (checkBtn.Tag.ToString() == "unknown") |
| | | { |
| | | return; |
| | | } |
| | | var index = int.Parse(checkBtn.Tag.ToString()); |
| | | if (index > list.Count) |
| | | { |
| | | index = 0; |
| | | } |
| | | action(index); |
| | | //移除fLayout界面 |
| | | frameLayout.RemoveFromParent(); |
| | | }; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 单选择 |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 多选择 |
| | | /// </summary> |
| | | /// <param name="frameLayout">父控件</param> |
| | | /// <param name="list">显示数据源</param> |
| | | /// <param name="titleText"></param> |
| | | /// <param name="stateTextList">之前状态文本</param> |
| | | /// <param name="action">返回索引值列表</param> |
| | | /// <param name="textSize">显示文本字体大小</param> |
| | | public void MultiSelectShow(FrameLayout frameLayout, List<Face> list, string titleText, string stateTexts, Action<List<int>> action, int textSize = LogicView.TextSize.text14) |
| | | { |
| | | LogicView.DateView view = new LogicView.DateView(); |
| | | view.btnTitle.Text = titleText; |
| | | view.FLayoutView(frameLayout, list.Count); |
| | | view.btnCancel.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //移除fLayout界面 |
| | | view.frameLayout.RemoveFromParent(); |
| | | }; |
| | | List<int> intList = new List<int>(); |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | var face= list[i]; |
| | | LogicView.CheckView checkView = new LogicView.CheckView(); |
| | | checkView.frameLayout.Y = Application.GetRealHeight(56 + 50 * i); |
| | | checkView.btnText.TextSize = textSize; |
| | | view.frameLayout.AddChidren(checkView.FLayoutView()); |
| | | checkView.btnText.Text = face.userName; |
| | | checkView.btnClick.Tag = i;//标记 |
| | | |
| | | if (stateTexts.Contains(face.userId)) |
| | | { |
| | | //显示之前的选中状态 |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | intList.Add(i); |
| | | } |
| | | //点击事件 |
| | | checkView.btnClick.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | |
| | | int clickIndex =int.Parse(checkView.btnClick.Tag.ToString()); |
| | | checkView.btnClick.IsSelected = !checkView.btnClick.IsSelected; |
| | | if (checkView.btnClick.IsSelected) |
| | | { |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | if (!intList.Contains(clickIndex)) |
| | | { |
| | | //添加选中数据 |
| | | intList.Add(clickIndex); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | checkView.btnCheckIcon.IsSelected = false; |
| | | if (intList.Contains(clickIndex)) |
| | | { |
| | | //移除选中数据 |
| | | intList.Remove(clickIndex); |
| | | } |
| | | } |
| | | |
| | | }; |
| | | |
| | | } |
| | | view.btnConfirm.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | if (intList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | action(intList); |
| | | //移除fLayout界面 |
| | | view.frameLayout.RemoveFromParent(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 月-多选择 |
| | | /// </summary> |
| | | /// <param name="frameLayout">父控件</param> |
| | |
| | | /// </summary> |
| | | /// <param name="frame">显示在哪个界面的父控件</param> |
| | | /// <param name="list">显示数据源</param> |
| | | /// <param name="stateList">之前状态数据源</param> |
| | | /// <param name="titleText">标题</param> |
| | | /// <param name="action">返回值索引值</param> |
| | | public void FrameOrVv(FrameLayout frame, List<string> list, List<string> stateList, int titleText, Action<int> action) |
| | | /// <param name="isIcon">数据源没有数据是否显示提示图标(默认(true)显示)</param> |
| | | public void FrameOrVv(FrameLayout frame, List<string> list, List<string> stateList, string titleText, Action<int> action,bool isIcon=true) |
| | | { |
| | | |
| | | int line = 0; |
| | |
| | | frame.AddChidren(frameLayout); |
| | | |
| | | LogicView.DateView view = new LogicView.DateView(); |
| | | view.btnTitle.TextID = titleText; |
| | | view.btnTitle.Text = titleText; |
| | | view.FLayoutView(frameLayout, line); |
| | | view.btnCancel.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | }; |
| | | |
| | | if (list.Count == 0) |
| | | if (list.Count == 0&&isIcon) |
| | | { |
| | | Button btnTipNot = new Button |
| | | { |
| | |
| | | verticalRefresh.AddChidren(checkView.FLayoutView()); |
| | | } |
| | | |
| | | if (stateList.Contains(strName)) |
| | | { |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | } |
| | | checkView.btnText.Text = strName; |
| | | checkView.btnClick.Tag = i;//标记 |
| | | |
| | | if (stateList.Contains(strName)) |
| | | { |
| | | //checkView.btnCheckIcon.IsSelected = true; |
| | | |
| | | checkBtn.IsSelected = false; |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | checkBtn = checkView.btnCheckIcon; |
| | | checkBtn.Tag = checkView.btnClick.Tag.ToString(); |
| | | } |
| | | //点击事件 |
| | | checkView.btnClick.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | |
| | | } |
| | | return list; |
| | | } |
| | | /// <summary> |
| | | /// 动态获取传感器等级列表 |
| | | /// </summary> |
| | | /// <param name="device">功能(sid)</param> |
| | | /// <returns></returns> |
| | | public List<string> GetSensorLevelList(Entity.Function device) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | var dic = GetSensorLevelDic(device); |
| | | foreach (var d in dic) { |
| | | list.Add(d.Key); |
| | | } |
| | | return list; |
| | | } |
| | | /// <summary> |
| | | /// 指定获取等级拼接的字符串 |
| | | /// </summary> |
| | | /// <param name="device">功能(sid)</param> |
| | | /// <param name="s">初始值</param> |
| | | /// <param name="isTextBoolean">表示true(返回key);false(返回values)</param> |
| | | /// <returns></returns>isTextBoolean |
| | | public string GetSensorLevelText(Entity.Function device, string s, bool isTextBoolean) |
| | | { |
| | | if (device == null || device.attrKeyConfigs == null) |
| | | { |
| | | return ""; |
| | | } |
| | | var dic = GetSensorLevelDic(device); |
| | | if (isTextBoolean) |
| | | { |
| | | foreach (var d in dic) |
| | | { |
| | | if (d.Value==s) |
| | | { |
| | | //如果values值存在,返回key值 |
| | | return d.Key.ToString(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | foreach (var d in dic) |
| | | { |
| | | if (d.Key==s) |
| | | { |
| | | //如果key值存在,返回values值 |
| | | return d.Value.ToString(); |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | /// <summary> |
| | | /// 动态获取传感器等级字典 |
| | | /// </summary> |
| | | /// <param name="device">功能(sid)</param> |
| | | /// <returns></returns> |
| | | public Dictionary<string,string> GetSensorLevelDic(Entity.Function device) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | if (device == null || device.attrKeyConfigs == null) |
| | | { |
| | | return dic; |
| | | } |
| | | string strKey = ""; |
| | | string strKeyValues = ""; |
| | | for (int i = 0; i < device.attrKeyConfigs.Count; i++) |
| | | { |
| | | var attrKeyConfig = device.attrKeyConfigs[i]; |
| | | foreach (var attrKeyInfo in attrKeyConfig.configs) |
| | | { |
| | | //动态拼接字符串 |
| | | strKey = attrKeyInfo.desc + ":" + attrKeyInfo.start + "~" + attrKeyInfo.end + attrKeyConfig.unit; |
| | | strKeyValues = "(" + attrKeyInfo.start + "," + attrKeyInfo.end + "]"; |
| | | if (!dic.ContainsKey(strKey)) |
| | | { |
| | | //没有再添加 |
| | | dic.Add(strKey, strKeyValues); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | return dic; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 模式/风速互相转换值的方法 |
| | | /// </summary> |
| | |
| | | return value; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取key值 |
| | | /// </summary> |
| | | /// <param name="value"></param> |
| | | /// <returns>不存在返回空字符“”</returns> |
| | | public string GetKey(Dictionary<string, string> dic, string value) |
| | | { |
| | | if (string.IsNullOrEmpty(value)) { |
| | | return string.Empty; |
| | | } |
| | | if (dic==null||dic.Count==0) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | //如果出现多个相同Value,这里默认返回是第一个key值 |
| | | var key = dic.FirstOrDefault(q => q.Value == value).Key; |
| | | return key == null ? string.Empty : key; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取value值 |
| | | /// </summary> |
| | | /// <param name="key">键</param> |
| | | /// <returns>不存在返回空字符“”</returns> |
| | | public string GetValue(Dictionary<string, string> dic, string key) |
| | | { |
| | | if (string.IsNullOrEmpty(key)) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | if (dic == null || dic.Count == 0) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | string value = string.Empty; |
| | | dic.TryGetValue(key, out value); |
| | | return value == null ? string.Empty : value; |
| | | } |
| | | /// <summary> |
| | | /// 获取海信电视信号源列表( 0:LiveTV;2:PS;3:HDMI_1;4:HDMI_2;5:HDMI_3;6:HDMI_4;11:AV;) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Dictionary<string, string> GetHisenseSignalSourceDic() |
| | | { |
| | | var dic = new Dictionary<string, string>(); |
| | | dic.Add("HDML 1", "3"); |
| | | dic.Add("HDML 2", "4"); |
| | | dic.Add("HDML 3", "5"); |
| | | dic.Add("HDML 4", "6"); |
| | | dic.Add("Live TV", "0"); |
| | | dic.Add("PS", "2"); |
| | | dic.Add("AV", "11"); |
| | | return dic; |
| | | } |
| | | |
| | | } |
| | | } |