陈嘉乐
2021-03-17 dbc23459fdf4e8b74a5f955fbb9fc631b4babc70
HDL_ON/UI/UI2/FuntionControlView/Electrical/IrLearnPage.cs
New file
@@ -0,0 +1,146 @@
using System;
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 IrLearnPage : DeviceFunctionCardCommonForm
    {
        #region ■ 变量声明___________________________
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 初始化白色区域的内容
        /// </summary>
        public override void InitFrameWhiteContent()
        {
            base.ShowColltionButton = false;
            base.SetTitleText(Language.StringByID(StringId.RemoteControl));
            //初始化第一个索引页的内容
            this.InitFrameWhiteContent1();
        }
        /// <summary>
        /// 初始化第一个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent1()
        {
            var contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(94),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(296),
                Height = Application.GetRealHeight(376),
            };
            FrameWhiteCentet1.AddChidren(contentView);
            var row = new FrameLayout()
            {
                //Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(56),
            };
            contentView.AddChidren(row);
            int index = 0;
            foreach(var attr in device.attributes)
            {
                if(index != 0 && index%3==0)
                {
                    row = new FrameLayout()
                    {
                        Width = Application.GetRealWidth(200),
                        Height = Application.GetRealHeight(56),
                    };
                    contentView.AddChidren(row);
                }
                var btn = new Button()
                {
                    Width = Application.GetRealWidth(88),
                    Height = Application.GetRealHeight(40),
                    Radius = (uint)Application.GetRealHeight(18),
                    BorderColor = CSS_Color.PromptingColor1,
                    BorderWidth = (uint)Application.GetRealWidth(2),
                    TextAlignment = TextAlignment.Center,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    SelectedTextColor = CSS_Color.MainBackgroundColor,
                    SelectedBackgroundColor = CSS_Color.MainColor,
                };
                if (attr.value.Count > 0)
                {
                    btn.Text = attr.value[0];
                }
                if (index % 3 == 1)
                {
                    btn.Gravity = Gravity.CenterHorizontal;
                }
                else if (index % 3 == 2)
                {
                    btn.X = Application.GetRealWidth(208);
                }
                row.AddChidren(btn);
                btn.MouseUpEventHandler = (sender, e) => {
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add(attr.key, "");
                    Control.Ins.SendWriteCommand(device, d);
                    new System.Threading.Thread(() => {
                        System.Threading.Thread.Sleep(2000);
                        Application.RunOnMainThread(() => {
                            btn.IsSelected = false;
                        });
                    }) { IsBackground = true }.Start();
                };
                index++;
            }
        }
        #endregion
        #region ■ 设备状态反馈_______________________
        /// <summary>
        /// 设备状态反馈
        /// </summary>
        /// <param name="i_LocalDevice"></param>
        public override void DeviceStatuPush(Function i_LocalDevice)
        {
            return;
        }
        #endregion
        #region ■ 发送各种命令_______________________
        #endregion
        #region ■ 刷新界面状态_______________________
        /// <summary>
        /// 刷新界面状态
        /// </summary>
        private void RefreshFormStatu()
        {
            return;
        }
        #endregion
    }
}