using System; using System.Collections.Generic; 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 起始颜色 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(action); 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.ColorfulBegin))) }; 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(action); 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 waitPage = new Loading(); this.AddChidren(waitPage); EventHandler eventHandler = (sender, e) => { waitPage.Start(""); new System.Threading.Thread(() => { try { Application.RunOnMainThread(() => { LoadEditDialog(() => { btnWorkHours.Text = hour + "时"; btnWorkHours.Text += minute + "分"; btnWorkHours.Text += second + "秒"; }); }); } 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 <= 23; i += 1) { item1.Add(i+Language.StringByID(StringId.h)); } for (int i = 0; i <= 59; i += 1) { item2.Add(i + Language.StringByID(StringId.m)); item3.Add(i + Language.StringByID(StringId.s)); } uIPickerView.setNPicker(item1, item2,item3); uIPickerView.setCurrentItems(hour, minute, second); optionBaseView.AddChidren(uIPickerView); dialog.Show(); pView.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; btnCancel.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => { hour = int1; minute = int2; second = int3; }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); action?.Invoke(); }; } } }