JLChen
2020-11-27 0f8f6ad183a9595a82f3229029b16cbcf62bf8ff
HDL_ON/UI/UI0-Public/Widget/UpdateTipDialog.cs
@@ -1,7 +1,6 @@
using System;
using Shared;
using HDL_ON.UI.CSS;
using System.Collections.Generic;
namespace HDL_ON.UI
{
@@ -25,7 +24,7 @@
        /// <param name="cancelAction"></param>
        /// <param name="cancelID"></param>
        /// <param name="confirmID"></param>
        void ShowDialogBase(string titleStr, string tipStr, List<string> msgList, Action okAction, Action cancelAction, int cancelID = StringId.Ignore, int confirmID = StringId.Update)
        void ShowDialogBase(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction, bool isForceUpdate, int cancelID = StringId.Ignore, int confirmID = StringId.Update)
        {
            this.BackgroundColor = CSS_Color.DialogTransparentColor1;
@@ -66,35 +65,32 @@
            };
            contentView.AddChidren(btnTip);
            //方案1
            int listViewY = btnTip.Bottom + Application.GetMinRealAverage(10);
            int lineY = Application.GetRealHeight(250);
            int btnMesY = btnTip.Bottom + Application.GetMinRealAverage(5);
            int lineY = Application.GetRealHeight(258);
            var listView = new VerticalScrolViewLayout()
            VerticalScrolViewLayout mesView = new VerticalScrolViewLayout()
            {
                X = Application.GetRealWidth(25),
                Width = contentView.Width - Application.GetRealWidth(50),
                Y = listViewY,
                Height = lineY - listViewY,
                X = Application.GetRealWidth(16),
                Y = btnMesY,
                Width = contentView.Width - Application.GetRealWidth(32),
                Height = lineY - btnMesY - Application.GetMinRealAverage(5),
            };
            contentView.AddChidren(listView);
            contentView.AddChidren(mesView);
            //方案2
            //Button btnMes = new Button()
            //{
            //    Gravity = Gravity.CenterHorizontal,
            //    X = Application.GetRealWidth(25),
            //    Y = btnTip.Bottom + Application.GetMinRealAverage(28),
            //    Width = contentView.Width - Application.GetRealWidth(50),
            //    Height = lineY - listViewY,
            //    TextAlignment = TextAlignment.TopLeft,
            //    TextColor = CSS_Color.TextualColor,
            //    TextSize = CSS_FontSize.TextFontSize,
            //    IsMoreLines = true,
            //    Text = msgStr,
            Button btnMes = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = mesView.Width,
                Height = mesView.Height,
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.TextFontSize,
                IsMoreLines = true,
                Text = msgStr,
                //BackgroundColor = CSS_Color.AuxiliaryColor2
            //};
            //listView.AddChidren(btnMes);
            };
            mesView.AddChidren(btnMes);
            Button btnLine = new Button()
            {
@@ -105,23 +101,198 @@
            };
            contentView.AddChidren(btnLine);
            Button btnCancel = new Button()
            if (!isForceUpdate)
            {
                Y = btnLine.Bottom,
                Width = Application.GetRealWidth(144),
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = cancelID,
                int Width144 = Application.GetRealWidth(144);
                Button btnCancel = new Button()
                {
                    Y = btnLine.Bottom,
                    Width = Width144,
                    Height = Application.GetRealHeight(44),
                    TextAlignment = TextAlignment.Center,
                    TextColor = CSS_Color.TextualColor,
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextID = cancelID,
                };
                contentView.AddChidren(btnCancel);
                Button btnConfirm = new Button()
                {
                    X = contentView.Width - Width144,
                    Y = btnLine.Y,
                    Width = Width144,
                    Height = Application.GetRealHeight(44),
                    TextAlignment = TextAlignment.Center,
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextColor = CSS_Color.MainBackgroundColor,
                    BackgroundColor = CSS_Color.MainColor,
                    TextID = confirmID,
                };
                contentView.AddChidren(btnConfirm);
                //例:右下圆角 大小为50
                int mRectCornerID = HDLUtils.RectCornerBottomRight;
                btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
                btnCancel.MouseUpEventHandler += (sender, e) =>
                {
                    this.Close();
                    cancelAction?.Invoke();
                };
                btnConfirm.MouseUpEventHandler += (sender, e) =>
                {
                    this.Close();
                    okAction?.Invoke();
                };
            }
            else
            {
                Button btnConfirm = new Button()
                {
                    Y = btnLine.Y,
                    Width = contentView.Width,
                    Height = Application.GetRealHeight(44),
                    TextAlignment = TextAlignment.Center,
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextColor = CSS_Color.MainBackgroundColor,
                    BackgroundColor = CSS_Color.MainColor,
                    TextID = confirmID,
                };
                contentView.AddChidren(btnConfirm);
                //例:右下圆角 大小为50
                int mRectCornerID = HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerBottomLeft;
                btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
                btnConfirm.MouseUpEventHandler += (sender, e) =>
                {
                    //dialog禁止关闭
                    okAction?.Invoke();
                };
            }
            Button btnHeadImage = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetMinRealAverage(152),
                Width = Application.GetMinRealAverage(160),
                Height = Application.GetMinRealAverage(160),
                BorderColor = 0x00000000,
                BorderWidth = 0,
                UnSelectedImagePath = "Public/Dialog/DialogTipTitleIcon_3.png",
            };
            contentView.AddChidren(btnCancel);
            this.AddChidren(btnHeadImage);
            this.Show();
        }
        /// <summary>
        /// 加载提示更新Dialog
        /// </summary>
        /// <param name="titleStr"></param>
        /// <param name="tipStr"></param>
        /// <param name="msgStr"></param>
        /// <param name="okAction"></param>
        /// <param name="cancelAction"></param>
        public void ShowUpdateDialog(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction = null)
        {
            this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, cancelAction, false);
        }
        /// <summary>
        /// 加载强制更新Dialog
        /// Dialog不关闭
        /// </summary>
        /// <param name="titleStr"></param>
        /// <param name="tipStr"></param>
        /// <param name="msgStr"></param>
        /// <param name="okAction"></param>
        /// <param name="cancelAction"></param>
        public void ShowForcedUpdateDialog(string titleStr, string tipStr, string msgStr, Action okAction)
        {
            this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, null, true);
        }
        /// <summary>
        /// 初始化Dialog
        /// </summary>
        /// <param name="titleStr"></param>
        /// <param name="tipStr"></param>
        /// <param name="msgStr"></param>
        /// <param name="okAction"></param>
        /// <param name="cancelAction"></param>
        /// <param name="cancelID"></param>
        /// <param name="confirmID"></param>
        void ShowTipDialogBase(string titleStr, string msgStr, Action okAction, int confirmID = StringId.Close)
        {
            this.BackgroundColor = CSS_Color.DialogTransparentColor1;
            FrameLayout contentView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetMinRealAverage(223),
                Width = Application.GetRealWidth(288),
                Height = Application.GetRealHeight(302),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
                BorderWidth = 0,
                BorderColor = 0x00000000,
            };
            this.AddChidren(contentView);
            Button btnTitle = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetMinRealAverage(95),
                Height = Application.GetMinRealAverage(30),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
                Text = titleStr
            };
            contentView.AddChidren(btnTitle);
            int btnMesY = btnTitle.Bottom + Application.GetMinRealAverage(5);
            int lineY = Application.GetRealHeight(258);
            VerticalScrolViewLayout mesView = new VerticalScrolViewLayout()
            {
                X = Application.GetRealWidth(16),
                Y = btnMesY,
                Width = contentView.Width - Application.GetRealWidth(32),
                Height = lineY - btnMesY - Application.GetMinRealAverage(5),
            };
            contentView.AddChidren(mesView);
            Button btnMes = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = mesView.Width,
                Height = mesView.Height,
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.TextFontSize,
                IsMoreLines = true,
                Text = msgStr,
                BackgroundColor = CSS_Color.AuxiliaryColor2
            };
            mesView.AddChidren(btnMes);
            Button btnLine = new Button()
            {
                Y = lineY,
                Height = Application.GetRealHeight(1),
                Width = contentView.Width,
                BackgroundColor = CSS_Color.DividingLineColor,
            };
            contentView.AddChidren(btnLine);
            Button btnConfirm = new Button()
            {
                X = btnCancel.Right,
                Y = btnLine.Y,
                Width = Application.GetRealWidth(144),
                Width = contentView.Width,
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.SubheadingFontSize,
@@ -131,14 +302,8 @@
            };
            contentView.AddChidren(btnConfirm);
            //例:右下圆角 大小为50
            int mRectCornerID = HDLUtils.RectCornerBottomRight;
            int mRectCornerID = HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerBottomLeft;
            btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
            btnCancel.MouseUpEventHandler += (sender, e) =>
            {
                this.Close();
                cancelAction?.Invoke();
            };
            btnConfirm.MouseUpEventHandler += (sender, e) =>
            {
@@ -158,53 +323,23 @@
            };
            this.AddChidren(btnHeadImage);
            if(msgList != null && msgList.Count > 0)
            {
                foreach(var mes in msgList)
                {
                    Button btnMes = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = listView.Width,
                        Height = Application.GetRealHeight(17),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = CSS_Color.TextualColor,
                        TextSize = CSS_FontSize.TextFontSize,
                        Text = mes,
                    };
                    contentView.AddChidren(btnMes);
                }
            }
            this.Show();
        }
        ///// <summary>
        ///// 加载提示Dialog
        ///// </summary>
        ///// <param name="titleStr"></param>
        ///// <param name="tipStr"></param>
        ///// <param name="msgStr"></param>
        ///// <param name="okAction"></param>
        ///// <param name="cancelAction"></param>
        //public void ShowDialog(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction = null)
        //{
        //    this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, cancelAction);
        //}
        /// <summary>
        /// 加载提示Dialog
        /// 加载提示通知Dialog
        /// </summary>
        /// <param name="titleStr"></param>
        /// <param name="tipStr"></param>
        /// <param name="msgList"></param>
        /// <param name="msgStr"></param>
        /// <param name="okAction"></param>
        /// <param name="cancelAction"></param>
        public void ShowDialog(string titleStr, string tipStr, List<string> msgList, Action okAction, Action cancelAction = null)
        public void ShowTipDialog(string titleStr, string msgStr, Action okAction)
        {
            this.ShowDialogBase(titleStr, tipStr, msgList, okAction, cancelAction);
            this.ShowTipDialogBase(titleStr, msgStr, okAction);
        }
    }
}