| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.Entity; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | | public class HomePage : FrameLayout |
| | | public partial class HomePage : FrameLayout |
| | | { |
| | | |
| | | #region 控件列表 |
| | | FrameLayout bodyView; |
| | | static FrameLayout bodyView; |
| | | /// <summary> |
| | | /// 顶部信息区域 |
| | | /// </summary> |
| | |
| | | /// 当前pm2.5状态 |
| | | /// </summary> |
| | | Button btnPm25Values; |
| | | /// <summary> |
| | | /// 灯光区域集合 |
| | | /// </summary> |
| | | static Dictionary<string, FrameLayout> LightViews; |
| | | /// <summary> |
| | | /// 空调区域集合 |
| | | /// </summary> |
| | | static Dictionary<string, FrameLayout> AcViews; |
| | | /// <summary> |
| | | /// 窗帘区域集合 |
| | | /// </summary> |
| | | static Dictionary<string, FrameLayout> CurtainViews; |
| | | #endregion |
| | | |
| | | public HomePage() |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealHeight(28), |
| | | }; |
| | | topView.AddChidren(msgView); |
| | | |
| | | var btngb = new Button() |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.MainColor,//0x3F4484F4,// |
| | | Alpha = 0.4f, |
| | | }; |
| | | topView.AddChidren(msgView); |
| | | msgView.AddChidren(btngb); |
| | | |
| | | Button btnMsgIcon; |
| | | btnMsgIcon = new Button() |
| | |
| | | btnChangeFunction = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(114), |
| | | TextID = InternationalizationString.Functions, |
| | | TextID = StringId.Functions, |
| | | SelectedTextColor = CSS.CSS_Color.MainColor, |
| | | TextColor = CSS.CSS_Color.PromptingColor1, |
| | | //TextSize = CSS.CSS_FontSize.TextFontSize, |
| | |
| | | { |
| | | X = btnChangeFunction.Right, |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetRealWidth(2), |
| | | Width = Application.GetRealWidth(1), |
| | | Height = Application.GetRealHeight(14), |
| | | BackgroundColor = CSS.CSS_Color.PromptingColor1, |
| | | }; |
| | |
| | | { |
| | | X = btnLine.Right, |
| | | Width = Application.GetRealWidth(114), |
| | | TextID = InternationalizationString.Scenes, |
| | | TextID = StringId.Scenes, |
| | | SelectedTextColor = CSS.CSS_Color.MainColor, |
| | | TextColor = CSS.CSS_Color.PromptingColor1, |
| | | TextSize = CSS.CSS_FontSize.TextFontSize, |
| | |
| | | contextView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = changeView.Bottom + Application.GetRealHeight(10), |
| | | Height = Application.GetRealHeight(340 + 30), //20为超出部分 |
| | | Height = Application.GetRealHeight(310 + 30), //20为超出部分 |
| | | }; |
| | | bodyView.AddChidren(contextView); |
| | | |
| | | var lightViews = new Dictionary<string, FrameLayout>(); |
| | | var acViews = new Dictionary<string, FrameLayout>(); |
| | | var curtainViews = new Dictionary<string, FrameLayout>(); |
| | | FrameLayout rowView = new FrameLayout(); |
| | | LightViews = new Dictionary<string, FrameLayout>(); |
| | | AcViews = new Dictionary<string, FrameLayout>(); |
| | | CurtainViews = new Dictionary<string, FrameLayout>(); |
| | | var rowView = new FrameLayout(); |
| | | |
| | | foreach (var function in DB_ResidenceData.residenceData.functions) |
| | | { |
| | |
| | | }; |
| | | contextView.AddChidren(rowView); |
| | | } |
| | | |
| | | var functionView_X = Application.GetRealWidth((182 + 7) * (index % 2)); |
| | | if (index % 2 == 0) |
| | | { |
| | | functionView_X += 7; |
| | | } |
| | | var functionView = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth((182 + 7) * (index % 2)), |
| | | X = functionView_X, |
| | | Width = Application.GetRealWidth(182), |
| | | Height = Application.GetRealHeight(140), |
| | | Tag = function.sid |
| | | }; |
| | | rowView.AddChidren(functionView); |
| | | var btnbg = new Button() |
| | |
| | | { |
| | | case FunctionType.Light: |
| | | #region 灯光 Light |
| | | lightViews.Add(function.sid, functionView); |
| | | LightViews.Add(function.sid, functionView); |
| | | #endregion |
| | | break; |
| | | case FunctionType.Curtain: |
| | | #region 窗帘 |
| | | curtainViews.Add(function.sid, functionView); |
| | | CurtainViews.Add(function.sid, functionView); |
| | | #endregion |
| | | break; |
| | | case FunctionType.AC: |
| | | #region 空调 AC |
| | | acViews.Add(function.sid, functionView); |
| | | AcViews.Add(function.sid, functionView); |
| | | #endregion |
| | | break; |
| | | |
| | |
| | | LoadControlView(functionView, function); |
| | | } |
| | | |
| | | |
| | | contextView.AddChidren(new Button { Height = Application.GetRealHeight(30) }); |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 加载控制卡片 |
| | |
| | | { |
| | | X = Application.GetRealWidth(21), |
| | | Y = Application.GetRealHeight(10) + btnIcon.Bottom, |
| | | Text = function.Name, |
| | | Text = function.name, |
| | | IsBold = true, |
| | | TextColor = CSS.CSS_Color.PromptingColor1, |
| | | TextColor = CSS.CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS.CSS_FontSize.TextFontSize, |
| | | Height = Application.GetRealHeight(24), |
| | | Width = Application.GetRealWidth(140), |
| | |
| | | Y = btnZone.Bottom, |
| | | Height = Application.GetRealHeight(18), |
| | | Width = Application.GetRealWidth(113), |
| | | TextColor = CSS.CSS_Color.PromptingColor1, |
| | | SelectedTextColor = CSS.CSS_Color.MainBackgroundColor, |
| | | TextColor = 0x00000000, |
| | | TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Tag = "state", |
| | | Text = function.lastState |
| | | }; |
| | | view.AddChidren(btnState); |
| | |
| | | Width = Application.GetMinRealAverage(24), |
| | | Height = Application.GetMinRealAverage(24), |
| | | UnSelectedImagePath = "Collection/CollectionIcon.png", |
| | | SelectedImagePath = "Collection/CollectionOnIcon.png", |
| | | SelectedImagePath = "Collection/CollectionIcon.png", |
| | | }; |
| | | view.AddChidren(btnCollection); |
| | | |
| | |
| | | { |
| | | X = Application.GetRealWidth(122), |
| | | Y = Application.GetRealHeight(92), |
| | | Width = Application.GetRealWidth(48), |
| | | Height = Application.GetRealHeight(36), |
| | | Width = Application.GetMinRealAverage(48), |
| | | Height = Application.GetMinRealAverage(36), |
| | | UnSelectedImagePath = "Collection/Switch.png", |
| | | SelectedImagePath = "Collection/SwitchOn.png", |
| | | }; |
| | | view.AddChidren(btnSwitch); |
| | | |
| | | |
| | | switch (function.funcType) |
| | | { |
| | |
| | | btnIcon.SelectedImagePath = "Public/FunctionIcon/LightOnIcon.png"; |
| | | |
| | | btnSwitch.MouseUpEventHandler += (sender, e) => { |
| | | var jsonString = new JObject { { "Namespace", "HDL" }, { "Command", "write" }, { "Type", "device" } }; |
| | | var data = new JObject { { "Switch", 1 }, { "Dimmer", 100 }, { "sid", "0001002019101209000025670400010001" } }; |
| | | jsonString.Add("objects", data); |
| | | Control.Send(jsonString, function, 3); |
| | | var curState = !btnSwitch.IsSelected; |
| | | for (int i = 0; i < view.ChildrenCount; i++) |
| | | { |
| | | if (view.GetChildren(i).GetType() == typeof(Button)) |
| | | { |
| | | var btn = view.GetChildren(i) as Button; |
| | | btn.IsSelected = curState; |
| | | } |
| | | } |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var light = function as Light; |
| | | light.state = btnSwitch.IsSelected ? 1 : 0; |
| | | Control.Send("write", function, 3); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | #endregion |
| | | break; |
| | | |
| | | case FunctionType.Curtain: |
| | | #region 窗帘 |
| | | btnIcon.UnSelectedImagePath = "Public/FunctionIcon/CurtainIcon.png"; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |