| | |
| | | /// 表示是(条件/目标) |
| | | /// </summary> |
| | | private string if_type; |
| | | /// <summary> |
| | | /// 定义一个记录选中设备状态列表; |
| | | /// </summary> |
| | | private List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>(); |
| | | /// <summary> |
| | | /// 定义一个变量,记录选中状态 |
| | | /// </summary> |
| | | private string selectedState = "unknown"; |
| | | /// <summary> |
| | | /// 定义一个变量,记录选中状态记录属性 |
| | | /// </summary> |
| | | private string keyVlaue = ""; |
| | | public void Show(Entity.Function device, int index, bool edit, string str) |
| | | { |
| | | if_type = str; |
| | |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | #endregion |
| | | //定义一个记录选中设备状态列表; |
| | | List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>(); |
| | | //定义一个变量,记录选中状态 |
| | | string selectedState = "unknown"; |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | //开关灯光 light.Switch |
| | | case FunctionType.Dimmer: |
| | | { |
| | | //for (int i = 0; i < device.function.Count; i++) |
| | | //{ |
| | | //} |
| | | LogicView.SelectTypeView relayView = new LogicView.SelectTypeView(); |
| | | relayView.btnIcon.Visible = false; |
| | | relayView.btnState.Visible = true; |
| | | relayView.btnText.TextSize = LogicView.TextSize.text16; |
| | | relayView.btnText.Height = Application.GetRealHeight(22); |
| | | relayView.btnText.TextID = StringId.switchLogic; |
| | | relayView.btnText.X = Application.GetRealWidth(16); |
| | | relayView.btnText.Width = Application.GetRealWidth(130); |
| | | relayView.btnLine.X = Application.GetRealWidth(16); |
| | | relayView.btnLine.Width = Application.GetRealWidth(343); |
| | | relayView.btnState.Text = ""; |
| | | fLayout.AddChidren(relayView.FLayoutView()); |
| | | relayView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout relayFunView = new FrameLayout |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(relayFunView); |
| | | LogicView.SwitchView switchView = new LogicView.SwitchView(); |
| | | switchView.FLayoutView(relayFunView, 2); |
| | | |
| | | Button btnOn = new Button |
| | | { |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | TextID = StringId.onLogic, |
| | | Height = Application.GetRealHeight(44), |
| | | Width = Application.GetRealWidth(343), |
| | | |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnOn); |
| | | Button btnLine = new Button |
| | | { |
| | | Height = 1, |
| | | BackgroundColor = CSS.CSS_Color.viewLine, |
| | | Y = btnOn.Bottom, |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnLine); |
| | | Button btnOff = new Button |
| | | { |
| | | Y = btnLine.Bottom, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | TextID = StringId.offLogic, |
| | | Height = Application.GetRealHeight(44), |
| | | Width = Application.GetRealWidth(343), |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnOff); |
| | | |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "on_off"); |
| | | LogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | btnOn.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "on"); |
| | | RemView(relayFunView); |
| | | relayView.btnState.TextID = StringId.onLogic; |
| | | selectedState = device.functionType + "_on"; |
| | | AddDictionaryData(dicSateteList, "on_off", dic); |
| | | }; |
| | | btnOff.MouseUpEventHandler += (sender3, e3) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "off"); |
| | | RemView(relayFunView); |
| | | relayView.btnState.TextID = StringId.offLogic; |
| | | selectedState = device.functionType + "_off"; |
| | | AddDictionaryData(dicSateteList, "on_off", dic); |
| | | }; |
| | | |
| | | if (relayView.btnState.Text != "") |
| | | { |
| | | if (relayView.btnState.Text == btnOn.Text) |
| | | { |
| | | btnOn.TextColor = CSS.CSS_Color.textConfirmColor; |
| | | } |
| | | else |
| | | { |
| | | btnOff.TextColor = CSS.CSS_Color.textConfirmColor; |
| | | } |
| | | } |
| | | |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState,2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, relayView.btnState, null, null, null); |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case FunctionType.RGB: |
| | | { |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case FunctionType.RGBW: |
| | | { |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case FunctionType.CCT: |
| | | { |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case FunctionType.Relay: |
| | | { |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | //窗帘 |
| | | case FunctionType.Curtain: |
| | | { |
| | | LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); |
| | | lightSwitchView.btnText.TextID = StringId.switchLogic; |
| | | lightSwitchView.btnState.Text = ""; |
| | | fLayout.AddChidren(lightSwitchView.FLayoutView()); |
| | | lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | |
| | | |
| | | |
| | | #region 保存 |
| | |
| | | } |
| | | break; |
| | | } |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | { |
| | | foreach (var dic in dicList) |
| | | if (if_type== LogicMethod.condition_if) { |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | foreach (var dic in dicList) |
| | | { |
| | | button1.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | | else |
| | | { |
| | | button1.Text = Language.StringByID(StringId.offLogic); |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | button1.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | | else |
| | | { |
| | | button1.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | else if (if_type == LogicMethod.target_if) |
| | | { |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 |
| | | case FunctionType.Relay: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | button1.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | | else |
| | | { |
| | | button1.Text = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | /// <summary> |
| | | /// 添加选中数据 |
| | | /// </summary> |
| | | /// <param name="dicList">数据列表</param> |
| | | /// <param name="keyValue">识别设备</param> |
| | | /// <param name="dicList">存储数据列表</param> |
| | | /// <param name="keyValue">识别设备</param> |
| | | /// <param name="dictionary">选中数据</param> |
| | | /// <returns></returns> |
| | | private void AddDictionaryData(List<Dictionary<string, string>> dicList, string keyValue, Dictionary<string, string> dictionary) |
| | |
| | | for (int i = 0; i < dicList.Count; i++) |
| | | { |
| | | var dic = dicList[i]; |
| | | if (dic.ContainsValue(keyValue)) |
| | | if (dic.ContainsValue(keyValue)) |
| | | { |
| | | //判断是否存在 |
| | | indexValue = i; |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 开关功能展开界面 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | /// <param name="device"></param> |
| | | /// <param name="button"></param> |
| | | /// <param name="len"></param> |
| | | public void SwitchViewMethod(FrameLayout frame, Entity.Function device,Button button, int len) { |
| | | |
| | | LogicView.SwitchView switchView = new LogicView.SwitchView(); |
| | | switchView.FLayoutView(frame, len); |
| | | |
| | | Button btnOn = new Button |
| | | { |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | TextID = StringId.onLogic, |
| | | Height = Application.GetRealHeight(44), |
| | | Width = Application.GetRealWidth(343), |
| | | |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnOn); |
| | | Button btnLine = new Button |
| | | { |
| | | Height = 1, |
| | | BackgroundColor = CSS.CSS_Color.viewLine, |
| | | Y = btnOn.Bottom, |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnLine); |
| | | Button btnOff = new Button |
| | | { |
| | | Y = btnLine.Bottom, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = LogicView.TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | TextID = StringId.offLogic, |
| | | Height = Application.GetRealHeight(44), |
| | | Width = Application.GetRealWidth(343), |
| | | }; |
| | | switchView.frameLayout.AddChidren(btnOff); |
| | | |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | switch (if_type) |
| | | { |
| | | case LogicMethod.condition_if: |
| | | { |
| | | LogicMethod.dictionary(dic, "key", "on_off"); |
| | | LogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.dictionary(dic, "data_type", "string"); |
| | | keyVlaue = "on_off"; |
| | | } |
| | | break; |
| | | case LogicMethod.target_if: |
| | | { |
| | | LogicMethod.dictionary(dic, "key", "on_off"); |
| | | keyVlaue = "on_off"; |
| | | } |
| | | break; |
| | | } |
| | | btnOn.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "on"); |
| | | RemView(frame); |
| | | button.TextID = StringId.onLogic; |
| | | selectedState = device.functionType + "_on"; |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | }; |
| | | btnOff.MouseUpEventHandler += (sender3, e3) => |
| | | { |
| | | LogicMethod.dictionary(dic, "value", "off"); |
| | | RemView(frame); |
| | | button.TextID = StringId.offLogic; |
| | | selectedState = device.functionType + "_off"; |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | }; |
| | | if (button.Text != "") |
| | | { |
| | | if (button.Text == btnOn.Text) |
| | | { |
| | | btnOn.TextColor = CSS.CSS_Color.textConfirmColor; |
| | | } |
| | | else |
| | | { |
| | | btnOff.TextColor = CSS.CSS_Color.textConfirmColor; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |