| | |
| | | scene = s; |
| | | backAction = act; |
| | | |
| | | |
| | | refreshFunctionRowAction = () => { |
| | | LoadFunctionRow(functionListView); |
| | | }; |
| | | } |
| | | |
| | | public void LoadPage( Action backRefresh) |
| | | public void LoadPage() |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.NewScene)).LoadTopView(backRefresh); |
| | | initPage(); |
| | | } |
| | | |
| | | void initPage() |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.NewScene)).LoadTopView(); |
| | | |
| | | bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | |
| | | VerticalScrolViewLayout contentView = new VerticalScrolViewLayout() |
| | | var contentView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = Application.GetRealHeight(64), |
| | | Height = Application.GetRealHeight(603 - 50), |
| | |
| | | bodyView.AddChidren(contentView); |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealWidth(12) }); |
| | | |
| | | FrameLayout sceneBgView = new FrameLayout() |
| | | var sceneBgView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(252), |
| | |
| | | |
| | | //2020-12-03 修改图片加载方法 |
| | | ImageUtlis.Current.LoadLocalOrNetworkImages(scene.ImagePath, addSceneImageView); |
| | | |
| | | |
| | | #region 场景名称row |
| | | sceneNameView = new FrameLayout() |
| | |
| | | }; |
| | | row.AddChidren(btnRight); |
| | | |
| | | |
| | | |
| | | var btnFunctionInfo = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(327), |
| | |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | |
| | | |
| | | Button btnDelSceneFunction = new Button() |
| | | { |
| | | BackgroundColor = CSS_Color.WarningColor, |
| | |
| | | scene.SaveSceneData(true); |
| | | row.RemoveFromParent(); |
| | | functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count); |
| | | //LoadFunctionRow(functionListView); |
| | | }; |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | if (sfs.value == "off") |
| | | return Language.StringByID(StringId.Close); |
| | | } |
| | | if (sfs.key == FunctionAttributeKey.Mode) |
| | | { |
| | | |
| | | } |
| | | } |
| | | FunctionAttributes perTrait; |
| | | |
| | | switch (sceneFunction.localFunction.functionType) |
| | | if (sceneFunction.status.Count == 0) |
| | | { |
| | | case FunctionType.AC: |
| | | sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); |
| | | sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + |
| | | sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; |
| | | sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText(); |
| | | break; |
| | | case FunctionType.FloorHeating: |
| | | sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); |
| | | sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + |
| | | sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; |
| | | break; |
| | | case FunctionType.Dimmer: |
| | | perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | case FunctionType.Relay: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | break; |
| | | case FunctionType.RGB: |
| | | perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | case FunctionType.Curtain: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | break; |
| | | case FunctionType.MotorCurtain: |
| | | perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | return sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | |
| | | var modeState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode); |
| | | var tempState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); |
| | | var fanState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); |
| | | if (modeState != null) |
| | | { |
| | | sceneFunctionInfo += FunctionList.List.GetValueText(modeState.key, modeState.value); |
| | | } |
| | | if (tempState != null) |
| | | { |
| | | sceneFunctionInfo += FunctionList.List.GetValueText(tempState.key, tempState.value); |
| | | sceneFunctionInfo += FunctionList.List.GetUintString(tempState.key); |
| | | } |
| | | if (fanState != null) |
| | | { |
| | | sceneFunctionInfo += FunctionList.List.GetValueText(fanState.key, fanState.value); |
| | | } |
| | | var briState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness); |
| | | if (briState != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | var perState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent); |
| | | if (perState != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | |
| | | //FunctionAttributes perTrait; |
| | | |
| | | //switch (sceneFunction.localFunction.functionType) |
| | | //{ |
| | | //case FunctionType.AC: |
| | | //var acMode = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode); |
| | | //var acTemp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); |
| | | //var acFan = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); |
| | | //if (acMode != null) |
| | | //{ |
| | | // sceneFunctionInfo += FunctionList.List.GetValueText(acMode.key, acMode.value); |
| | | //} |
| | | //if (acTemp != null) |
| | | //{ |
| | | // sceneFunctionInfo += FunctionList.List.GetValueText(acTemp.key, acTemp.value); |
| | | // sceneFunctionInfo += FunctionList.List.GetUintString(acTemp.key); |
| | | //} |
| | | //if (acFan!=null) |
| | | //{ |
| | | // sceneFunctionInfo += FunctionList.List.GetValueText(acFan.key, acFan.value); |
| | | //} |
| | | // break; |
| | | //case FunctionType.FloorHeating: |
| | | //sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); |
| | | //sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + |
| | | // sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; |
| | | //break; |
| | | //case FunctionType.Dimmer: |
| | | //perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); |
| | | //if (perTrait != null) |
| | | //{ |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | //} |
| | | //else |
| | | //{ |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | //} |
| | | //break; |
| | | //case FunctionType.Relay: |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | // break; |
| | | //case FunctionType.RGB: |
| | | // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); |
| | | // if (perTrait != null) |
| | | // { |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; |
| | | // } |
| | | // else |
| | | // { |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | // } |
| | | // break; |
| | | //case FunctionType.Curtain: |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | // break; |
| | | //case FunctionType.MotorCurtain: |
| | | // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); |
| | | // if (perTrait != null) |
| | | // { |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; |
| | | // } |
| | | // else |
| | | // { |
| | | // sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | // } |
| | | // break; |
| | | //} |
| | | return sceneFunctionInfo; |
| | | } |
| | | |
| | |
| | | { |
| | | btnComplete.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (btnComplete.TextID == StringId.Complete) |
| | | if (string.IsNullOrEmpty(scene.name)) |
| | | { |
| | | if (string.IsNullOrEmpty(scene.name)) |
| | | new Tip() |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | foreach (var tempRoom in FunctionList.List.scenes) |
| | | { |
| | | if (scene.name == tempRoom.name) |
| | | { |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); |
| | | return; |
| | | } |
| | | foreach (var tempRoom in FunctionList.List.scenes) |
| | | { |
| | | if (scene.name == tempRoom.name) |
| | | { |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); |
| | | return; |
| | | } |
| | | } |
| | | scene.SaveSceneData(true); |
| | | } |
| | | var result = scene.AddScene(); |
| | | if (result == StateCode.SUCCESS) |
| | | { |
| | | FunctionList.List.scenes.Add(scene); |
| | | backAction(); |
| | | this.RemoveFromParent(); |
| | | } |
| | | if (btnComplete.TextID == StringId.Del) |
| | | else |
| | | { |
| | | Action action = () => |
| | | { |
| | | FunctionList.List.DeleteScene(scene, true); |
| | | backAction(); |
| | | this.RemoveFromParent(); |
| | | }; |
| | | new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteSceneTip, action); |
| | | }; |
| | | IMessageCommon.Current.ShowErrorInfoAlter(result); |
| | | } |
| | | }; |
| | | } |
| | | |