| | |
| | | /// </summary> |
| | | public void LoadFunctionDiv() |
| | | { |
| | | //todo 增加设备,增加功能列表卡片 |
| | | if (function == null) |
| | | { |
| | | this.RemoveFromParent(); |
| | |
| | | } |
| | | LoadDiv(); |
| | | |
| | | if (function.functionCategory == FunctionCategory.Curtain || function.functionCategory == FunctionCategory.Music || function.functionCategory == FunctionCategory.Scene)//窗帘没有开关按钮 |
| | | { |
| | | switch (function.functionCategory) |
| | | { |
| | | case FunctionCategory.Curtain: |
| | | switch(function.functionType) |
| | | { |
| | | case FunctionType.Curtain: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png"; |
| | | break; |
| | | case FunctionType.MotorCurtain: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/MotorCurtainIcon.png"; |
| | | break; |
| | | case FunctionType.RollingShutter: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/RollingShutterIcon.png"; |
| | | break; |
| | | } |
| | | CurtainFragment(); |
| | | break; |
| | | case FunctionCategory.Music: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png"; |
| | | MusicFragment(); |
| | | break; |
| | | btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"; |
| | | |
| | | if (SPK.CurtainSpkList().Contains(function.spk)) |
| | | {//窗帘没有开关按钮 |
| | | CurtainFragment(); |
| | | } |
| | | else if (SPK.MusicSpkList().Contains(function.spk)) |
| | | {//音乐没有开关按钮 |
| | | MusicFragment(); |
| | | } |
| | | else if (SPK.EvironmentSensorList().Contains(function.spk) || SPK.ArmSensorSpkList().Contains(function.spk)) //传感器没有开关按钮) |
| | | { |
| | | var powerLowTipAttr = function.attributes.Find((obj) => obj.key == FunctionAttributeKey.BatteryState); |
| | | if (powerLowTipAttr != null) |
| | | { |
| | | if (powerLowTipAttr.state.ToLower() == "low") |
| | | { |
| | | Button btnTipPowerLow = new Button() |
| | | { |
| | | X = Application.GetRealWidth(307), |
| | | Y = Application.GetRealHeight(25), |
| | | Width = Application.GetRealWidth(24), |
| | | Height = Application.GetRealWidth(24), |
| | | UnSelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png", |
| | | SelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png", |
| | | }; |
| | | this.AddChidren(btnTipPowerLow); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | #region 加载开关按钮 |
| | | /// <summary> |
| | | /// 开关按钮 |
| | | /// </summary> |
| | | Button btnSwitch; |
| | | if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer) |
| | | if (function.spk == SPK.ClothesHanger)//晾衣架 |
| | | { |
| | | btnSwitch = new Button() |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(78), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "Public/PowerClose.png", |
| | | SelectedImagePath = "Public/PowerOpen.png", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on", |
| | | Tag = function.sid + "_Switch", |
| | | }; |
| | | bodyDiv.AddChidren(btnSwitch); |
| | | ClothesHangerFragment(); |
| | | } |
| | | else |
| | | { |
| | | btnSwitch = new Button() |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(58), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "Public/PowerClose.png", |
| | | SelectedImagePath = "Public/PowerOpen.png", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on", |
| | | Tag = function.sid + "_Switch", |
| | | }; |
| | | bodyDiv.AddChidren(btnSwitch); |
| | | } |
| | | //加载开关按钮事件 |
| | | LoadEvent_SwitchFunction(btnSwitch); |
| | | #region 加载开关按钮 |
| | | |
| | | switch (function.functionCategory) |
| | | { |
| | | case FunctionCategory.Thermostat: |
| | | switch (function.functionType) |
| | | /// <summary> |
| | | /// 开关按钮 |
| | | /// </summary> |
| | | Button btnSwitch; |
| | | if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming) |
| | | { |
| | | btnSwitch = new Button() |
| | | { |
| | | case FunctionType.AC: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png"; |
| | | LoadLastStatesButton(); |
| | | break; |
| | | case FunctionType.FloorHeating: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png"; |
| | | LoadLastStatesButton(); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Light: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png"; |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(78), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "Public/PowerClose.png", |
| | | SelectedImagePath = "Public/PowerOpen.png", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on", |
| | | Tag = function.sid + "_Switch", |
| | | }; |
| | | bodyDiv.AddChidren(btnSwitch); |
| | | //加载开关按钮事件 |
| | | LoadEvent_SwitchFunction(btnSwitch, function.attributes.Find((obj) => obj.key == FunctionAttributeKey.FadeTime)); |
| | | } |
| | | else |
| | | { |
| | | btnSwitch = new Button() |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(58), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "Public/PowerClose.png", |
| | | SelectedImagePath = "Public/PowerOpen.png", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on", |
| | | Tag = function.sid + "_Switch", |
| | | }; |
| | | bodyDiv.AddChidren(btnSwitch); |
| | | //加载开关按钮事件 |
| | | LoadEvent_SwitchFunction(btnSwitch); |
| | | } |
| | | |
| | | if (SPK.AcSpkList().Contains(function.spk) || |
| | | SPK.FhSpkList().Contains(function.spk)) |
| | | { |
| | | LoadLastStatesButton(); |
| | | } |
| | | else if (SPK.LightSpkList().Contains(function.spk)) |
| | | { |
| | | btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on"; |
| | | LoadLightControl(); |
| | | break; |
| | | case FunctionCategory.SwitchDevice: |
| | | switch (function.functionType) |
| | | { |
| | | case FunctionType.Socket: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png"; |
| | | break; |
| | | } |
| | | } |
| | | else if (SPK.ElectricalSpkList().Contains(function.spk)) |
| | | { |
| | | btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on"; |
| | | break; |
| | | case FunctionCategory.Electrical: |
| | | switch (function.functionType) |
| | | { |
| | | case FunctionType.Fan: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png"; |
| | | break; |
| | | case FunctionType.TV: |
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png"; |
| | | break; |
| | | } |
| | | btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on"; |
| | | break; |
| | | } |
| | | #endregion |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | if (function.functionCategory != FunctionCategory.Scene) |
| | | { |
| | | LoadEvent_DivSkipEvent(); |
| | | } |
| | | LoadEvent_DivSkipEvent(); |
| | | LoadEvent_FunctionCollection(); |
| | | } |
| | | |
| | |
| | | UnSelectedImagePath = "Collection/CollectionGrayIcon.png", |
| | | IsSelected = function.collect |
| | | }; |
| | | //bodyDiv.AddChidren(btnCollectionIcon); |
| | | //2020-12-16 如果是成员隐藏收藏功能 |
| | | if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare) |
| | | if ( !SPK.ArmSensorSpkList().Contains(function.spk) && !SPK.EnvironDeviceSpkList().Contains( function.spk))//!DB_ResidenceData.Instance.CurrentRegion.isOtherShare && |
| | | { |
| | | bodyDiv.AddChidren(btnCollectionIcon); |
| | | } |
| | |
| | | /// </summary> |
| | | void LoadLightControl() |
| | | { |
| | | switch (function.functionType) |
| | | switch (function.spk) |
| | | { |
| | | case FunctionType.Dimmer: |
| | | case FunctionType.RGB: |
| | | case SPK.LightDimming: |
| | | case SPK.LightRGB: |
| | | #region Dimmer |
| | | var btnDimmerMinValues = new Button() |
| | | { |
| | |
| | | ProgressTextColor = CSS_Color.FirstLevelTitleColor, |
| | | ProgressTextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | MaxValue = 100, |
| | | Progress = (function as Light).brightness, |
| | | Progress = Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.Brightness)), |
| | | Tag = function.sid + "_DimmerBar", |
| | | SeekBarPadding = Application.GetRealWidth(20), |
| | | }; |
| | |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png", |
| | | SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "off", |
| | | IsSelected = function.GetAttrState(FunctionAttributeKey.OnOff) == "off", |
| | | Tag = function.sid + "_off" |
| | | }; |
| | | bodyDiv.AddChidren(btnCurtainClose); |
| | | if(function.spk == SPK.CurtainRoller) |
| | | { |
| | | btnCurtainClose.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainDownIcon.png"; |
| | | btnCurtainClose.SelectedImagePath = "FunctionIcon/Curtain/CurtainDownIconOn.png"; |
| | | } |
| | | |
| | | var btnCurtainStop = new Button() |
| | | { |
| | |
| | | UnSelectedImagePath = "FunctionIcon/Curtain/CurtainStopIcon.png", |
| | | SelectedImagePath = "FunctionIcon/Curtain/CurtainStopOnIcon.png", |
| | | Tag = function.sid + "_stop", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "stop" |
| | | }; |
| | | bodyDiv.AddChidren(btnCurtainStop); |
| | | |
| | |
| | | UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png", |
| | | SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png", |
| | | Tag = function.sid + "_on", |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on" |
| | | IsSelected = function.GetAttrState(FunctionAttributeKey.OnOff) == "on", |
| | | }; |
| | | bodyDiv.AddChidren(btnCurtainOpen); |
| | | LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function as Curtain); |
| | | if (function.spk == SPK.CurtainRoller) |
| | | { |
| | | btnCurtainOpen.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainUpIcon.png"; |
| | | btnCurtainOpen.SelectedImagePath = "FunctionIcon/Curtain/CurtainUpIconOn.png"; |
| | | } |
| | | LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function); |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | | /// 加载晾衣架功能控制卡片 |
| | | /// </summary> |
| | | void ClothesHangerFragment() |
| | | { |
| | | #region ClothesHanger |
| | | var btnClothesHangerUp = new Button() |
| | | { |
| | | X = Application.GetRealWidth(233), |
| | | Y = Application.GetRealHeight(58), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerUpIcon1.png", |
| | | SelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerUpIcon1On.png", |
| | | }; |
| | | bodyDiv.AddChidren(btnClothesHangerUp); |
| | | |
| | | var btnClothesHangerDown = new Button() |
| | | { |
| | | X = Application.GetRealWidth(303), |
| | | Y = Application.GetRealHeight(58), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDownIcon1.png", |
| | | SelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDownIcon1On.png", |
| | | }; |
| | | bodyDiv.AddChidren(btnClothesHangerDown); |
| | | LoadEvent_ControlClothesHanger(function, btnClothesHangerUp, btnClothesHangerDown); |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "MusicIcon/pause.png", |
| | | SelectedImagePath = "MusicIcon/play.png", |
| | | IsSelected = (function as A31MusicModel).A31PlayStatus.status == "play" , |
| | | Tag = function.functionType + "_State_" + function.sid |
| | | //IsSelected = (function as A31MusicModel).A31PlayStatus.status == "play" , |
| | | Tag = function.spk + "_State_" + function.sid |
| | | }; |
| | | bodyDiv.AddChidren(btnPlay); |
| | | |
| | |
| | | #endregion |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 加载功能状态信息按钮 |
| | | /// </summary> |
| | | void LoadLastStatesButton() |
| | | { |
| | | if(function.spk == SPK.LightSwitch) |
| | | { |
| | | return; |
| | | } |
| | | var btnLastStates = new Button() |
| | | { |
| | | X = Application.GetRealWidth(10 + 32 + 8), |
| | |
| | | SelectedTextColor = CSS_Color.PromptingColor1, |
| | | TextColor = 0x00000000, |
| | | TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | | Tag = function.functionType + "_laststates_" + function.sid, |
| | | Tag = function.spk + "_laststates_" + function.sid, |
| | | IsSelected = function.trait_on_off.curValue.ToString() == "on" |
| | | }; |
| | | bodyDiv.AddChidren(btnLastStates); |