using System; using System.Collections.Generic; using HDL_ON.DriverLayer; using HDL_ON.Entity; using HDL_ON.Stan; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class ColorfulInfoPage : FrameLayout { FrameLayout bodyView; Light lightTemp; Function function; int hour = 0; int minute = 0; int second = 0; public ColorfulInfoPage(Function function) { bodyView = this; lightTemp = new Light(); this.function = function; } public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView(); var contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(500), ScrollEnabled = false, }; bodyView.AddChidren(contentView); #region 炫彩开关 contentView.AddChidren(new Button { Height = Application.GetRealHeight(10), BackgroundColor = CSS_Color.BackgroundColor, }); var viewSwitch = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(viewSwitch); var btnSwitchText = new Button() { X = Application.GetRealWidth(16), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.CulorfulTest, }; viewSwitch.AddChidren(btnSwitchText); var btnColorfulSwitch = new Button() { X = Application.GetRealWidth(314), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(48), Height = Application.GetMinRealAverage(36), UnSelectedImagePath = "Public/Switch.png", SelectedImagePath = "Public/SwitchOn.png", IsSelected = function.GetAttrState(FunctionAttributeKey.Colorful) == "on" }; viewSwitch.AddChidren(btnColorfulSwitch); btnColorfulSwitch.MouseUpEventHandler = (sender, e) => { btnColorfulSwitch.IsSelected = !btnColorfulSwitch.IsSelected; new System.Threading.Thread(() => { try { var controlColorfulState = btnColorfulSwitch.IsSelected ? "on" : "off"; function.SetAttrState(FunctionAttributeKey.Colorful, controlColorfulState); var d = new Dictionary(); d.Add(FunctionAttributeKey.Colorful, controlColorfulState); if (controlColorfulState == "on") { var color = function.GetAttrState(FunctionAttributeKey.ColorfulBegin).Split(","); var sendColorString = color[0] + "," + color[1] + "," + color[2]; d.Add(FunctionAttributeKey.ColorfulBegin, sendColorString); color = function.GetAttrState(FunctionAttributeKey.ColorfulEnd).Split(","); sendColorString = color[0] + "," + color[1] + "," + color[2]; d.Add(FunctionAttributeKey.ColorfulEnd, sendColorString); d.Add(FunctionAttributeKey.ColorfulTime, function.GetAttrState(FunctionAttributeKey.ColorfulTime)); } Control.Ins.SendWriteCommand(function, d); } catch (Exception ex) { MainPage.Log($"控制炫彩开关异常:{ex.Message}"); } }) { IsBackground = true }.Start(); }; contentView.AddChidren(new Button { Height = Application.GetRealHeight(10), BackgroundColor = CSS_Color.BackgroundColor, }); #endregion #region 起始颜色 var startView = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(startView); var btnStartTitle = new Button() { X = Application.GetRealWidth(16), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.StartColor, }; startView.AddChidren(btnStartTitle); var btnStartRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; startView.AddChidren(btnStartRight); var btnStartColor = new Button() { X = Application.GetRealWidth(295), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(28), Height = Application.GetRealWidth(28), Radius = (uint)Application.GetRealWidth(14), BorderColor = CSS_Color.DividingLineColor, BorderWidth = 1, BackgroundColor = (uint)(0xFF000000 + lightTemp.GetRGBcolor(function.GetAttrState(FunctionAttributeKey.ColorfulBegin))) }; startView.AddChidren(btnStartColor); startView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); btnStartColor.MouseUpEventHandler = (sender, e) => { Action action = (color) => { btnStartColor.BackgroundColor = color; //function.SetAttrState(FunctionAttributeKey.ColorfulBegin, color); }; var rgbView = new ColorfulSettingPage(function, action,true); MainPage.BasePageView.AddChidren(rgbView); rgbView.LoadPage(function.GetAttrState(FunctionAttributeKey.ColorfulBegin)); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; #endregion #region 结束颜色 var endColorView = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(endColorView); var btnEndColorTitle = new Button() { X = Application.GetRealWidth(16), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.EndColor, }; endColorView.AddChidren(btnEndColorTitle); var btnEndColorRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; endColorView.AddChidren(btnEndColorRight); var btnEndColor = new Button() { X = Application.GetRealWidth(295), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(28), Height = Application.GetRealWidth(28), Radius = (uint)Application.GetRealWidth(14), BorderColor = CSS_Color.DividingLineColor, BorderWidth = 1, BackgroundColor = (uint)(0xFF000000 + lightTemp.GetRGBcolor(function.GetAttrState(FunctionAttributeKey.ColorfulEnd))) }; endColorView.AddChidren(btnEndColor); endColorView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor }); btnEndColor.MouseUpEventHandler = (sender, e) => { Action action = (color) => { btnEndColor.BackgroundColor = color; function.SetAttrState(FunctionAttributeKey.ColorfulEnd, color); }; var rgbView = new ColorfulSettingPage(function, action,false); MainPage.BasePageView.AddChidren(rgbView); rgbView.LoadPage(function.GetAttrState(FunctionAttributeKey.ColorfulEnd)); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; #endregion #region 炫彩周期 var workHoursView = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(workHoursView); var btnWorkHoursTitle = new Button() { X = Application.GetRealWidth(16), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.WorkingHours, }; workHoursView.AddChidren(btnWorkHoursTitle); var btnWorkHoursRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; workHoursView.AddChidren(btnWorkHoursRight); var btnWorkHours = new Button() { X = Application.GetRealWidth(195), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(128), Height = Application.GetRealWidth(28), TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.PromptingColor1, Text = function.GetAttrState(FunctionAttributeKey.ColorfulTime) }; workHoursView.AddChidren(btnWorkHours); var time = Convert.ToInt32( function.GetAttrState(FunctionAttributeKey.ColorfulTime)); //btnWorkHours.Text = time/ 360 + Language.StringByID(StringId.h); btnWorkHours.Text = time / 60 + Language.StringByID(StringId.m); btnWorkHours.Text += time % 60 + Language.StringByID(StringId.s); var waitPage = new Loading(); this.AddChidren(waitPage); EventHandler eventHandler = (sender, e) => { waitPage.Start(""); new System.Threading.Thread(() => { try { Application.RunOnMainThread(() => { LoadEditDialog(() => { if( second == 0) { new PublicAssmebly().TipMsg(StringId.Tip, StringId.TimeInvalid); return; } //btnWorkHours.Text = hour + "时"; btnWorkHours.Text = second/60 + "分"; btnWorkHours.Text += second%60 + "秒"; new System.Threading.Thread(() => { var d = new Dictionary(); function.SetAttrState(FunctionAttributeKey.ColorfulTime, ( minute * 60 + second).ToString()); d.Add(FunctionAttributeKey.ColorfulTime, ( minute * 60 + second).ToString()); Control.Ins.SendWriteCommand(function, d); }) { IsBackground = true }.Start(); }); }); } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); }); } }) { IsBackground = true }.Start(); }; btnWorkHours.MouseUpEventHandler = eventHandler; workHoursView.MouseUpEventHandler = eventHandler; btnWorkHoursRight.MouseUpEventHandler = eventHandler; #endregion } /// /// 加载选择弹窗 /// void LoadEditDialog(Action action) { Dialog dialog = new Dialog(); var pView = new FrameLayout() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; dialog.AddChidren(pView); var optionBaseView = new FrameLayout() { Y = Application.GetRealHeight(456 - 60), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(260), AnimateSpeed = 0.3f, Animate = Animate.DownToUp, BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), }; pView.AddChidren(optionBaseView); var topView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(40), BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), }; optionBaseView.AddChidren(topView); topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor }); var btnCancel = new Button() { X = Application.GetRealWidth(21), Width = Application.GetRealWidth(100), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.Cancel, }; topView.AddChidren(btnCancel); var btnConfrim = new Button() { X = Application.GetRealWidth(160), Width = Application.GetRealWidth(160), TextAlignment = TextAlignment.CenterRight, TextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.Confirm, }; topView.AddChidren(btnConfrim); List item1 = new List(); List item2 = new List(); List item3 = new List(); UIPickerView uIPickerView = new UIPickerView() { Y = Application.GetRealHeight(40), Height = Application.GetRealHeight(210), Radius = (uint)Application.GetRealWidth(12), }; for (int i = 0; i <= 15; i += 1) { item1.Add(i+Language.StringByID(StringId.h)); } for (int i = 1; i <= 120; i += 1) { item2.Add(i + Language.StringByID(StringId.m)); item3.Add(i + Language.StringByID(StringId.s)); } uIPickerView.setNPicker( item3,null,null); uIPickerView.setCurrentItems(second-1,0,0); optionBaseView.AddChidren(uIPickerView); dialog.Show(); pView.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; btnCancel.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => { second = int1+1; }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); action?.Invoke(); }; } } }