2023年10月18日15:27:09
埃克斯动态计算文本宽度
| | |
| | | /// 固定域名,正式环境 |
| | | /// 公共域名就近解析 |
| | | /// </summary> |
| | | public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com"; |
| | | //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com"; |
| | | const string APP_KEY = "HDL-HOME-APP-TEST"; |
| | | const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss"; |
| | | |
| | |
| | | case StringId.onLogic: |
| | | { |
| | | value = "on"; |
| | | if (device.spk== SPK.SensorDryContact) { |
| | | value = "open"; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case StringId.offLogic: |
| | | { |
| | | value = "off"; |
| | | if (device.spk == SPK.SensorDryContact) |
| | | { |
| | | value = "close"; |
| | | } |
| | | } |
| | | break; |
| | | case StringId.youren: |
| | |
| | | case SPK.SensorDryContact2: |
| | | { |
| | | |
| | | string value = this.GetKeyValue("on_off", dicList); |
| | | string value = this.GetKeyValue("contact_status", dicList); |
| | | inputView.btnState.Text = Language.StringByID(StringId.offLogic); |
| | | if (value == "on") |
| | | if (value == "open") |
| | | { |
| | | inputView.btnState.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | if (value == "open") |
| | | { |
| | | button1.Text = Language.StringByID(StringId.onLogic); |
| | | } |
| | |
| | | { |
| | | EventHandler<MouseEventArgs> UpClick = (sender, e) => |
| | | { |
| | | |
| | | this.BackgroundColor = 0x00000000; |
| | | action?.Invoke(this, btnImage, btnName); |
| | | this.BackgroundColor = 0x00000000; |
| | | |
| | | //弹起来还原背景颜色 |
| | | }; |
| | |
| | | TextColor = MusicColor.TextColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Gravity = Gravity.CenterVertical, |
| | | IsMoreLines = true, |
| | | Padding=new Padding(0,0,0,0), |
| | | Name = "btnName", |
| | | }; |
| | |
| | | btnName.MouseDownEventHandler += DownClick; |
| | | btnRightImage.MouseDownEventHandler += DownClick; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 自动计算控件长度 |
| | | /// </summary> |
| | | /// <param name="orientation">位置(左或右)</param> |
| | | /// <param name="frame">父容器</param> |
| | | /// <param name="btnName">备注控件</param> |
| | | /// <param name="btnImage">图标备注控件</param> |
| | | /// <param name="btnNameWidth">备注控件宽度</param> |
| | | /// <param name="btnNameWidthMaxValue">备注控件宽度最大值</param> |
| | | /// <param name="parentDefaultWidthMaxValue">父控件宽度默认最大值</param> |
| | | public void CustomCalculationWidth(Orientation orientation, FrameLayout frame, Button btnName, Button btnImage, int btnNameWidth,int btnNameWidthMaxValue = 110, int parentDefaultWidthMaxValue = 101) |
| | | { |
| | | |
| | | int parentRightX = 226; |
| | | int parentLeftX = 16; |
| | | |
| | | |
| | | if (btnName.GetTextWidth() > Application.GetRealWidth(btnNameWidth)) |
| | | { |
| | | frame.Width = Application.GetRealWidth(parentDefaultWidthMaxValue - btnNameWidth) + btnName.GetTextWidth(); |
| | | if (orientation == Orientation.right) |
| | | { |
| | | frame.X = Application.GetRealWidth(parentRightX + btnNameWidth) - btnName.GetTextWidth(); |
| | | } |
| | | else if (orientation == Orientation.left) |
| | | { |
| | | frame.X = Application.GetRealWidth(parentLeftX); |
| | | } |
| | | btnName.Width = btnName.GetTextWidth(); |
| | | btnImage.X = btnName.Right + Application.GetRealWidth(8); |
| | | } |
| | | |
| | | if (btnName.GetTextWidth() > Application.GetRealWidth(btnNameWidthMaxValue)) |
| | | { |
| | | |
| | | btnName.Width = Application.GetRealWidth(btnNameWidthMaxValue); |
| | | if (orientation == Orientation.right) |
| | | { |
| | | frame.X =Application.GetRealWidth(parentRightX+ btnNameWidth) - btnName.Width; |
| | | } |
| | | else if (orientation == Orientation.left) |
| | | { |
| | | frame.X = Application.GetRealWidth(parentLeftX); |
| | | } |
| | | frame.Width = Application.GetRealWidth(parentDefaultWidthMaxValue - btnNameWidth) + btnName.Width; |
| | | btnImage.X = btnName.Right + Application.GetRealWidth(8); |
| | | } |
| | | |
| | | } |
| | | |
| | | public enum Orientation |
| | | { |
| | | left, |
| | | right, |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | gfSingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png"; |
| | | gfSingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | gfSingleFramLayout.btnLeftImage.Visible = false; |
| | | |
| | | if (gfSingleFramLayout.btnName.GetTextWidth() > Application.GetRealWidth(48)) |
| | | { |
| | | gfSingleFramLayout.singleFramLayout.Width = Application.GetRealWidth(101 - 48) + gfSingleFramLayout.btnName.GetTextWidth(); |
| | | gfSingleFramLayout.singleFramLayout.X = Application.GetRealWidth(226 + 48) - gfSingleFramLayout.btnName.GetTextWidth(); |
| | | gfSingleFramLayout.btnName.Width = gfSingleFramLayout.btnName.GetTextWidth(); |
| | | gfSingleFramLayout.btnRightImage.X = gfSingleFramLayout.btnName.Right + Application.GetRealWidth(8); |
| | | } |
| | | gfSingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right, |
| | | gfSingleFramLayout.singleFramLayout, |
| | | gfSingleFramLayout.btnName, |
| | | gfSingleFramLayout.btnRightImage, |
| | | 48, 200); |
| | | } |
| | | else |
| | | { |
| | |
| | | jdhSingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png"; |
| | | jdhSingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | jdhSingleFramLayout.btnLeftImage.Visible = false; |
| | | jdhSingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right, |
| | | jdhSingleFramLayout.singleFramLayout, |
| | | jdhSingleFramLayout.btnName, |
| | | jdhSingleFramLayout.btnRightImage, |
| | | 48, 200); |
| | | } |
| | | else |
| | | { |
| | |
| | | bfqSingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png"; |
| | | bfqSingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | bfqSingleFramLayout.btnLeftImage.Visible = false; |
| | | |
| | | |
| | | |
| | | bfqSingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.left, |
| | | bfqSingleFramLayout.singleFramLayout, |
| | | bfqSingleFramLayout.btnName, |
| | | bfqSingleFramLayout.btnRightImage, |
| | | 48); |
| | | |
| | | //影库 |
| | | ykSingleFramLayout = new TypeSingleFramLayout(); |
| | |
| | | tvSingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png"; |
| | | tvSingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | tvSingleFramLayout.btnLeftImage.Visible = false; |
| | | tvSingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right, |
| | | tvSingleFramLayout.singleFramLayout, |
| | | tvSingleFramLayout.btnName, |
| | | tvSingleFramLayout.btnRightImage, |
| | | 48, 200); |
| | | } |
| | | else |
| | | { |
| | |
| | | tyySingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png"; |
| | | tyySingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | tyySingleFramLayout.btnLeftImage.Visible = false; |
| | | tyySingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right, |
| | | tyySingleFramLayout.singleFramLayout, |
| | | tyySingleFramLayout.btnName, |
| | | tyySingleFramLayout.btnRightImage, |
| | | 48,200); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | tyySingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical; |
| | | tyySingleFramLayout.btnLeftImage.Visible = false; |
| | | |
| | | if (tyySingleFramLayout.btnName.GetTextWidth() > Application.GetRealWidth(48)) |
| | | { |
| | | tyySingleFramLayout.singleFramLayout.Width = Application.GetRealWidth(101 - 48) + tyySingleFramLayout.btnName.GetTextWidth(); |
| | | tyySingleFramLayout.singleFramLayout.X = Application.GetRealWidth(226 + 48) - tyySingleFramLayout.btnName.GetTextWidth(); |
| | | tyySingleFramLayout.btnName.Width = tyySingleFramLayout.btnName.GetTextWidth(); |
| | | tyySingleFramLayout.btnRightImage.X = tyySingleFramLayout.btnName.Right + Application.GetRealWidth(8); |
| | | } |
| | | tyySingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right, |
| | | tyySingleFramLayout.singleFramLayout, |
| | | tyySingleFramLayout.btnName, |
| | | tyySingleFramLayout.btnRightImage, |
| | | 48, 200); |
| | | |
| | | } |
| | | else |