New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | | namespace HDL_ON.UI.UI2.Classification |
| | | { |
| | | /// <summary> |
| | | /// 跑马灯页面 |
| | | /// 序列页面 |
| | | /// </summary> |
| | | public class SeriesFunctionListPage : FrameLayout |
| | | { |
| | | FrameLayout bodyView; |
| | | public SeriesFunctionListPage() |
| | | { |
| | | bodyView = this; |
| | | } |
| | | |
| | | public void LoadPage() |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.HorseRaceLamp)).LoadTopView(); |
| | | bodyView.BackgroundColor = CSS_Color.BackgroundColor; |
| | | |
| | | var functionListView = new VerticalScrolViewLayout() |
| | | { |
| | | Y = Application.GetRealHeight(64), |
| | | Height = Application.GetRealHeight(603 - 12), |
| | | }; |
| | | bodyView.AddChidren(functionListView); |
| | | |
| | | var waitPage = new Loading(); |
| | | bodyView.AddChidren(waitPage); |
| | | waitPage.Hide(); |
| | | |
| | | Dictionary<string, List<Button>> dicGroupButtons = new Dictionary<string, List<Button>>(); |
| | | |
| | | List<string> oidList = new List<string>(); |
| | | |
| | | foreach(var rgb in FunctionList.List.GetLightList()) |
| | | { |
| | | //if(rgb.spk == SPK.LightRGB) |
| | | { |
| | | var oid = rgb.sid.Substring(0, 16); |
| | | if (oidList.Contains(oid)) |
| | | { |
| | | continue; |
| | | } |
| | | var seriesList = FunctionList.List.GetSeries().FindAll((obj) => obj.sid.StartsWith(oid)); |
| | | if (seriesList.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | oidList.Add(oid); |
| | | var list = new List<Function>(); |
| | | List<Button> groupButtons = new List<Button>(); |
| | | list.AddRange(seriesList); |
| | | var groupView = new VerticalScrolViewLayout() |
| | | { |
| | | Height = Application.GetRealHeight(44 + 51 * list.Count), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | ScrollEnabled = false, |
| | | }; |
| | | functionListView.AddChidren(groupView); |
| | | |
| | | #region title |
| | | var titleView = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(44), |
| | | }; |
| | | groupView.AddChidren(titleView); |
| | | |
| | | var btnTitle = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.MainColor, |
| | | Text =Language.StringByID( StringId.HorseRaceLampGroup )+ " "+ oidList.Count.ToString(), |
| | | }; |
| | | if(Language.CurrentLanguage == "Chinese") |
| | | { |
| | | btnTitle.Text = Language.StringByID(StringId.HorseRaceLampGroup) + oidList.Count.ToString(); |
| | | } |
| | | titleView.AddChidren(btnTitle); |
| | | |
| | | #endregion |
| | | |
| | | foreach (var series in list) |
| | | { |
| | | groupView.AddChidren(new Button |
| | | { |
| | | Height = 1, |
| | | BackgroundColor = CSS_Color.DividingLineColor, |
| | | }); |
| | | |
| | | var rgbColorfulView = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(50), |
| | | }; |
| | | groupView.AddChidren(rgbColorfulView); |
| | | |
| | | var btnRgbColorfulTitle = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | Text = series.name == rgb.name ? Language.StringByID(StringId.AutomaticColoring) : series.name, |
| | | }; |
| | | rgbColorfulView.AddChidren(btnRgbColorfulTitle); |
| | | |
| | | var btnColorfulSwitch = new Button() |
| | | { |
| | | X = Application.GetRealWidth(320), |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetMinRealAverage(48), |
| | | Height = Application.GetMinRealAverage(36), |
| | | UnSelectedImagePath = "Public/Switch.png", |
| | | SelectedImagePath = "Public/SwitchOn.png", |
| | | Tag = series.sid, |
| | | }; |
| | | rgbColorfulView.AddChidren(btnColorfulSwitch); |
| | | |
| | | groupButtons.Add(btnColorfulSwitch); |
| | | |
| | | btnColorfulSwitch.MouseUpEventHandler = (sener, e) => { |
| | | btnColorfulSwitch.IsSelected = !btnColorfulSwitch.IsSelected; |
| | | var state = btnColorfulSwitch.IsSelected ? "on" : "off"; |
| | | waitPage.Start(""); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add("on_off", state); |
| | | DriverLayer.Control.Ins.SendWriteCommand(series, d); |
| | | if (state == "on") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | List<Button> updataList = new List<Button>(); |
| | | dicGroupButtons.TryGetValue(((Button)sener).Tag.ToString().Substring(0, 16), out updataList); |
| | | foreach (var updataTemp in updataList) |
| | | { |
| | | updataTemp.IsSelected = false; |
| | | } |
| | | btnColorfulSwitch.IsSelected = true; |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"序列控制异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | waitPage.Hide(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | |
| | | } |
| | | Console.WriteLine("oid: " + oid); |
| | | dicGroupButtons.TryAdd(oid, groupButtons); |
| | | |
| | | functionListView.AddChidren(new Button |
| | | { |
| | | Height = Application.GetRealHeight(8), |
| | | BackgroundColor = CSS_Color.DividingLineColor, |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |