黄学彪
2019-11-13 8b9ce384b26c414db32f98e94e088f5334869c2d
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/FrameLayoutControls/FrameLayoutControl.cs
@@ -36,6 +36,17 @@
        /// </summary>
        public int chidrenYaxis = 0;
        /// <summary>
        /// 圆角度(安卓和IOS或许需要预编译)
        /// </summary>
        public uint RadiusEx
        {
            set
            {
                this.Radius = value;
            }
        }
        #endregion
        #region ■ 初始化_____________________________
@@ -50,7 +61,15 @@
            this.MouseUpEventHandler += ChildrenUpEvent;
            this.MouseDownEventHandler += ChildrenDownEvent;
        }
        }
        /// <summary>
        /// 做成一个普通的FrameLayout控件
        /// </summary>
        /// <param name="flage">没啥用的东西</param>
        public FrameLayoutControl(bool flage)
        {
        }
        #endregion
@@ -63,14 +82,21 @@
        /// <param name="chidrenBindMode">变更的绑定模式</param>
        public void ChangedChidrenBindMode(View view, ChidrenBindMode chidrenBindMode)
        {
            if (view is Button)
            if (view is ButtonBase)
            {
                //子控件移除事件
                Button button = (Button)view;
                button.MouseUpEventHandler -= ChildrenUpEvent;
                ButtonBase button = (ButtonBase)view;
                button.ButtonClickEvent -= ChildrenUpEvent;
                button.MouseDownEventHandler -= ChildrenDownEvent;
                this.BindChidrenEvent(view, chidrenBindMode);
            }
            else if (view is ImageView)
            {
                view.MouseUpEventHandler -= ChildrenUpEvent;
                view.MouseDownEventHandler -= ChildrenDownEvent;
                this.BindChidrenEvent(view, chidrenBindMode);
            }
            else if (view is ViewGroup)
            {
@@ -82,11 +108,11 @@
                    {
                        break;
                    }
                    if (myView is Button)
                    if (myView is ButtonBase)
                    {
                        //子控件移除事件
                        Button button = (Button)myView;
                        button.MouseUpEventHandler -= ChildrenUpEvent;
                        ButtonBase button = (ButtonBase)myView;
                        button.ButtonClickEvent -= ChildrenUpEvent;
                        button.MouseDownEventHandler -= ChildrenDownEvent;
                    }
                }
@@ -105,17 +131,30 @@
        /// <param name="chidrenBindMode"></param>
        private void BindChidrenEvent(View view, ChidrenBindMode chidrenBindMode)
        {
            if (view is Button && chidrenBindMode != ChidrenBindMode.NotBind)
            if (chidrenBindMode == ChidrenBindMode.NotBind)
            {
                return;
            }
            if (view is ButtonBase)
            {
                //为子控件添加事件
                Button button = (Button)view;
                button.MouseUpEventHandler -= ChildrenUpEvent;
                ButtonBase button = (ButtonBase)view;
                button.ButtonClickEvent -= ChildrenUpEvent;
                button.MouseDownEventHandler -= ChildrenDownEvent;
                button.MouseUpEventHandler += ChildrenUpEvent;
                button.ButtonClickEvent += ChildrenUpEvent;
                button.MouseDownEventHandler += ChildrenDownEvent;
            }
            else if (view is ViewGroup && chidrenBindMode != ChidrenBindMode.NotBind)
            else if (view is ImageView)
            {
                //自身也添加事件
                view.MouseUpEventHandler -= ChildrenUpEvent;
                view.MouseDownEventHandler -= ChildrenDownEvent;
                view.MouseUpEventHandler += ChildrenUpEvent;
                view.MouseDownEventHandler += ChildrenDownEvent;
            }
            else if (view is ViewGroup)
            {
                //为子控件添加事件
                ViewGroup groupContr = (ViewGroup)view;
@@ -126,14 +165,14 @@
                    {
                        break;
                    }
                    if (myView is Button)
                    if (myView is ButtonBase)
                    {
                        //为子控件添加事件
                        Button button = (Button)myView;
                        button.MouseUpEventHandler -= ChildrenUpEvent;
                        ButtonBase button = (ButtonBase)myView;
                        button.ButtonClickEvent -= ChildrenUpEvent;
                        button.MouseDownEventHandler -= ChildrenDownEvent;
                        button.MouseUpEventHandler += ChildrenUpEvent;
                        button.ButtonClickEvent += ChildrenUpEvent;
                        button.MouseDownEventHandler += ChildrenDownEvent;
                    }
                }
@@ -191,8 +230,24 @@
        /// <param name="e">E.</param>
        private void ChildrenUpEvent(object sender, MouseEventArgs e)
        {
            //调用委托
            ButtonClickEvent?.Invoke(sender, e);
            if (sender is FrameLayoutControl)
            {
                //LOG出力
                this.WriteLog();
            }
            try
            {
                //调用委托
                ButtonClickEvent?.Invoke(sender, e);
            }
            catch (Exception ex)
            {
                //出现未知错误
                var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                alert.Show();
                //Log出力
                HdlLogLogic.Current.WriteLog(ex);
            }
        }
        #endregion
@@ -247,7 +302,7 @@
            //设置选择状态
            this.SetClickSelectStatu();
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                System.Threading.Thread.Sleep(waiTime);
                Application.RunOnMainThread(() =>
@@ -255,8 +310,7 @@
                    //设置不选择状态
                    this.SetClickNotSelectStatu();
                });
            })
            { IsBackground = true }.Start();
            });
        }
        /// <summary>
@@ -280,5 +334,40 @@
        }
        #endregion
        #region ■ Log出力____________________________
        /// <summary>
        /// 该控件所属的界面名字
        /// </summary>
        private string formName = null;
        /// <summary>
        /// Log出力
        /// </summary>
        private void WriteLog()
        {
            if (formName == null)
            {
                formName = string.Empty;
                View myView = this.Parent;
                for (; ; )
                {
                    if (myView == null)
                    {
                        break;
                    }
                    else if (myView is CommonFormBase)
                    {
                        formName = ((CommonFormBase)myView).FormID;
                        break;
                    }
                    myView = myView.Parent;
                }
            }
            HdlLogLogic.Current.WriteLog(1, formName + ".FrameLayoutControl 被点击");
        }
        #endregion
    }
}