using System; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public partial class IntelligencePage : FrameLayout { FrameLayout bodyView; /// /// 场景/自动化分页区域 /// PageLayout contentPageView; #region 场景区域 FrameLayout scenePageView; /// /// 场景内容显示区域 /// FrameLayout floorChangeView; #region 场景底部切换显示区域 /// /// 场景区域,顶部区域 /// FrameLayout sceneTopView; /// /// 楼层选择下拉图标 /// Button btnFloorDownIcon; /// /// 楼层显示 /// Button btnFloor; /// /// 添加场景按钮 /// Button btnAddIcon; #endregion /// /// 场景功能控制区域 /// VerticalScrolViewLayout sceneFunctionView; #endregion public IntelligencePage() { bodyView = this; } public void LoadPage() { bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; #region top FrameLayout topView = new FrameLayout() { Height = Application.GetRealHeight(64), BackgroundColor = CSS_Color.TopViewColor, }; bodyView.AddChidren(topView); Button btnSceneTilte = new Button() { Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(170), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.HeadlineFontSize, TextColor = CSS_Color.PromptingColor1, SelectedTextColor = CSS_Color.MainColor, TextID = StringId.Scenes, IsSelected = true }; topView.AddChidren(btnSceneTilte); Button btnAutomationTitle = new Button() { X = Application.GetRealWidth(209), Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(170), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.PromptingColor1, SelectedTextColor = CSS_Color.MainColor, TextID = StringId.Automation, }; topView.AddChidren(btnAutomationTitle); btnAddIcon = new Button() { X = Application.GetRealWidth(337), Y = Application.GetRealHeight(29), Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "Public/AddIcon.png", }; topView.AddChidren(btnAddIcon); #endregion contentPageView = new PageLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(667 - 64 - 49 + 30), BackgroundColor = CSS_Color.BackgroundColor, IsShowPoint = false }; bodyView.AddChidren(contentPageView); LoadScenePageView(); //LoadFunctionPageView(); LoadEventList(); } /// /// 加载场景列表界面 /// void LoadScenePageView() { scenePageView = new FrameLayout(); contentPageView.AddChidren(scenePageView); /// /// 场景内容显示区域 /// floorChangeView = new FrameLayout() { Height = Application.GetRealHeight(52), }; scenePageView.AddChidren(floorChangeView); #region 场景底部切换显示区域 /// /// 场景区域,顶部区域 /// sceneTopView = new FrameLayout() { Height = Application.GetRealHeight(53), }; floorChangeView.AddChidren(sceneTopView); /// /// 楼层选择下拉图标 /// btnFloorDownIcon = new Button() { Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), X = Application.GetRealWidth(16), Y = Application.GetRealHeight(18), UnSelectedImagePath = "Public/DownIcon.png", }; floorChangeView.AddChidren(btnFloorDownIcon); /// /// 楼层显示 /// btnFloor = new Button() { X = btnFloorDownIcon.Right, Y = Application.GetRealHeight(18), Width = Application.GetRealWidth(200), Height = Application.GetMinRealAverage(16), TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextAlignment = TextAlignment.CenterLeft, Text = OnAppConfig.Instance.CurFoor, }; floorChangeView.AddChidren(btnFloor); #endregion sceneFunctionView = new VerticalScrolViewLayout() { Y = floorChangeView.Bottom, Height = Application.GetRealHeight(667 - 64 - 49 - 52 + 30), }; scenePageView.AddChidren(sceneFunctionView); LoadSceneFunctionControlZone(); } /// /// 加载场景功能显示区域 /// void LoadSceneFunctionControlZone() { sceneFunctionView.RemoveAll(); var rowView = new FrameLayout(); try { int index = 0; foreach (var function in DB_ResidenceData.functionList.scenes) { if (function.roomIdList.Count == 0)//如何在房间已经移除了这个功能,则收藏界面也不会再显示 { function.collection = false; continue; } if (index % 2 == 0) { sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) }); rowView = new FrameLayout() { Height = Application.GetRealWidth(122), }; sceneFunctionView.AddChidren(rowView); sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) }); } var functionView_X = Application.GetRealWidth((16 + 164) * (index % 2) + 16); var functionView = new FrameLayout() { X = functionView_X, Width = Application.GetRealWidth(164), Height = Application.GetRealWidth(122), Tag = function.sid, BackgroundImagePath = (function as Scene).ImagePath, }; rowView.AddChidren(functionView); LoadSceneFunctionDiv(functionView, function); index++; } if (index == 0) { var view = new FrameLayout(); sceneFunctionView.AddChidren(view); var btnNoCollectionBg = new Button() { Y = Application.GetRealHeight(120), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(180), Height = Application.GetRealWidth(180), UnSelectedImagePath = "Collection/NoCollectionBg.png", }; view.AddChidren(btnNoCollectionBg); var btnNoCollectionTip = new Button() { Height = Application.GetRealHeight(42), Y = btnNoCollectionBg.Bottom, TextAlignment = TextAlignment.Center, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextID = StringId.TipNoScene, }; view.AddChidren(btnNoCollectionTip); } } catch (Exception ex) { MainPage.Log("homepage erorr : " + ex.Message); } sceneFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) }); } /// /// 加载场景控制卡片 /// void LoadSceneFunctionDiv(FrameLayout view, Function function) { try { Button btnCoverd = new Button() { UnSelectedImagePath = "Collection/SceneCovered.png", }; view.AddChidren(btnCoverd); Button btnName; btnName = new Button() { X = Application.GetRealWidth(12), Y = Application.GetRealWidth(68), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(24), Text = function.name, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.MainBackgroundColor, TextAlignment = TextAlignment.CenterLeft, }; view.AddChidren(btnName); Button btnZone; btnZone = new Button() { X = Application.GetRealWidth(12), Y = btnName.Bottom, Height = Application.GetRealWidth(18), Width = Application.GetRealWidth(113), TextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, TextAlignment = TextAlignment.CenterLeft, SelectedTextColor = CSS_Color.MainBackgroundColor, Text = function.GetRoomListName(), }; view.AddChidren(btnZone); Button btnSettingIcon; btnSettingIcon = new Button() { X = Application.GetRealWidth(4), Y = Application.GetRealWidth(4), Height = Application.GetRealWidth(32), Width = Application.GetRealWidth(32), UnSelectedImagePath = "Public/FuncInfoSetIcon_white.png", }; view.AddChidren(btnSettingIcon); Button btnCollection; btnCollection = new Button() { X = Application.GetRealWidth(116), Y = Application.GetRealWidth(8), Width = Application.GetMinRealAverage(32), Height = Application.GetMinRealAverage(32), UnSelectedImagePath = "Collection/CollectionWhiteIcon.png", SelectedImagePath = "Collection/CollectionIcon.png", IsSelected = function.collection, }; view.AddChidren(btnCollection); btnCollection.MouseUpEventHandler = (sender, e) => { function.collection = btnCollection.IsSelected = !btnCollection.IsSelected; function.SaveFunctionData(); }; LoadEvent_ControlScene(btnCoverd,btnName,btnZone, function); btnSettingIcon.MouseUpEventHandler = (sender, e) => { Action backAction = () => { LoadSceneFunctionControlZone(); }; Action refreshAction = () => { btnName.Text = function.name; btnZone.Text = function.GetRoomListName(); view.BackgroundImagePath = (function as Scene).ImagePath; }; var aep = new SceneEditPage(function as Scene, backAction); MainPage.BasePageView.AddChidren(aep); aep.LoadPage(StringId.EditScene, refreshAction); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } catch (Exception ex) { MainPage.Log("homepage LoadControlView error : " + ex.Message); } } } //------------- public partial class IntelligencePage { void LoadEventList() { LoadEvent_SkipAddScenePage(); } /// /// 跳转至添加场景的界面 /// void LoadEvent_SkipAddScenePage() { btnAddIcon.MouseUpEventHandler = (sender, e) => { Action action = () => { LoadSceneFunctionControlZone(); }; var aep = new NewSceneMenuListPage(action); MainPage.BasePageView.AddChidren(aep); aep.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } /// /// 加载场景控制事件 /// void LoadEvent_ControlScene(Button btnCoverd, Button btnName, Button btnZone, Function function) { EventHandler eventHandler = (sender, e) => { string msg = function.name + Language.StringByID(StringId.AlreadyOpened); new PublicAssmebly().TipMsgAutoClose(msg, true); Control.Send(function); }; btnCoverd.MouseUpEventHandler = eventHandler; btnName.MouseUpEventHandler = eventHandler; btnZone.MouseUpEventHandler = eventHandler; } } }