New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Threading.Tasks;
|
| | | using ZigBee.Device; |
| | | namespace Shared.Phone.UserCenter.DevicePanel |
| | | { |
| | | public class PanelBrightnessAdjustForm : EditorCommonForm |
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listview = null;
|
| | | /// <summary>
|
| | | /// 面板的回路
|
| | | /// </summary>
|
| | | private Panel panelDevice; |
| | | /// <summary>
|
| | | /// 设备的某一回路
|
| | | /// </summary>
|
| | | private CommonDevice deviceObj = null;
|
| | | /// <summary>
|
| | | /// 亮度调节的信息
|
| | | /// </summary>
|
| | | private Panel.PanelSwitchLevelInfo linghtLevelInfo = null;
|
| | | /// <summary>
|
| | | /// 亮度调节的信息
|
| | | /// </summary>
|
| | | private Panel.PanelProximitySensorInfo proximitySensorsInfo = null;
|
| | | /// <summary>
|
| | | /// 节能模式
|
| | | /// </summary>
|
| | | private Panel.PanelSaveEnergyModeInfo energyModeInfo = null;
|
| | | /// <summary>
|
| | | /// 按键的颜色数据
|
| | | /// </summary>
|
| | | private Panel.KeyColorData keyColorData = null; |
| | | /// <summary>
|
| | | /// 选择睡眠时间的事件 value:索引(从0开始) 文本信息请用Text获取
|
| | | /// </summary>
|
| | | public Action<int> timeAction = null;
|
| | | /// <summary>
|
| | | /// 当前选择的功能类型索引
|
| | | /// </summary>
|
| | | private int nowSelectNo = 0;
|
| | | /// <summary>
|
| | | /// /// <summary>
|
| | | /// 睡眠时间的值
|
| | | /// </summary>
|
| | | /// </summary>
|
| | | public string sleepTimeText
|
| | | {
|
| | | get { return btnSleepTime.Text; }
|
| | | set { btnSleepTime.Text = value; }
|
| | | }
|
| | | /// <summary>
|
| | | ///睡眠时间 |
| | | /// </summary>
|
| | | public NormalViewControl btnSleepTime = null; |
| | | #endregion
|
| | | |
| | | #region ■ 初始化_____________________________
|
| | | |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_device">设备的某一回路</param>
|
| | | public void ShowForm(CommonDevice device)
|
| | | {
|
| | | //左滑使能不可
|
| | | this.ScrollEnabled = false; |
| | | this.deviceObj = device; |
| | | this.panelDevice = new Panel(); |
| | | this.panelDevice.DeviceAddr = this.deviceObj.DeviceAddr; |
| | | this.panelDevice.DeviceEpoint = 200; |
| | | this.panelDevice.CurrentGateWayId = this.deviceObj.CurrentGateWayId; |
| | | |
| | | //设置头部信息 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uLightRegulation));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private async void InitMiddleFrame()
|
| | | {
|
| | | //获取设备初始数据
|
| | | var result = await this.GetDeviceDefultData();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | listview = new VerticalScrolViewLayout();
|
| | | listview.Height = Application.GetRealHeight(1981 - 184);
|
| | | bodyFrameLayout.AddChidren(listview); |
| | | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //添加节能模式控件
|
| | | this.AddEnergyConservationRow();
|
| | |
|
| | | //添加屏幕亮度级别控件
|
| | | this.AddScreenBrightnesLevelControl(); |
| | | |
| | | //获取设备类型的 |
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { deviceObj }); |
| | | if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleEnvironment) |
| | | { |
| | | //添加面板的颜色 |
| | | this.AddColorControl(); |
| | | } |
| | | |
| | | this.FinishInitControl(listview, energyModeInfo.enable);
|
| | |
|
| | | //保存
|
| | | var btnSave = new BottomClickButton();
|
| | | btnSave.TextID = R.MyInternationalizationString.uSave;
|
| | | bodyFrameLayout.AddChidren(btnSave);
|
| | | btnSave.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //保存面板数据
|
| | | this.SavePanelData();
|
| | | };
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 屏幕亮度级别_______________________ |
| | | /// <summary>
|
| | | /// 添加屏幕亮度级别控件
|
| | | /// </summary>
|
| | | private void AddScreenBrightnesLevelControl()
|
| | | {
|
| | | var btnEspace = new NormalViewControl(600, 58, true);
|
| | | btnEspace.X = ControlCommonResourse.XXLeft;
|
| | | listview.AddChidren(btnEspace);
|
| | |
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = Application.GetRealHeight(429);
|
| | | frameBack.Y = Application.GetRealHeight(58);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | listview.AddChidren(frameBack);
|
| | |
|
| | | //屏幕亮度级别
|
| | | var btnLevelView = new NormalViewControl(400, 60, true);
|
| | | btnLevelView.X = ControlCommonResourse.XXLeft;
|
| | | btnLevelView.Y = Application.GetRealHeight(54);
|
| | | btnLevelView.TextID = R.MyInternationalizationString.uScreenBrightnesLevel;
|
| | | frameBack.AddChidren(btnLevelView);
|
| | |
|
| | | //?级
|
| | | string strRank = Language.StringByID(R.MyInternationalizationString.uRank);
|
| | | var btnLevel = new NormalViewControl(167, 60, true);
|
| | | btnLevel.X = Application.GetRealWidth(855);
|
| | | btnLevel.Y = Application.GetRealHeight(54);
|
| | | btnLevel.TextAlignment = TextAlignment.CenterRight;
|
| | | btnLevel.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | frameBack.AddChidren(btnLevel);
|
| | |
|
| | | //当前亮度
|
| | | var btnProgressView1 = new NormalViewControl(200, 50, true);
|
| | | btnProgressView1.X = ControlCommonResourse.XXLeft;
|
| | | btnProgressView1.Y = Application.GetRealHeight(157);
|
| | | btnProgressView1.TextSize = 12;
|
| | | btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnProgressView1.TextID = R.MyInternationalizationString.uNowLuminance;
|
| | | frameBack.AddChidren(btnProgressView1);
|
| | | var btnProgress1 = new NormalViewControl(200, 50, true);
|
| | | btnProgress1.X = Application.GetRealWidth(222);
|
| | | btnProgress1.Y = Application.GetRealHeight(157);
|
| | | btnProgress1.TextSize = 12;
|
| | | btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | frameBack.AddChidren(btnProgress1);
|
| | |
|
| | | //进度条
|
| | | var seekBar1 = new SeekBarControl();
|
| | | seekBar1.SeekBarPadding = 25;
|
| | | seekBar1.MaxValue = 5;
|
| | | seekBar1.ProgressBarColor = 0xff3e99f4;
|
| | | seekBar1.Y = Application.GetRealHeight(253);
|
| | | frameBack.AddChidren(seekBar1);
|
| | | seekBar1.ProgressChangedEvent += (div, value) =>
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | btnProgress1.Text = (value + 1).ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | btnProgress1.Text = value.ToString();
|
| | | }
|
| | |
|
| | | switch (value)
|
| | | {
|
| | | case 0:
|
| | | case 1:
|
| | | linghtLevelInfo.panelDirectionsLevel = 20;
|
| | | btnLevel.Text = "1" + strRank;
|
| | |
|
| | | break;
|
| | | case 2:
|
| | | linghtLevelInfo.panelDirectionsLevel = 40;
|
| | | btnLevel.Text = "2" + strRank;
|
| | | break;
|
| | | case 3:
|
| | | linghtLevelInfo.panelDirectionsLevel = 60;
|
| | | btnLevel.Text = "3" + strRank;
|
| | | break;
|
| | | case 4:
|
| | | linghtLevelInfo.panelDirectionsLevel = 80;
|
| | | btnLevel.Text = "4" + strRank;
|
| | | break;
|
| | | case 5:
|
| | | linghtLevelInfo.panelDirectionsLevel = 100;
|
| | | btnLevel.Text = "5" + strRank;
|
| | | break;
|
| | | }
|
| | | listview.ScrollEnabled = false;
|
| | | };
|
| | | seekBar1.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | listview.ScrollEnabled = true;
|
| | | };
|
| | | seekBar1.OnStopTrackingTouchEvent += (div, value) =>
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | seekBar1.Progress = 1;
|
| | | }
|
| | | else
|
| | | {
|
| | | seekBar1.Progress = value;
|
| | | }
|
| | | };
|
| | |
|
| | | if (linghtLevelInfo.panelDirectionsLevel <= 20 && linghtLevelInfo.panelDirectionsLevel >= 0)
|
| | | {
|
| | | btnLevel.Text = "1" + strRank;
|
| | | btnProgress1.Text = "1";
|
| | | seekBar1.Progress = 1;
|
| | | }
|
| | | else if (linghtLevelInfo.panelDirectionsLevel <= 40 && linghtLevelInfo.panelDirectionsLevel > 20)
|
| | | {
|
| | | btnLevel.Text = "2" + strRank;
|
| | | btnProgress1.Text = "2";
|
| | | seekBar1.Progress = 2;
|
| | | }
|
| | | else if (linghtLevelInfo.panelDirectionsLevel <= 60 && linghtLevelInfo.panelDirectionsLevel > 40)
|
| | | {
|
| | | btnLevel.Text = "3" + strRank;
|
| | | btnProgress1.Text = "3";
|
| | | seekBar1.Progress = 3;
|
| | | }
|
| | | else if (linghtLevelInfo.panelDirectionsLevel <= 80 && linghtLevelInfo.panelDirectionsLevel > 60)
|
| | | {
|
| | | btnLevel.Text = "4" + strRank;
|
| | | btnProgress1.Text = "4";
|
| | | seekBar1.Progress = 4;
|
| | | }
|
| | | else if (linghtLevelInfo.panelDirectionsLevel <= 100 && linghtLevelInfo.panelDirectionsLevel > 80)
|
| | | {
|
| | | btnLevel.Text = "5" + strRank;
|
| | | btnProgress1.Text = "5";
|
| | | seekBar1.Progress = 5;
|
| | | }
|
| | | else
|
| | | {
|
| | | btnLevel.Text = "1" + strRank;
|
| | | btnProgress1.Text = "1";
|
| | | seekBar1.Progress = 1;
|
| | | }
|
| | |
|
| | | var btnTemp1 = new NormalViewControl(200, 50, true);
|
| | | btnTemp1.X = ControlCommonResourse.XXLeft;
|
| | | btnTemp1.Y = Application.GetRealHeight(322);
|
| | | btnTemp1.TextSize = 12;
|
| | | btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnTemp1.Text = "1";
|
| | | frameBack.AddChidren(btnTemp1);
|
| | |
|
| | | var btnTemp2 = new NormalViewControl(100, 50, true);
|
| | | btnTemp2.X = frameBack.Width - ControlCommonResourse.XXLeft - Application.GetRealWidth(100);
|
| | | btnTemp2.Y = Application.GetRealHeight(322);
|
| | | btnTemp2.TextAlignment = TextAlignment.CenterRight;
|
| | | btnTemp2.TextSize = 12;
|
| | | btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnTemp2.Text = "5";
|
| | | frameBack.AddChidren(btnTemp2);
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 背光颜色_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加背光颜色控件
|
| | | /// </summary>
|
| | | private void AddColorControl()
|
| | | {
|
| | | var btnEspace = new NormalViewControl(600, 58, true);
|
| | | btnEspace.X = ControlCommonResourse.XXLeft;
|
| | | listview.AddChidren(btnEspace);
|
| | |
|
| | | //背景
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Y = Application.GetRealHeight(490);
|
| | | frameBack.Height = Application.GetRealHeight(170);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | listview.AddChidren(frameBack);
|
| | |
|
| | | //背光灯颜色
|
| | | var btnLevelView = new NormalViewControl(400, 60, true);
|
| | | btnLevelView.X = ControlCommonResourse.XXLeft;
|
| | | btnLevelView.Y = Application.GetRealHeight(54);
|
| | | btnLevelView.Gravity = Gravity.CenterVertical;
|
| | | btnLevelView.TextID = R.MyInternationalizationString.BackgroundLightColor;
|
| | | frameBack.AddChidren(btnLevelView);
|
| | |
|
| | | var frameColor = new FrameLayoutStatuControl();
|
| | | frameColor.UseClickStatu = false;
|
| | | frameColor.Width = Application.GetRealHeight(262);
|
| | | frameColor.Height = this.GetPictrueRealSize(79);
|
| | | frameColor.Y = Application.GetRealHeight(26);
|
| | | frameColor.X = listview.Width - ControlCommonResourse.XXLeft - Application.GetRealHeight(262);
|
| | | frameBack.AddChidren(frameColor);
|
| | |
|
| | | //颜色
|
| | | var btnColorView = new NormalViewControl(Application.GetRealHeight(110), this.GetPictrueRealSize(49), false);
|
| | | btnColorView.Gravity = Gravity.CenterVertical;
|
| | | btnColorView.TextAlignment = TextAlignment.CenterRight;
|
| | | btnColorView.TextSize = 12;
|
| | | btnColorView.Y = Application.GetRealHeight(5);
|
| | | btnColorView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnColorView.TextID = R.MyInternationalizationString.uColor;
|
| | | frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEvent);
|
| | |
|
| | | int R1 = Convert.ToInt32(this.keyColorData.OpenColorR, 16);
|
| | | int G1 = Convert.ToInt32(this.keyColorData.OpenColorG, 16);
|
| | | int B1 = Convert.ToInt32(this.keyColorData.OpenColorB, 16);
|
| | | uint backColor = this.GetColorByRGB((byte)R1, (byte)G1, (byte)B1);
|
| | |
|
| | | //颜色外框
|
| | | var frameColorLine = new FrameLayoutStatuControl();
|
| | | frameColorLine.UseClickStatu = false;
|
| | | frameColorLine.Height = this.GetPictrueRealSize(79);
|
| | | frameColorLine.Width = this.GetPictrueRealSize(79);
|
| | | frameColorLine.X = btnColorView.Right + Application.GetRealHeight(18);
|
| | | frameColorLine.Radius = (uint)this.GetPictrueRealSize(79) / 2;
|
| | | frameColorLine.BorderWidth = 1;
|
| | | frameColorLine.BorderColor = 0xffcccccc;
|
| | | frameColor.AddChidren(frameColorLine, ChidrenBindMode.NotBind);
|
| | |
|
| | | //分两步计算,不然有可能它得出的结果有误差导致不居中
|
| | | int btnColorWidth = frameColorLine.Height - this.GetPictrueRealSize(7) - this.GetPictrueRealSize(7);
|
| | | var btnColor = new NormalViewControl(btnColorWidth, btnColorWidth, false);
|
| | | btnColor.Gravity = Gravity.Center;
|
| | | btnColor.Radius = (uint)btnColorWidth / 2;
|
| | | btnColor.BackgroundColor = backColor;
|
| | | frameColorLine.AddChidren(btnColor, ChidrenBindMode.NotBind);
|
| | | frameColor.ChangedChidrenBindMode(frameColorLine, ChidrenBindMode.BindEvent);
|
| | |
|
| | | var btnRight = new NormalViewControl(this.GetPictrueRealSize(58), this.GetPictrueRealSize(58), false);
|
| | | btnRight.UnSelectedImagePath = "Item/RightNext.png";
|
| | | btnRight.Y = Application.GetRealHeight(5);
|
| | | btnRight.X = frameColor.Width - this.GetPictrueRealSize(58);
|
| | | frameColor.AddChidren(btnRight, ChidrenBindMode.BindEvent);
|
| | | btnRight.Y += this.GetPictrueRealSize(8);
|
| | |
|
| | | frameColor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new PanelColorSelectForm();
|
| | | form.AddForm(R1, G1, B1);
|
| | | form.FinishSelectColorEvent += (Rcolor, Gcolor, Bcolor) =>
|
| | | {
|
| | | R1 = Rcolor;
|
| | | G1 = Gcolor;
|
| | | B1 = Bcolor;
|
| | |
|
| | | this.keyColorData.OpenColorR = Convert.ToString(Rcolor, 16);
|
| | | this.keyColorData.OpenColorG = Convert.ToString(Gcolor, 16);
|
| | | this.keyColorData.OpenColorB = Convert.ToString(Bcolor, 16);
|
| | |
|
| | | btnColor.BackgroundColor = this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
|
| | | };
|
| | | };
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 节能模式行_________________________ |
| | | /// <summary>
|
| | | /// 添加节能模式行
|
| | | /// </summary>
|
| | | /// <param name="frameLinght">各种背光灯的容器(控件伸缩使用)</param>
|
| | | private void AddEnergyConservationRow()
|
| | | {
|
| | | //缩小:170 扩大:614
|
| | | var frameBack = new FrameRowControl();
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.UseClickStatu = false;
|
| | | frameBack.Height = Application.GetRealHeight(170);
|
| | | listview.AddChidren(frameBack);
|
| | |
|
| | | //节能模式
|
| | | frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uEnergyConservationMode), 400);
|
| | | //开关控件
|
| | | var btnSwitch = frameBack.AddMostRightSwitchIcon();
|
| | | btnSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnSwitch.IsSelected = !btnSwitch.IsSelected;
|
| | | energyModeInfo.enable = btnSwitch.IsSelected;
|
| | | //展开或者缩小的高度
|
| | | var value = Application.GetRealHeight(614);
|
| | | if (btnSwitch.IsSelected == true)
|
| | | {
|
| | | frameBack.Height += value;
|
| | | }
|
| | | else
|
| | | {
|
| | | frameBack.Height -= value;
|
| | | }
|
| | | this.FinishInitControl(listview, energyModeInfo.enable);
|
| | | };
|
| | | if (energyModeInfo.enable == true)
|
| | | {
|
| | | btnSwitch.IsSelected = true;
|
| | | }
|
| | |
|
| | | //当前亮度
|
| | | var btnProgressView1 = new NormalViewControl(200, 49, true);
|
| | | btnProgressView1.X = ControlCommonResourse.XXLeft;
|
| | | btnProgressView1.Y = Application.GetRealHeight(164);
|
| | | btnProgressView1.TextSize = 12;
|
| | | btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnProgressView1.TextID = R.MyInternationalizationString.uNowLuminance;
|
| | | frameBack.AddChidren(btnProgressView1);
|
| | | var btnProgress1 = new NormalViewControl(200, 49, true);
|
| | | btnProgress1.X = Application.GetRealWidth(222);
|
| | | btnProgress1.Y = Application.GetRealHeight(164);
|
| | | btnProgress1.TextSize = 12;
|
| | | btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnProgress1.Text = energyModeInfo.level + "%";
|
| | | frameBack.AddChidren(btnProgress1);
|
| | |
|
| | | //进度条
|
| | | var seekBar1 = new SeekBarControl();
|
| | | seekBar1.Y = Application.GetRealHeight(253);
|
| | | seekBar1.ProgressBarColor = 0xff3e99f4;
|
| | | seekBar1.SeekBarPadding = 25;
|
| | | frameBack.AddChidren(seekBar1);
|
| | | seekBar1.ProgressChangedEvent += (div, value) =>
|
| | | {
|
| | | btnProgress1.Text = value + "%";
|
| | | //数据变更
|
| | | energyModeInfo.level = value;
|
| | | listview.ScrollEnabled = false;
|
| | | };
|
| | | seekBar1.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | listview.ScrollEnabled = true;
|
| | | };
|
| | | seekBar1.Progress = energyModeInfo.level;
|
| | |
|
| | | var btnTemp1 = new NormalViewControl(200, 49, true);
|
| | | btnTemp1.X = ControlCommonResourse.XXLeft;
|
| | | btnTemp1.Y = Application.GetRealHeight(325);
|
| | | btnTemp1.TextSize = 12;
|
| | | btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnTemp1.Text = "0%";
|
| | | frameBack.AddChidren(btnTemp1);
|
| | |
|
| | | var btnTemp2 = new NormalViewControl(200, 49, true);
|
| | | btnTemp2.X = listview.Width - Application.GetRealWidth(200 + 49);
|
| | | btnTemp2.Y = Application.GetRealHeight(325);
|
| | | btnTemp2.TextAlignment = TextAlignment.CenterRight;
|
| | | btnTemp2.TextSize = 12;
|
| | | btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnTemp2.Text = "100%";
|
| | | frameBack.AddChidren(btnTemp2);
|
| | |
|
| | | if (energyModeInfo.enable == true)
|
| | | {
|
| | | //展开或者缩小的高度
|
| | | var value = Application.GetRealHeight(614);
|
| | | frameBack.Height += value;
|
| | | }
|
| | | //添加接近感应
|
| | | this.AddProximitySensorsRow(frameBack);
|
| | | //底线 |
| | | var btnLine = new NormalViewControl(965, 5, true);
|
| | | btnLine.Height = 1;
|
| | | btnLine.X = Application.GetRealWidth(52);
|
| | | btnLine.Y = Application.GetRealHeight(484 + 127);
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | frameBack.AddChidren(btnLine);
|
| | |
|
| | | //添加睡眠时间
|
| | | this.AddSleepTimeRow(frameBack);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 接近感应___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 接近感应行
|
| | | /// </summary>
|
| | | private void AddProximitySensorsRow(FrameRowControl frameRowControl)
|
| | | {
|
| | | //接近感应行
|
| | | var frameBack = new FrameRowControl();
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.UseClickStatu = false;
|
| | | frameBack.Y = Application.GetRealHeight(443);
|
| | | frameBack.Height = Application.GetRealHeight(170);
|
| | | frameRowControl.AddChidren(frameBack); |
| | | |
| | | //接近感应 |
| | | frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.ProximitySensors), 400);
|
| | | //开关控件
|
| | | var btnSwitch = frameBack.AddMostRightSwitchIcon();
|
| | |
|
| | | btnSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnSwitch.IsSelected = !btnSwitch.IsSelected;
|
| | | proximitySensorsInfo.enable = btnSwitch.IsSelected;
|
| | | };
|
| | | if (proximitySensorsInfo.enable == true)
|
| | | {
|
| | | btnSwitch.IsSelected = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 睡眠时间___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 睡眠时间行
|
| | | /// </summary>
|
| | | private void AddSleepTimeRow(FrameRowControl frameRowControl)
|
| | | {
|
| | | //睡眠时间行
|
| | | var frameBack = new FrameRowControl();
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.UseClickStatu = false;
|
| | | frameBack.Y = Application.GetRealHeight(784 - 170);
|
| | | frameBack.Height = Application.GetRealHeight(170); |
| | | frameRowControl.AddChidren(frameBack);
|
| | |
|
| | | //睡眠时间
|
| | | frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.SleepTime), 400);
|
| | | //右箭头
|
| | | frameBack.AddRightArrow(); |
| | | btnSleepTime = new NormalViewControl(700, true);
|
| | | switch (energyModeInfo.time)
|
| | | {
|
| | | case 15:
|
| | | btnSleepTime.Text = "15s";
|
| | | nowSelectNo = 0;
|
| | | break;
|
| | | case 60:
|
| | | btnSleepTime.Text = "1min";
|
| | | nowSelectNo = 1;
|
| | | break;
|
| | | case 300:
|
| | | btnSleepTime.Text = "5min";
|
| | | nowSelectNo = 2;
|
| | | break;
|
| | | } |
| | | frameBack.AddMostRightView(this.sleepTimeText, 700);
|
| | |
|
| | | timeAction = null;
|
| | | timeAction += (nowSelectNo) => |
| | | { |
| | | switch (nowSelectNo) |
| | | { |
| | | case 0: |
| | | energyModeInfo.time = 15; |
| | | break; |
| | | case 1: |
| | | energyModeInfo.time = 60; |
| | | break; |
| | | case 2: |
| | | energyModeInfo.time = 300; |
| | | break; |
| | | } |
| | | AddSleepTimeRow(frameRowControl);
|
| | | };
|
| | | frameBack.ButtonClickEvent += (sender, e) =>
|
| | | { |
| | | this.ShowSelectDeviceSleepTimeListForm();
|
| | | };
|
| | | }
|
| | |
|
| | | #region ■ 显示选择设备睡眠时间_______________ |
| | | /// <summary>
|
| | | /// 显示选择设备睡眠时间的界面
|
| | | /// </summary>
|
| | | public void ShowSelectDeviceSleepTimeListForm()
|
| | | {
|
| | | //显示列表
|
| | | var listText = new List<string>();
|
| | | listText.Add("15s");
|
| | | listText.Add("1min");
|
| | | listText.Add("5min");
|
| | | //标题:选择功能类型
|
| | | var title = Language.StringByID(R.MyInternationalizationString.SleepTime);
|
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = false;//允许取消
|
| | | form.AddForm(title, listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo)
|
| | | {
|
| | | //选择的是相同的
|
| | | return;
|
| | | }
|
| | | //-1:选择取消
|
| | | this.sleepTimeText = selectNo == -1 ? string.Empty : listText[selectNo];
|
| | | nowSelectNo = selectNo; |
| | | //调用回调函数 |
| | | this.timeAction?.Invoke(nowSelectNo);
|
| | | };
|
| | | }
|
| | | #endregion
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取初始数据_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备初始数据
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> GetDeviceDefultData()
|
| | | {
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | | //亮度调节(他们说随便拿一路回路就行了)
|
| | | linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice);
|
| | | if (linghtLevelInfo == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //接近感应(他们说随便拿一路回路就行了)
|
| | | proximitySensorsInfo = await HdlDevicePanelLogic.Current.GetDeviceProximitySensorsSettion(panelDevice);
|
| | | if (proximitySensorsInfo == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //节能模式(他们说随便拿一路回路就行了)
|
| | | energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice);
|
| | | if (energyModeInfo == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | keyColorData = HdlDevicePanelLogic.Current.GetPanelColorInfo(panelDevice);
|
| | | if (this.keyColorData == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存数据___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存面板数据
|
| | | /// </summary>
|
| | | private async void SavePanelData()
|
| | | {
|
| | | this.ShowProgressBar(); |
| | | |
| | | //节能模式修改(他们说随便一个回路就行) |
| | | |
| | | var result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
|
| | | if (result == false)
|
| | | {
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | //接近感应(提供设备的同事说随便一个回路就行)
|
| | | result = await HdlDevicePanelLogic.Current.SetProximitySensorStatus(panelDevice, proximitySensorsInfo.enable);
|
| | | if (result == false)
|
| | | {
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | |
|
| | | //亮度调节更改(他们说随便一个回路就行)
|
| | | result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
|
| | | if (result == false)
|
| | | {
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | |
|
| | | //设置按键面板颜色的信息
|
| | | result = HdlDevicePanelLogic.Current.SetPanelColorInfo(panelDevice, this.keyColorData);
|
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 补充容器___________________________ |
| | | /// <summary>
|
| | | /// 行数超过容器时,补一个空白FrameLayout,使之能滑动
|
| | | /// </summary>
|
| | | /// <param name="listview">当前滑动页范围</param>
|
| | | /// <param name="enable">是否添加容器</param>
|
| | | public void FinishInitControl(VerticalScrolViewLayout listview, bool enable = false)
|
| | | {
|
| | | //促使被挡住的菜单能够向上滑动
|
| | | var frameTemp = new FrameLayout();
|
| | | listview.AddChidren(frameTemp);
|
| | | frameTemp.Tag = "移除容器";
|
| | | if (enable == true)
|
| | | {
|
| | | listview.ScrollEnabled = true;
|
| | | frameTemp.Height = Application.GetRealHeight(2212 - 1921 + 173);
|
| | | }
|
| | | else
|
| | | {
|
| | | listview.RemoveViewByTag("移除容器");
|
| | | listview.ScrollEnabled = false;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 将RGB转换为颜色
|
| | | /// </summary>
|
| | | /// <param name="R"></param>
|
| | | /// <param name="G"></param>
|
| | | /// <param name="B"></param>
|
| | | /// <returns></returns>
|
| | | private uint GetColorByRGB(byte R, byte G, byte B)
|
| | | {
|
| | | return (uint)(0xFF000000 + R * 256 * 256 + G * 256 + B);
|
| | | } |
| | | |
| | | #endregion
|
| | | } |
| | | } |