using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; using System; using System.Collections.Generic; using System.Text; namespace HDL_ON.Stan { /// <summary> /// 设备功能å¡ç‰‡çš„åº•å±‚ç•Œé¢ /// </summary> public class DeviceFunctionCardCommonForm : EditorCommonForm { #region â– å˜é‡å£°æ˜Ž___________________________ /// <summary> /// 当å‰å›žè·¯å¯¹è±¡ /// </summary> public Function device = null; /// <summary> /// å³ä¸Šè§’é…置结æŸçš„事件 /// </summary> public Action SettionFinishEvent = null; /// <summary> /// å·¦å³ç¿»é¡µçš„æŽ§ä»¶çš„事件 /// </summary> public Action<int> PageChangeEvent = null; /// <summary> /// 左峿•´ä¸ªç¿»é¡µçš„æŽ§ä»¶ /// </summary> private PageLayout pageLayout = null; /// <summary> /// 设备å嗿ާ件(刷新用到) /// </summary> public NormalViewControl btnDeviceName = null; /// <summary> /// 房间å嗿ާ件(刷新用到) /// </summary> public NormalViewControl btnRoomName = null; /// <summary> /// åº•éƒ¨å¿«æ·æŒ‰é’®1 /// </summary> private NormalViewControl btnBottomOne = null; /// <summary> /// åº•éƒ¨å¿«æ·æŒ‰é’®2 /// </summary> private NormalViewControl btnBottomTwo = null; /// <summary> /// 第一索引的白色区域的桌布控件 /// </summary> public NormalFrameLayout FrameWhiteCentet1 = null; /// <summary> /// 第二索引的白色区域的桌布控件(请先调用AddSecondPageå‡½æ•°å®Œæˆæ·»åŠ ) /// </summary> public NormalFrameLayout FrameWhiteCentet2 = null; /// <summary> /// æ˜¯å¦æ˜¾ç¤ºæ”¶è—按钮 /// </summary> public bool ShowColltionButton = true; #endregion #region â– åˆå§‹åŒ–_____________________________ /// <summary> /// ç”»é¢æ˜¾ç¤º(åº•å±‚ä¼šå›ºå®šè°ƒç”¨æ¤æ–¹æ³•,借以完æˆç”»é¢åˆ›å»º) /// </summary> /// <param name="i_device">设备对象</param> /// <param name="btnHigherCollection">上一级界é¢çš„æ”¶è—控件(原æ¥on的框架太å‘)</param> /// <param name="btnHigherDeviceName">上一级界é¢çš„设备å嗿ާ件(原æ¥on的框架太å‘)</param> /// <param name="btnHigherRoom">上一级界é¢çš„æˆ¿é—´å嗿ާ件(原æ¥on的框架太å‘)</param> public void ShowForm(Function i_device, Button btnHigherCollection, Button btnHigherDeviceName, Button btnHigherRoom) { this.device = i_device; //æ·»åŠ å¤´éƒ¨ã€è®¾ç½®ã€‘å›¾æ ‡ this.AddTopSettingIcon(btnHigherDeviceName, btnHigherRoom); //åˆå§‹åŒ–ä¸éƒ¨ä¿¡æ¯ this.InitMiddleFrame(btnHigherCollection); } /// <summary> /// åˆå§‹åŒ–ä¸éƒ¨ä¿¡æ¯ /// </summary> /// <param name="btnHigherCollection">上一级界é¢çš„æ”¶è—控件</param> private void InitMiddleFrame(Button btnHigherCollection) { //清空bodyFrame this.ClearBodyFrame(); //左峿•´ä¸ªç¿»é¡µçš„æŽ§ä»¶ this.pageLayout = new PageLayout(); pageLayout.IsShowPoint = false; pageLayout.ScrollEnabled = false; bodyFrameLayout.AddChidren(pageLayout); pageLayout.PageChange += (sender, index) => { //è®¾ç½®åº•éƒ¨ä¸¤ä¸ªæŒ‰é’®çš„çŠ¶æ€ this.SetBottomTwoButtonStatu(); this.PageChangeEvent?.Invoke(index); }; //åˆå§‹åŒ–第一个索引的桌布 this.InitFrameWhiteContent1(btnHigherCollection); //åˆå§‹åŒ–白色内容(需è¦è‡ªä¸»å®žçް) this.InitFrameWhiteContent(); } /// <summary> /// åˆå§‹åŒ–第一个索引的桌布 /// </summary> /// <param name="btnHigherCollection">上一级界é¢çš„æ”¶è—控件</param> private void InitFrameWhiteContent1(Button btnHigherCollection) { //第一个索引桌布是必定å˜åœ¨çš„ var frameTable1 = new FrameLayout(); frameTable1.Width = pageLayout.Width; frameTable1.Height = pageLayout.Height; pageLayout.AddChidren(frameTable1); //第一个索引的白色桌布 this.FrameWhiteCentet1 = new NormalFrameLayout(); FrameWhiteCentet1.Gravity = Gravity.CenterHorizontal; FrameWhiteCentet1.Y = Application.GetRealHeight(22); FrameWhiteCentet1.Width = Application.GetRealWidth(327); FrameWhiteCentet1.Height = Application.GetRealHeight(526); FrameWhiteCentet1.BackgroundImagePath = "Public/Fragmentbg.png"; frameTable1.AddChidren(FrameWhiteCentet1); //设备åå— this.btnDeviceName = new NormalViewControl(270, 37, true); btnDeviceName.X = Application.GetRealWidth(16); btnDeviceName.Y = Application.GetRealHeight(18); btnDeviceName.TextColor = CSS_Color.FirstLevelTitleColor; btnDeviceName.TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel; btnDeviceName.Text = device.name; btnDeviceName.Width = btnDeviceName.GetRealWidthByText(); FrameWhiteCentet1.AddChidren(btnDeviceName); //房间åå— this.btnRoomName = new NormalViewControl(270, 21, true); btnRoomName.X = Application.GetRealWidth(16); btnRoomName.Y = btnDeviceName.Bottom; btnRoomName.TextColor = CSS_Color.PromptingColor1; btnRoomName.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; btnRoomName.Text = device.GetRoomListName(); btnRoomName.Width = btnRoomName.GetRealWidthByText(); FrameWhiteCentet1.AddChidren(btnRoomName); if (ShowColltionButton) { var btnCollection = new IconViewControl(40); btnCollection.X = Application.GetRealWidth(273); btnCollection.Y = Application.GetRealHeight(16); btnCollection.SelectedImagePath = "Collection/CollectionIcon.png"; btnCollection.UnSelectedImagePath = "Collection/CollectionGrayIcon.png"; btnCollection.IsSelected = device.collect; FrameWhiteCentet1.AddChidren(btnCollection); btnCollection.ButtonClickEvent += (sender, e) => { btnCollection.IsSelected = !btnCollection.IsSelected; device.collect = btnCollection.IsSelected; btnHigherCollection.IsSelected = device.collect; device.CollectFunction(); }; } } /// <summary> /// åˆå§‹åŒ–第二个索引的桌布 /// </summary> private void InitFrameWhiteContent2() { this.pageLayout.ScrollEnabled = true; //第一个索引桌布是必定å˜åœ¨çš„ var frameTable2 = new FrameLayout(); frameTable2.Width = pageLayout.Width; frameTable2.Height = pageLayout.Height; pageLayout.AddChidren(frameTable2); //第一个索引的白色桌布 this.FrameWhiteCentet2 = new NormalFrameLayout(); FrameWhiteCentet2.Gravity = Gravity.CenterHorizontal; FrameWhiteCentet2.Y = Application.GetRealHeight(22); FrameWhiteCentet2.Width = Application.GetRealWidth(327); FrameWhiteCentet2.Height = Application.GetRealHeight(526); FrameWhiteCentet2.BackgroundImagePath = "Public/Fragmentbg.png"; frameTable2.AddChidren(FrameWhiteCentet2); } /// <summary> /// åˆå§‹åŒ–白色内容(需è¦è‡ªä¸»å®žçް) /// </summary> public virtual void InitFrameWhiteContent() { } #endregion #region â– æ·»åŠ ç¬¬äºŒç´¢å¼•é¡µ_____________________ /// <summary> /// æ·»åŠ ç¬¬äºŒç´¢å¼•é¡µ /// </summary> public void AddSecondPage() { //åˆå§‹åŒ–第二个索引的桌布 this.InitFrameWhiteContent2(); //åº•éƒ¨æ·»åŠ ä¸¤ä¸ªæŒ‰é’® this.btnBottomOne = new NormalViewControl(14, 6, true); btnBottomOne.X = Application.GetRealWidth(170); btnBottomOne.Y = FrameWhiteCentet1.Bottom + Application.GetRealHeight(30); btnBottomOne.BackgroundColor = CSS_Color.MainColor; btnBottomOne.Radius = (uint)Application.GetRealHeight(6) / 2; bodyFrameLayout.AddChidren(btnBottomOne); btnBottomOne.ButtonClickEvent += (sender, e) => { this.pageLayout.PageIndex = 0; //è®¾ç½®åº•éƒ¨ä¸¤ä¸ªæŒ‰é’®çš„çŠ¶æ€ this.SetBottomTwoButtonStatu(); if (this.FrameWhiteCentet2 != null && this.pageLayout.ScrollEnabled == false) { this.pageLayout.ScrollEnabled = true; } }; this.btnBottomTwo = new NormalViewControl(14, 6, true); btnBottomTwo.X = btnBottomOne.Right + Application.GetRealWidth(8); btnBottomTwo.Y = btnBottomOne.Y; btnBottomTwo.BackgroundColor = 0xffadc7f7; btnBottomTwo.Radius = (uint)Application.GetRealHeight(6) / 2; bodyFrameLayout.AddChidren(btnBottomTwo); btnBottomTwo.ButtonClickEvent += (sender, e) => { this.pageLayout.PageIndex = 1; //è®¾ç½®åº•éƒ¨ä¸¤ä¸ªæŒ‰é’®çš„çŠ¶æ€ this.SetBottomTwoButtonStatu(); if (this.FrameWhiteCentet2 != null && this.pageLayout.ScrollEnabled == false) { this.pageLayout.ScrollEnabled = true; } }; } /// <summary> /// è®¾ç½®åº•éƒ¨ä¸¤ä¸ªæŒ‰é’®çš„çŠ¶æ€ /// </summary> private void SetBottomTwoButtonStatu() { if (this.btnBottomTwo == null) { return; } if (this.pageLayout.PageIndex == 1) { this.btnBottomOne.BackgroundColor = 0xffadc7f7; this.btnBottomTwo.BackgroundColor = CSS_Color.MainColor; } else { this.btnBottomOne.BackgroundColor = CSS_Color.MainColor; this.btnBottomTwo.BackgroundColor = 0xffadc7f7; } } #endregion #region ■界é¢å…³é—___________________________ /// <summary> /// 界é¢å…³é— /// </summary> public override void CloseFormBefore() { base.CloseFormBefore(); this.SettionFinishEvent = null; this.PageChangeEvent = null; } #endregion #region ■一般方法___________________________ /// <summary> /// 获å–头部å³è¾¹çš„ã€è®¾ç½®ã€‘å›¾æ ‡æŽ§ä»¶ /// </summary> /// <returns></returns> public PicViewControl GetTopSettingIcon() { for (int i = 0; i < topFrameLayout.ChildrenCount; i++) { var myView = topFrameLayout.GetChildren(i); if (myView == null || myView.Name != "btnSetting") { continue; } return myView as PicViewControl; } return null; } /// <summary> /// æ·»åŠ å¤´éƒ¨ã€è®¾ç½®ã€‘çš„å›¾æ ‡ /// </summary> /// <param name="btnHigherCollection">上一级界é¢çš„æ”¶è—控件(原æ¥on的框架太å‘)</param> /// <param name="btnHigherDeviceName">上一级界é¢çš„设备å嗿ާ件(原æ¥on的框架太å‘)</param> private void AddTopSettingIcon(Button btnHigherDeviceName, Button btnHigherRoom) { //è®¾ç½®å›¾æ ‡(é—¨é”界é¢éœ€è¦å€Ÿç”¨è¿™ä¸ªå›¾æ ‡çš„Xè½´å’ŒYè½´,æ‰€ä»¥åŠ è¿›æ¥) var btnSetting = new PicViewControl(28, 28); btnSetting.X = Application.GetRealWidth(337); btnSetting.Y = Application.GetRealHeight(9); btnSetting.UnSelectedImagePath = "Public/FuncInfoSetIcon.png"; btnSetting.Name = "btnSetting"; topFrameLayout.AddChidren(btnSetting); //如果是æˆå‘˜æ²¡æœ‰åŠŸèƒ½ if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == true) { btnSetting.Visible = false; } btnSetting.ButtonClickEvent += (sender, e) => { var infoView = new UI.FunctionBaseInfoSetPage(this.device, () => { //刷新显示 btnHigherDeviceName.Text = this.device.name; btnHigherRoom.Text = this.device.GetRoomListName(); //从新计算宽度 this.btnDeviceName.Text = btnHigherDeviceName.Text; this.btnDeviceName.Width = this.btnDeviceName.GetRealWidthByText(); this.btnRoomName.Text = btnHigherRoom.Text; this.btnRoomName.Width = this.btnRoomName.GetRealWidthByText(); //回调事件 this.SettionFinishEvent?.Invoke(); }); MainPage.BasePageView.AddChidren(infoView); infoView.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } #endregion } }