| | |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | | using HDL_ON.Entity; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | |
| | | /// </summary> |
| | | VerticalScrolViewLayout functionListView; |
| | | /// <summary> |
| | | /// 场景名称row |
| | | /// </summary> |
| | | FrameLayout sceneNameView; |
| | | |
| | | /// <summary> |
| | | /// 场景名称显示文本 |
| | | /// </summary> |
| | | EditText etSceneName; |
| | | Button btnSceneName; |
| | | /// <summary> |
| | | /// 场景名称修改图标 |
| | | /// </summary> |
| | | Button btnEditSceneNameIcon; |
| | | |
| | | /// <summary> |
| | | /// 所属区域row |
| | | /// </summary> |
| | | FrameLayout belongToZoneRow; |
| | | Button btnBelongToZoneRight; |
| | | Button btnZoneName; |
| | | |
| | | Button btnAddFunctionTitle; |
| | |
| | | bodyView = this; |
| | | scene = s; |
| | | backAction = act; |
| | | |
| | | |
| | | refreshFunctionRowAction = () => { |
| | | LoadFunctionRow(functionListView); |
| | | }; |
| | | } |
| | | |
| | | public void LoadPage(int titleId,Action backRefresh) |
| | | { |
| | | pageTitleId = titleId; |
| | | new TopViewDiv(bodyView, Language.StringByID(pageTitleId)).LoadTopView(backRefresh); |
| | | initPage(); |
| | | } |
| | | |
| | | public void LoadPage(int titleId) |
| | | { |
| | | refreshFunctionRowAction = () => { |
| | | LoadFunctionRow(functionListView); |
| | | }; |
| | | |
| | | bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | pageTitleId = titleId; |
| | | new TopViewDiv(bodyView, Language.StringByID(pageTitleId)).LoadTopView(); |
| | | initPage(); |
| | | } |
| | | |
| | | void initPage() |
| | | { |
| | | bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; |
| | | |
| | | VerticalScrolViewLayout contentView = new VerticalScrolViewLayout() |
| | | { |
| | |
| | | Height = Application.GetRealHeight(603-50), |
| | | }; |
| | | bodyView.AddChidren(contentView); |
| | | |
| | | Button btnBaseInfoText = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Height = Application.GetRealWidth(46), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextID = StringId.BaseInfo, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | }; |
| | | contentView.AddChidren(btnBaseInfoText); |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealWidth(12) }); |
| | | |
| | | FrameLayout sceneBgView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = btnBaseInfoText.Bottom, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealWidth(184), |
| | | Width = Application.GetRealWidth(252), |
| | | Height = Application.GetRealWidth(188 + 24), |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | }; |
| | |
| | | }; |
| | | sceneBgView.AddChidren(addSceneImageView); |
| | | |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealWidth(16) ,BackgroundColor = CSS_Color.MainBackgroundColor}); |
| | | |
| | | #region 场景名称row |
| | | FrameLayout sceneNameView = new FrameLayout() |
| | | sceneNameView = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealWidth(50), |
| | | }; |
| | |
| | | }; |
| | | sceneNameView.AddChidren(btnSceneTitle); |
| | | |
| | | etSceneName = new EditText() |
| | | btnEditSceneNameIcon = new Button() |
| | | { |
| | | X = btnSceneTitle.Right, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.TextualColor, |
| | | X = Application.GetRealWidth(333), |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetMinRealAverage(28), |
| | | Height = Application.GetMinRealAverage(28), |
| | | UnSelectedImagePath = "Public/EditIcon.png", |
| | | }; |
| | | sceneNameView.AddChidren(btnEditSceneNameIcon); |
| | | |
| | | btnSceneName = new Button() |
| | | { |
| | | X = Application.GetRealWidth(100), |
| | | Width = Application.GetRealWidth(230), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | Text = scene.name |
| | | }; |
| | | sceneNameView.AddChidren(etSceneName); |
| | | sceneNameView.AddChidren(btnSceneName); |
| | | |
| | | Button btnSceneNameLine = new Button() |
| | | { |
| | |
| | | #endregion |
| | | |
| | | #region 所属区域row |
| | | FrameLayout belongToZoneRow = new FrameLayout() |
| | | belongToZoneRow = new FrameLayout() |
| | | { |
| | | Y = sceneNameView.Bottom, |
| | | Height = Application.GetRealWidth(50), |
| | |
| | | }; |
| | | belongToZoneRow.AddChidren(btnBelongToTitle); |
| | | |
| | | Button btnBelongToZoneRight = new Button() |
| | | btnBelongToZoneRight = new Button() |
| | | { |
| | | X = Application.GetRealWidth(339), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | |
| | | btnZoneName = new Button() |
| | | { |
| | | X = btnSceneTitle.Right, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.TextualColor, |
| | | X = Application.GetRealWidth(100), |
| | | Width = Application.GetRealWidth(230), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | Text = scene.GetRoomListName() == "" ? Language.StringByID(StringId.WholeHouseScene) : scene.GetRoomListName() |
| | | }; |
| | |
| | | |
| | | btnComplete = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(667-50), |
| | | Y = Application.GetRealHeight(667 - 50), |
| | | Height = Application.GetRealHeight(50), |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = CSS_Color.MainColor, |
| | | TextColor = pageTitleId == StringId.NewScene ? CSS_Color.MainColor : CSS_Color.WarningColor, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextID = StringId.Complete, |
| | | TextID = pageTitleId == StringId.NewScene ? StringId.Complete : StringId.Del, |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | IsBold = true |
| | | //IsBold = true |
| | | }; |
| | | bodyView.AddChidren(btnComplete); |
| | | |
| | |
| | | }; |
| | | |
| | | |
| | | Button btnDelSceneFunction = new Button() { |
| | | BackgroundColor = CSS_Color.WarningColor, |
| | | TextColor = CSS_Color.MainBackgroundColor, |
| | | TextID = StringId.Del, |
| | | }; |
| | | row.AddRightView(btnDelSceneFunction); |
| | | btnDelSceneFunction.MouseUpEventHandler = (sender, e) => { |
| | | scene.sceneFunctionList.Remove(function); |
| | | scene.SaveFunctionData(); |
| | | row.RemoveFromParent(); |
| | | functionListView.Height = Application.GetRealWidth(65 * scene.sceneFunctionList.Count); |
| | | //LoadFunctionRow(functionListView); |
| | | }; |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | if (sceneFunction.trait_on_off.value.ToString() == "off") |
| | | return sceneFunctionInfo; |
| | | sceneFunctionInfo = ""; |
| | | switch(sceneFunction.functionType) |
| | | Trait perTrait; |
| | | |
| | | switch (sceneFunction.functionType) |
| | | { |
| | | case FunctionType.AC: |
| | | var addAC = sceneFunction as AC; |
| | |
| | | sceneFunction.function.Find((obj) => obj.name == "temperature").uintString; |
| | | break; |
| | | case FunctionType.Dimmer: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Brightness) + " " + sceneFunction.function.Find((obj) => obj.name == "brightness").value.ToString() + "%"; |
| | | perTrait = sceneFunction.function.Find((obj) => obj.name == "percent"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.function.Find((obj) => obj.name == "brightness").value.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | case FunctionType.Relay: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | break; |
| | | case FunctionType.RGB: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Brightness) + " " + sceneFunction.function.Find((obj) => obj.name == "brightness").value.ToString() + "%"; |
| | | perTrait = sceneFunction.function.Find((obj) => obj.name == "percent"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.function.Find((obj) => obj.name == "brightness").value.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | case FunctionType.Curtain: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | break; |
| | | case FunctionType.MotorCurtain: |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.function.Find((obj) => obj.name == "percent").value.ToString() + "%"; |
| | | perTrait = sceneFunction.function.Find((obj) => obj.name == "percent"); |
| | | if (perTrait != null) |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.function.Find((obj) => obj.name == "percent").value.ToString() + "%"; |
| | | } |
| | | else |
| | | { |
| | | sceneFunctionInfo += Language.StringByID(StringId.Open); |
| | | } |
| | | break; |
| | | } |
| | | return sceneFunctionInfo; |
| | |
| | | }; |
| | | optionView.AddChidren(btnDefaultGallery); |
| | | |
| | | optionView.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor }); |
| | | optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor }); |
| | | |
| | | btnTakePicture = new Button() |
| | | { |
| | |
| | | LoadEvent_ChangeSceneZone(); |
| | | LoadEvent_ChangeFunctionList(); |
| | | LoadEvent_CompleteEvent(); |
| | | LoadEvent_EditRoomName(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | void LoadEvent_ChangeSceneZone() |
| | | { |
| | | btnZoneName.MouseUpEventHandler = (sender, e) => |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | Action backAction = () => { |
| | | btnZoneName.Text = scene.GetRoomListName(); |
| | |
| | | ssl.LoadPage(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | btnZoneName.MouseUpEventHandler = eventHandler; |
| | | belongToZoneRow.MouseUpEventHandler = eventHandler; |
| | | btnBelongToZoneRight.MouseUpEventHandler = eventHandler; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | scene.ImagePath = addSceneImageView.ImagePath; |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | } |
| | | }, pid.ToString(), 16, 9); |
| | | scene.SaveFunctionData(); |
| | | }, pid.ToString(), 4, 3); |
| | | if (pageTitleId == StringId.EditScene) |
| | | { |
| | | scene.SaveFunctionData(); |
| | | } |
| | | pictureOptionView.Parent.RemoveFromParent(); |
| | | }; |
| | | btnAlbum.MouseDownEventHandler = (sender, e) => { |
| | |
| | | scene.ImagePath = addSceneImageView.ImagePath; |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | } |
| | | }, pid.ToString(), 16, 9); |
| | | }, pid.ToString(), 4, 3); |
| | | if (pageTitleId == StringId.EditScene) |
| | | { |
| | | scene.SaveFunctionData(); |
| | | } |
| | | pictureOptionView.Parent.RemoveFromParent(); |
| | | }; |
| | | |
| | | btnDefaultGallery.MouseUpEventHandler = (sender, e) => { |
| | | pictureOptionView.Parent.RemoveFromParent(); |
| | | Action<string> action = (obj) => { |
| | | scene.ImagePath = obj; |
| | | addSceneImageView.ImagePath = scene.ImagePath; |
| | | if (pageTitleId == StringId.EditScene) |
| | | { |
| | | scene.SaveFunctionData(); |
| | | } |
| | | }; |
| | | |
| | | var galleryPage = new GalleryPage(scene.ImagePath,action); |
| | | MainPage.BasePageView.AddChidren(galleryPage); |
| | | galleryPage.LoadPage(true); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 按钮按钮点击事件 |
| | | /// 完成按钮点击事件 |
| | | /// </summary> |
| | | void LoadEvent_CompleteEvent() |
| | | { |
| | | btnComplete.MouseUpEventHandler = (sender, e) => |
| | | btnComplete.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | scene.SaveFunctionData(); |
| | | DB_ResidenceData.functionList.scenes.Add(scene); |
| | | this.RemoveFromParent(); |
| | | backAction(); |
| | | if (btnComplete.TextID == StringId.Complete) |
| | | { |
| | | if (string.IsNullOrEmpty(scene.name)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | foreach (var tempRoom in DB_ResidenceData.functionList.scenes) |
| | | { |
| | | if (scene.name == tempRoom.name) |
| | | { |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); |
| | | return; |
| | | } |
| | | } |
| | | scene.SaveFunctionData(); |
| | | DB_ResidenceData.functionList.scenes.Add(scene); |
| | | backAction(); |
| | | this.RemoveFromParent(); |
| | | } |
| | | if (btnComplete.TextID == StringId.Del) |
| | | { |
| | | Action action = () => |
| | | { |
| | | DB_ResidenceData.DelSceneFunction(scene.sid); |
| | | backAction(); |
| | | this.RemoveFromParent(); |
| | | }; |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.DeleteSceneTip, action); |
| | | }; |
| | | }; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 加载修改场景名称窗口事件 |
| | | /// </summary> |
| | | void LoadEvent_EditRoomName() |
| | | { |
| | | Action<string> callBack = (str) => |
| | | { |
| | | //名称不能为空 |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | btnSceneName.Text = str; |
| | | scene.name = str; |
| | | if (pageTitleId == StringId.EditScene) |
| | | { |
| | | scene.SaveFunctionData(); |
| | | } |
| | | }; |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | List<string> sceneNameList = new List<string>(); |
| | | foreach (var tempScene in DB_ResidenceData.functionList.scenes) |
| | | { |
| | | sceneNameList.Add(tempScene.name); |
| | | } |
| | | new PublicAssmebly().LoadDialog_EditParater(StringId.SceneName, scene.name, callBack, StringId.SceneNameCannotBeEmpty, StringId.SceneNameAlreadyExists, sceneNameList); |
| | | }; |
| | | sceneNameView.MouseUpEventHandler = eventHandler; |
| | | btnSceneName.MouseUpEventHandler = eventHandler; |
| | | btnEditSceneNameIcon.MouseUpEventHandler = eventHandler; |
| | | } |
| | | |
| | | } |
| | | } |