HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/Device/Logic/CustomText.cs
@@ -10,76 +10,126 @@
        public void Show()
        {
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
            var topFrameLayout = new FrameLayout
            #region  上面的布局代码
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.TextID = MyInternationalizationString.custompush;
            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
            #endregion
            var middle = new FrameLayout
            {
                Height = Application.GetRealHeight(140),
                Y = Application.GetRealHeight(80),
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            AddChidren(topFrameLayout);
            var titleName = new Button
            {
                //TextID = MyInternationalizationString.selection,
                Text = "自定义推送",
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            topFrameLayout.AddChidren(titleName);
            var back = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                X = Application.GetRealWidth(20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            };
            topFrameLayout.AddChidren(back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent();
            };
            var middle = new FrameLayout();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 220);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            this.AddChidren(middle);
            var textBox = new EditText
            var textBox = new EditTextView//EditText
            {
                Width = Application.GetRealWidth(900),
                Width = Application.GetRealWidth(1080),
                Height = Application.GetRealHeight(600),
                X = Application.GetRealWidth(90),
                Y = Application.GetRealHeight(90),
                TextAlignment = TextAlignment.CenterLeft,
                TextAlignment = TextAlignment.TopLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Radius = (uint)Application.GetRealHeight(40),
                BorderColor = ZigbeeColor.Current.LogicLineColor,
                BorderWidth = 2,
                //Text = Common.Logic.CurrentLogic.LogicName,
                //TextID=MyInternationalizationString.automation1,
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Text = Common.Logic.CurrentLogic.LogicCustomPushText,
                TextSize = 14,
            };
            middle.AddChidren(textBox);
            textBox.HideSoftInput();
            var textBtn = new Button
            {
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealHeight(50),
                X = Application.GetRealWidth(1080 - 80 - 50),
                Y = Application.GetRealHeight(550 - 25),
                TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                Text = "50",
            };
            middle.AddChidren(textBtn);
            string s1 = "";
            string s2 = "";
            if (!string.IsNullOrEmpty(Common.Logic.CurrentLogic.LogicCustomPushText))
            {
                textBtn.Text = (50 - Common.Logic.CurrentLogic.LogicCustomPushText.Length).ToString();
            }
            textBox.TextChangeEventHandler += (sender, e) =>
            {
                var leng = e.Length;
                if (leng > 50)
                {
                    var substring = e.Substring(0, 50);
                    s1 = substring;
                    if (s1 == s2)
                    {
                        s2 = s1;
                    }
                    else
                    {
                        if (s2 == "")
                        {
                            s2 = s1;
                        }
                        else
                        {
                            s1 = s2;
                        }
                    }
                    textBox.Text = s2;
                }
                else
                {
                    if (leng == 50)
                    {
                        s2 = e.Substring(0, 50);
                    }
                    else
                    {
                        s1 = "";
                        s2 = "";
                    }
                    textBtn.Text = (50 - leng).ToString();
                }
            };
            var btnsave = new Button
            {
                Height = Application.GetRealHeight(150),
                Y = textBox.Bottom + Application.GetRealHeight(300),
                //Text = "保存",
                Width = Application.GetRealWidth(500),
                Radius = (uint)Application.GetRealHeight(50),
                BackgroundColor = ZigbeeColor.Current.LogicButtonBlueColor,
                X = Application.GetRealWidth(290),
                TextID = MyInternationalizationString.Save,
                Y = middle.Height - Application.GetRealHeight(260),
                X = Application.GetRealWidth(85),
                Height = Application.GetRealHeight(130),
                Width = Application.GetRealWidth(910),
                Radius = (uint)Application.GetRealHeight(60),
                BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
                TextID = MyInternationalizationString.confrim,
                TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                TextSize = 16,
            };
            middle.AddChidren(btnsave);
            middle.AddChidren(btnsave);
            btnsave.MouseUpEventHandler += (sender, e) =>
             {
                 Common.Logic.CurrentLogic.LogicCustomPushText = textBox.Text.Trim();
                 if (string.IsNullOrEmpty(Common.Logic.CurrentLogic.LogicCustomPushText))
                 {
                     var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
                           Language.StringByID(MyInternationalizationString.tiptextnull),
                           Language.StringByID(MyInternationalizationString.confrim));
                           alert.Show();
                           return;
                 }
                 Send.Zj(true, Common.Logic.CurrentLogic);
                 RemoveFromParent();
             };
        }
    }
}