| | |
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 场景和功能之间相互切换的Tab控件(完成初始化后,会根据默认选择调用回调函数)
|
| | | /// <para>场景和功能之间相互切换的Tab控件(完成初始化后,会根据默认选择调用回调函数)</para>
|
| | | /// <para>2020.03.10变更:它变更为文字型菜单控件</para>
|
| | | /// </summary>
|
| | | public class SceneFunctionSwitchControl : FrameLayout
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 选择事件 1:场景 2:功能
|
| | | /// 选择事件(从0开始)
|
| | | /// </summary>
|
| | | public Action<int> SelectTabEvent = null;
|
| | |
|
| | | private int m_nowSelectIndex = 1;
|
| | | private int m_nowSelectIndex = 0;
|
| | | /// <summary>
|
| | | /// 当前选择的分支 1:场景 2:功能
|
| | | /// 当前选择的分支(从0开始)
|
| | | /// </summary>
|
| | | public int nowSelectIndex
|
| | | {
|
| | | get { return m_nowSelectIndex; }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 所有名字的控件
|
| | | /// </summary>
|
| | | private List<NormalViewControl> listNameControl = new List<NormalViewControl>();
|
| | | /// <summary>
|
| | | /// 所有线的控件
|
| | | /// </summary>
|
| | | private List<NormalViewControl> listLineControl = new List<NormalViewControl>();
|
| | | /// <summary>
|
| | | /// 默认的那个菜单
|
| | | /// </summary>
|
| | | private FrameLayoutStatuControl frameDefult = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | public SceneFunctionSwitchControl()
|
| | | {
|
| | | this.Height = Application.GetRealHeight(90);
|
| | | this.Y = Application.GetRealHeight(40);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件(事件要至于它之前)
|
| | | /// 初始化控件(事件要至于它之前)
|
| | | /// </summary>
|
| | | public void InitControl()
|
| | | /// <param name="listTitleText">菜单文字列表</param>
|
| | | public void InitControl(List<string> listTitleText)
|
| | | {
|
| | | var btnTemp = new NormalViewControl(10, 10, false);
|
| | | btnTemp.TextID = R.MyInternationalizationString.uScence;
|
| | | btnTemp.TextSize = 16;
|
| | |
|
| | | //场景框(点击范围有点小,需要扩大它的点击范围)
|
| | | var frameScene = new FrameLayoutControl();
|
| | | frameScene.UseClickStatu = false;
|
| | | frameScene.Height = Application.GetRealHeight(90);
|
| | | frameScene.Width = btnTemp.GetRealWidthByText(16);
|
| | | frameScene.X = ControlCommonResourse.XXLeft;
|
| | | this.AddChidren(frameScene);
|
| | | //场景
|
| | | var btnScene = new NormalViewControl(frameScene.Width, Application.GetRealHeight(63), false);
|
| | | btnScene.Text = btnTemp.Text;
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextColor2;
|
| | | frameScene.AddChidren(btnScene, ChidrenBindMode.BindEventOnly);
|
| | | //底线
|
| | | var btnSceneLine = new NormalViewControl(40, 10, true);
|
| | | btnSceneLine.Y = btnScene.Bottom + Application.GetRealHeight(14);
|
| | | btnSceneLine.X = btnScene.X + btnScene.Width / 2 - Application.GetRealWidth(40) / 2;
|
| | | btnSceneLine.Radius = (uint)Application.GetRealHeight(10) / 2;
|
| | | btnSceneLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | frameScene.AddChidren(btnSceneLine, ChidrenBindMode.BindEventOnly);
|
| | |
|
| | | btnTemp.TextID = R.MyInternationalizationString.uFunction;
|
| | | //功能框(点击范围有点小,需要扩大它的点击范围)
|
| | | var frameFunc = new FrameLayoutControl();
|
| | | frameFunc.UseClickStatu = false;
|
| | | frameFunc.Height = Application.GetRealHeight(90);
|
| | | frameFunc.Width = btnTemp.GetRealWidthByText(16);
|
| | | frameFunc.X = frameScene.Right + Application.GetRealWidth(58);
|
| | | this.AddChidren(frameFunc);
|
| | | //功能
|
| | | var btnFunc = new NormalViewControl(frameFunc.Width, Application.GetRealHeight(63), false);
|
| | | btnFunc.Text = btnTemp.Text;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | frameFunc.AddChidren(btnFunc, ChidrenBindMode.BindEventOnly);
|
| | | //底线
|
| | | var btnFuncLine = new NormalViewControl(40, 10, true);
|
| | | btnFuncLine.Y = btnFunc.Bottom + Application.GetRealHeight(14);
|
| | | btnFuncLine.X = btnFunc.X + btnFunc.Width / 2 - Application.GetRealWidth(40) / 2;
|
| | | btnFuncLine.Radius = (uint)Application.GetRealHeight(10) / 2;
|
| | | btnFuncLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | frameFunc.AddChidren(btnFuncLine, ChidrenBindMode.BindEventOnly);
|
| | | btnFuncLine.Visible = false;
|
| | |
|
| | | frameScene.ButtonClickEvent += (sender, e) =>
|
| | | //做成头部菜单文字
|
| | | int XX = 0;
|
| | | for (int i = 0; i < listTitleText.Count; i++)
|
| | | {
|
| | | //场景分支选择
|
| | | if (this.m_nowSelectIndex == 1)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.m_nowSelectIndex = 1;
|
| | |
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFunc.TextSize = 14;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnSceneLine.Visible = true;
|
| | | btnFuncLine.Visible = false;
|
| | |
|
| | | this.SelectTabEvent?.Invoke(1);
|
| | | };
|
| | |
|
| | | frameFunc.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //功能分支选择
|
| | | if (this.m_nowSelectIndex == 2)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.m_nowSelectIndex = 2;
|
| | |
|
| | | btnScene.TextSize = 14;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnFunc.TextSize = 16;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFuncLine.Visible = true;
|
| | | btnSceneLine.Visible = false;
|
| | |
|
| | | this.SelectTabEvent?.Invoke(2);
|
| | | };
|
| | | btnTemp.Text = listTitleText[i];
|
| | | //开始初始化
|
| | | XX = this.InitTitleTextControl(i, listTitleText[i], btnTemp.GetRealWidthByText(), XX);
|
| | | }
|
| | | //回调方法
|
| | | if (this.m_nowSelectIndex == 1)
|
| | | this.frameDefult.ButtonClickEvent?.Invoke(null, null);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化标题控件
|
| | | /// </summary>
|
| | | /// <param name="i_index"></param>
|
| | | /// <param name="titleText"></param>
|
| | | private int InitTitleTextControl(int i_index, string titleText, int realWidth, int XX)
|
| | | {
|
| | | //场景框(点击范围有点小,需要扩大它的点击范围)
|
| | | var frameBack = new FrameLayoutStatuControl();
|
| | | frameBack.UseClickStatu = false;
|
| | | frameBack.Height = Application.GetRealHeight(90);
|
| | | frameBack.Width = realWidth;
|
| | | frameBack.X = XX + Application.GetRealWidth(58);
|
| | | this.AddChidren(frameBack);
|
| | | //名称
|
| | | var btnName = new NormalViewControl(frameBack.Width, Application.GetRealHeight(63), false);
|
| | | btnName.Text = titleText;
|
| | | btnName.TextAlignment = TextAlignment.Center;
|
| | | if (m_nowSelectIndex == i_index)
|
| | | {
|
| | | this.m_nowSelectIndex = 0;
|
| | | frameScene.ButtonClickEvent?.Invoke(null, null);
|
| | | this.frameDefult = frameBack;
|
| | | //选择状态
|
| | | btnName.TextSize = 16;
|
| | | btnName.IsBold = true;
|
| | | btnName.TextColor = UserCenterColor.Current.TextColor2;
|
| | | }
|
| | | if (this.m_nowSelectIndex == 2)
|
| | | else
|
| | | {
|
| | | this.m_nowSelectIndex = 0;
|
| | | frameFunc.ButtonClickEvent?.Invoke(null, null);
|
| | | btnName.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | }
|
| | | frameBack.AddChidren(btnName, ChidrenBindMode.BindEventOnly);
|
| | | //添加缓存
|
| | | this.listNameControl.Add(btnName);
|
| | |
|
| | | //底线
|
| | | var btnLine = new NormalViewControl(40, 10, true);
|
| | | btnLine.Y = btnName.Bottom + Application.GetRealHeight(14);
|
| | | btnLine.X = btnName.X + btnName.Width / 2 - Application.GetRealWidth(40) / 2;
|
| | | btnLine.Radius = (uint)Application.GetRealHeight(10) / 2;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | frameBack.AddChidren(btnLine, ChidrenBindMode.BindEventOnly);
|
| | | if (m_nowSelectIndex != i_index)
|
| | | {
|
| | | btnLine.Visible = false;
|
| | | }
|
| | | //添加缓存
|
| | | this.listLineControl.Add(btnLine);
|
| | |
|
| | | frameBack.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //选择的是同一个分支,则无效
|
| | | if (this.m_nowSelectIndex == i_index && e != null)
|
| | | {
|
| | | //手动点击的才处理
|
| | | return;
|
| | | }
|
| | | this.m_nowSelectIndex = i_index;
|
| | | //当前文字变色
|
| | | btnName.TextSize = 16;
|
| | | btnName.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnName.IsBold = true;
|
| | | btnLine.Visible = true;
|
| | |
|
| | | //还原其他的颜色
|
| | | for (int i = 0; i < listNameControl.Count; i++)
|
| | | {
|
| | | if (this.m_nowSelectIndex != i)
|
| | | {
|
| | | listNameControl[i].TextSize = 14;
|
| | | listNameControl[i].IsBold = false;
|
| | | listNameControl[i].TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | |
|
| | | listLineControl[i].Visible = false;
|
| | | }
|
| | | }
|
| | | this.SelectTabEvent?.Invoke(i_index);
|
| | | };
|
| | |
|
| | | //返回这个控件的右坐标
|
| | | return frameBack.Right;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <summary>
|
| | | /// 设置初始选择(请在初始化完成之前调用)
|
| | | /// </summary>
|
| | | /// <param name="index">1:场景 2:功能</param>
|
| | | /// <param name="index">从0开始</param>
|
| | | public void SetDefultIndex(int index)
|
| | | {
|
| | | this.m_nowSelectIndex = index;
|