using System; using System.Collections.Generic; using Shared.Common; using Shared.R; namespace Shared.Phone.Device.Logic { public class Illumination : FrameLayout { public Illumination() { Tag = "Logic"; } public void Show(ZigBee.Device.CommonDevice common,string name,int progresValue,bool _bool) { this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; TopView view = new TopView(); this.AddChidren(view.TopRowView()); view.toptitleNameBtn.Text = name; view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; FrameLayout middle = new FrameLayout { Y = view.topRowLayout.Bottom, Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); //白色快父控件 FrameLayout blankFraLayout = new FrameLayout { Height = Application.GetRealHeight(616), BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, }; middle.AddChidren(blankFraLayout); //照度值控件 Button illuminationBtn = new Button { X = Application.GetRealWidth(58), Y = Application.GetRealHeight(259 - 184), Height = Application.GetRealHeight(50), Width = Application.GetRealWidth(300), Text =Language.StringByID(MyInternationalizationString.illuminanceValue)+ progresValue+"lux", //TextID = MyInternationalizationString.Save, TextColor = ZigbeeColor.Current.LogicBtnCancelColor, TextSize = 12, }; middle.AddChidren(illuminationBtn); //-图标控件 Button lessBtn = new Button { X = Application.GetRealWidth(847), Y = Application.GetRealHeight(46), Height = Application.GetMinRealAverage(104), Width = Application.GetMinRealAverage(104), UnSelectedImagePath = "ZigeeLogic/lesLuminositys.png", }; middle.AddChidren(lessBtn); //+图标控件 Button addBtn = new Button { X = lessBtn.Right, Y = Application.GetRealHeight(46), Height = Application.GetMinRealAverage(104), Width = Application.GetMinRealAverage(104), UnSelectedImagePath = "ZigeeLogic/addLuminosity.png", }; middle.AddChidren(addBtn); //进度条控件 var horizontalSeekBarVol = new DiyImageSeekBar { Y = Application.GetRealHeight(173),//进度条父控件Y坐标 X = Application.GetRealWidth(104),//进度条X坐标 Width = Application.GetRealWidth(873),//进度条的长度 Height = Application.GetRealHeight(56),//进度条父控件高度 IsProgressTextShow = false,//显示百分比 IsClickable = true,//进度条是否滑动 ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected,//选中进度条颜色 SeekBarBackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,//进度条颜色 ThumbImagePath = "ZigeeLogic/progressbtn2.png",//进度条按钮图标 ThumbImageHeight = Application.GetRealHeight(56),//进度条按钮图标的高度(默认正方形:宽和高一样) ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor, //ProgressTextSize = 9,//显示百分比字体大小12 SeekBarViewHeight = Application.GetRealHeight(7),//进度条的高度10 MaxValue = 100, MinValue = 0, Progress = progresValue, }; middle.AddChidren(horizontalSeekBarVol); lessBtn.MouseUpEventHandler += (sender, e) => { horizontalSeekBarVol.Progress = horizontalSeekBarVol.Progress - 1; illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux"; }; addBtn.MouseUpEventHandler += (sender, e) => { horizontalSeekBarVol.Progress = horizontalSeekBarVol.Progress + 1; illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux"; }; EventHandler progressclick = (sender, e) => { illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux"; }; horizontalSeekBarVol.OnProgressChangedEvent += progressclick; horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick; Button text1Btn = new Button() { X = Application.GetRealWidth(81), Y = Application.GetRealHeight(426 - 184), Height = Application.GetRealHeight(100), Width = Application.GetRealWidth(63+15), Text = Language.StringByID(MyInternationalizationString.dark).Replace("{\\r\\n}", "\r\n"), TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, TextSize = 12, TextAlignment = TextAlignment.Center, IsMoreLines = true, }; middle.AddChidren(text1Btn); Button text2Btn = new Button() { X = Application.GetRealWidth(913-20), Y = Application.GetRealHeight(426 - 184), Height = Application.GetRealHeight(100), Width = Application.GetRealWidth(109+20), Text = Language.StringByID(MyInternationalizationString.bright).Replace("{\\r\\n}", "\r\n"), TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, TextSize = 12, TextAlignment = TextAlignment.Center, IsMoreLines = true, }; middle.AddChidren(text2Btn); //提示图标 Button tipIconBtn = new Button { X = Application.GetRealWidth(109), Y = Application.GetRealHeight(616 - 184), Height = Application.GetMinRealAverage(58), Width = Application.GetMinRealAverage(58), UnSelectedImagePath = "ZigeeLogic/tipIcon.png", }; middle.AddChidren(tipIconBtn); //提示文字 Button tipTextBtn = new Button() { X = Application.GetRealWidth(173), Y = Application.GetRealHeight(616 - 184), Height = Application.GetRealHeight(138), Width = Application.GetRealWidth(818), Text = Language.StringByID(MyInternationalizationString.tipIlluminanceValue).Replace("{\\r\\n}", "\r\n"), TextColor = ZigbeeColor.Current.LogicBtnCancelColor, TextSize = 12, TextAlignment = TextAlignment.Center, IsMoreLines = true, }; middle.AddChidren(tipTextBtn); //保存控件 LogicView.SaveView saveView = new LogicView.SaveView(); saveView.frameLayout.Y = middle.Height - Application.GetRealHeight(260); middle.AddChidren(saveView.Show()); saveView.clickviewBtn.MouseUpEventHandler += (sender, e) => { var deviceConditionsInfo = new Dictionary(); deviceConditionsInfo.Add("Type", "1"); deviceConditionsInfo.Add("IsValid", "1"); deviceConditionsInfo.Add("MacAddr", common.DeviceAddr); deviceConditionsInfo.Add("Epoint", common.DeviceEpoint.ToString()); deviceConditionsInfo.Add("Cluster_ID", "1024"); deviceConditionsInfo.Add("AttriButeId", "0"); deviceConditionsInfo.Add("AttriButeData1", horizontalSeekBarVol.Progress.ToString()); deviceConditionsInfo.Add("AttriButeData2", "0"); deviceConditionsInfo.Add("Range", "7"); if (_bool && progresValue != horizontalSeekBarVol.Progress) { LogicIfon.AddDeviceconditions(common, deviceConditionsInfo); } if (!_bool) { //不是编辑进来的; LogicIfon.AddDeviceconditions(common, deviceConditionsInfo); } var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; } } }