| | |
| | | /// </summary> |
| | | public class LightSceneEditDialog :Dialog |
| | | { |
| | | |
| | | |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | List<Function> listSwitch = new List<Function>(); |
| | | List<Function> lightDimming = new List<Function>(); |
| | | List<Function> lightCCT = new List<Function>(); |
| | | List<Function> lightRGB = new List<Function>(); |
| | | |
| | | /// <summary> |
| | | /// 传入的灯光列表 |
| | | /// 加入场景控制功能列表 |
| | |
| | | { |
| | | commandDic.Add(FunctionAttributeKey.OnOff, "off"); |
| | | |
| | | var hadDimming = lights.Find((obj) => obj.spk == SPK.LightDimming) != null; |
| | | var hadCCT = lights.Find((obj) => obj.spk == SPK.LightCCT) != null; |
| | | var hadRGB = lights.Find((obj) => obj.spk == SPK.LightRGB) != null; |
| | | listSwitch = lights.FindAll((obj) => obj.spk == SPK.LightSwitch); |
| | | lightDimming = lights.FindAll((obj) => obj.spk == SPK.LightDimming); |
| | | lightCCT = lights.FindAll((obj) => obj.spk == SPK.LightCCT); |
| | | lightRGB = lights.FindAll((obj) => obj.spk == SPK.LightRGB); |
| | | |
| | | var hadDimming = lightDimming.Count > 0; |
| | | var hadCCT = lightCCT.Count > 0; |
| | | var hadRGB = lightRGB.Count > 0; |
| | | |
| | | var bodyView = new FrameLayout(); |
| | | this.AddChidren(bodyView); |
| | |
| | | |
| | | var brightnessValue = 0; |
| | | var cctValue = 27; |
| | | if(rgbLight!= null) |
| | | { |
| | | int.TryParse(rgbLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue); |
| | | } |
| | | if (cctLight != null) |
| | | { |
| | | int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue); |
| | | int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out cctValue); |
| | | } |
| | | if(dimmingLight!=null) |
| | | { |
| | | int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out cctValue); |
| | | } |
| | | //if(rgbLight!= null) |
| | | //{ |
| | | // int.TryParse(rgbLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue); |
| | | //} |
| | | //if (cctLight != null) |
| | | //{ |
| | | // int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness).value, out brightnessValue); |
| | | // int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out cctValue); |
| | | //} |
| | | //if(dimmingLight!=null) |
| | | //{ |
| | | // int.TryParse(cctLight.status.Find((obj) => obj.key == FunctionAttributeKey.CCT).value, out brightnessValue); |
| | | //} |
| | | |
| | | |
| | | //属性设置区域 |
| | |
| | | btnClose.IsSelected = true; |
| | | btnOpen.IsSelected = false; |
| | | commandDic[FunctionAttributeKey.OnOff] = "off"; |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.OnOff, "off"); |
| | | foreach (var light in lights) |
| | | { |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | }; |
| | | btnOpen.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | btnClose.IsSelected = false; |
| | | btnOpen.IsSelected = true; |
| | | commandDic[FunctionAttributeKey.OnOff] = "on"; |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.OnOff, "on"); |
| | | foreach (var light in lights) |
| | | { |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | }; |
| | | |
| | | } |
| | |
| | | contentView.AddChidren(bottomView); |
| | | bottomView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); |
| | | |
| | | var btnSave = new Button() |
| | | var btnCacel = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(172), |
| | | Height = Application.GetRealHeight(44), |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextColor = CSS_Color.TextualColor, |
| | | TextID = StringId.Save, |
| | | TextID = StringId.Cancel, |
| | | }; |
| | | bottomView.AddChidren(btnSave); |
| | | bottomView.AddChidren(btnCacel); |
| | | |
| | | var btnComplete = new Button() |
| | | var btnSave = new Button() |
| | | { |
| | | X = Application.GetRealWidth(172), |
| | | Width = Application.GetRealWidth(172), |
| | |
| | | TextColor = CSS_Color.MainBackgroundColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | Text = "执行" |
| | | TextID = StringId.Save |
| | | }; |
| | | bottomView.AddChidren(btnComplete); |
| | | bottomView.AddChidren(btnSave); |
| | | |
| | | //例:右下圆角 大小为50 |
| | | int mRectCornerID = HDLUtils.RectCornerBottomRight; |
| | | btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID); |
| | | btnSave.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID); |
| | | |
| | | |
| | | |
| | | btnComplete.MouseUpEventHandler = (sender, e) => { |
| | | //this.Close(); |
| | | btnCacel.MouseUpEventHandler = (sender, e) => { |
| | | this.Close(); |
| | | |
| | | var waitPage = new Loading(); |
| | | MainPage.BaseView.AddChidren(waitPage); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | //var waitPage = new Loading(); |
| | | //MainPage.BaseView.AddChidren(waitPage); |
| | | //waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | //new Thread(() => |
| | | //{ |
| | | // try |
| | | // { |
| | | // foreach (var light in lights) |
| | | // { |
| | | // Dictionary<string, string> sendDate = new Dictionary<string, string>(); |
| | | // //赋值场景功能数据 |
| | | // foreach (var attr in light.GetAttributes()) |
| | | // { |
| | | // if (commandDic.ContainsKey(attr)) |
| | | // { |
| | | // try |
| | | // { |
| | | // sendDate.Add(attr, commandDic[attr]); |
| | | // } |
| | | // catch { } |
| | | // } |
| | | |
| | | new Thread(() => |
| | | { |
| | | try |
| | | { |
| | | foreach (var light in lights) |
| | | { |
| | | Dictionary<string, string> sendDate = new Dictionary<string, string>(); |
| | | //赋值场景功能数据 |
| | | foreach (var attr in light.GetAttributes()) |
| | | { |
| | | if (commandDic.ContainsKey(attr)) |
| | | { |
| | | try |
| | | { |
| | | sendDate.Add(attr, commandDic[attr]); |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | } |
| | | Control.Ins.SendWriteCommand(light, sendDate); |
| | | Thread.Sleep(50); |
| | | } |
| | | } |
| | | catch |
| | | { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | new PublicAssmebly().TipMsgAutoClose("组合控制已执行", true); |
| | | if (waitPage != null) |
| | | { |
| | | //backAction(null); |
| | | waitPage.RemoveFromParent(); |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | // } |
| | | // Control.Ins.SendWriteCommand(light, sendDate); |
| | | // Thread.Sleep(50); |
| | | // } |
| | | // } |
| | | // catch |
| | | // { } |
| | | // finally |
| | | // { |
| | | // Application.RunOnMainThread(() => |
| | | // { |
| | | // waitPage.Hide(); |
| | | // new PublicAssmebly().TipMsgAutoClose("组合控制已执行", true); |
| | | // if (waitPage != null) |
| | | // { |
| | | // //backAction(null); |
| | | // waitPage.RemoveFromParent(); |
| | | // } |
| | | // }); |
| | | // } |
| | | //}) |
| | | //{ IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | |
| | | |
| | | btnSave.MouseUpEventHandler += (sender, e) => |
| | | btnSave.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | if (string.IsNullOrEmpty(scene.name)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), |
| | | Text = Language.StringByID(StringId.NameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | |
| | | { |
| | | if (scene.name == tempRoom.name) |
| | | { |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); |
| | | new PublicAssmebly().TipMsg(StringId.Tip, StringId.NameAlreadyExists); |
| | | return; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (result == StateCode.SUCCESS) |
| | | { |
| | | scene = serverScene; |
| | | scene.userSceneId = serverScene.userSceneId; |
| | | FunctionList.List.scenes.Add(scene); |
| | | backAction(scene); |
| | | backAction?.Invoke(scene); |
| | | this.Close(); |
| | | } |
| | | else |
| | | { |
| | | if (result == "124005") |
| | | IMessageCommon.Current.ShowErrorInfoAlter(Language.StringByID(StringId.GatewayOffline)); |
| | | else |
| | | IMessageCommon.Current.ShowErrorInfoAlter(result); |
| | | } |
| | | }); |
| | |
| | | dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { |
| | | commandDic[FunctionAttributeKey.Percent] = dimmerBar.Progress.ToString(); |
| | | btnBrightnessText.Text = Language.StringByID(StringId.Brightness) + " " + e + "%"; |
| | | |
| | | foreach (var light in lights) |
| | | { |
| | | if (light.spk == SPK.LightSwitch) |
| | | { |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.OnOff, e > 0 ? "on" : "off"); |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | else |
| | | { |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.Brightness, e.ToString()); |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | |
| | | barColorTemplatrue.OnStopTrackingTouchEvent = (sender, e) => |
| | | { |
| | | commandDic[FunctionAttributeKey.CCT] = (barColorTemplatrue.Progress*100).ToString(); |
| | | |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.CCT, (barColorTemplatrue.Progress * 100).ToString()); |
| | | foreach (var light in lightCCT) |
| | | { |
| | | if (light.spk == SPK.LightCCT) |
| | | { |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | } |
| | | }; |
| | | //变更背景图的Y轴坐标 |
| | | btnColorTemplatrueBack.Y = barColorTemplatrue.Y + (barColorTemplatrue.Height - btnColorTemplatrueBack.Height) / 2; |
| | |
| | | //圆的半径(考虑边界,需要设置它的半径比较小一点) |
| | | int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12); |
| | | |
| | | |
| | | colorPicker.MouseUpEventHandler = (sender2, e) => { |
| | | d.Clear(); |
| | | d.Add(FunctionAttributeKey.RGB, commandDic[FunctionAttributeKey.RGB]); |
| | | foreach (var light in lightCCT) |
| | | { |
| | | if (light.spk == SPK.LightCCT) |
| | | { |
| | | Control.Ins.SendWriteCommand(light, d); |
| | | } |
| | | } |
| | | }; |
| | | colorPicker.ColorChaged += (sender2, e2) => { |
| | | string rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString(); |
| | | commandDic[FunctionAttributeKey.RGB] = rgbString; |