| | |
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 做成一个存在于右上角的菜单控件
|
| | | /// 做成一个存在于右上角的菜单控件(非楼层菜单,都可以使用)
|
| | | /// </summary>
|
| | | public class TopRightMenuControl : FrameLayout
|
| | | {
|
| | |
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 前回选择的行
|
| | | /// 背景容器控件
|
| | | /// </summary>
|
| | | private FrameRowControl oldRowFrame = null;
|
| | | private FrameLayout frameBack = null;
|
| | | /// <summary>
|
| | | /// 行高度
|
| | | /// </summary>
|
| | |
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 做成一个存在于右上角的菜单控件
|
| | | /// 做成一个存在于右上角的菜单控件(非楼层菜单,都可以使用)
|
| | | /// </summary>
|
| | | /// <param name="i_RowCount">一共有几行(不含标题)</param>
|
| | | /// <param name="i_widthType">这个菜单的宽度模式,目前只支持
|
| | |
| | | }
|
| | |
|
| | | //背景
|
| | | var frameBack = new FrameLayout();
|
| | | this.frameBack = new FrameLayout();
|
| | | frameBack.X = Application.GetRealWidth(662 - (RowWidth - 395));
|
| | | frameBack.Y = Application.GetRealHeight(161);
|
| | | frameBack.Width = Application.GetRealWidth(RowWidth);
|
| | |
| | | #region ■ 添加菜单___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加菜单行
|
| | | /// 添加菜单行(UI奇葩变更了,暗色图片为选中,黑色图片为非选中)
|
| | | /// </summary>
|
| | | /// <param name="TextValue">显示的文字</param>
|
| | | /// <param name="unSelectPic">图片</param>
|
| | | /// <param name="selectPic">图片</param>
|
| | | /// <param name="selectPic">图片(暗色图片)</param>
|
| | | /// <param name="unSelectPic">图片(黑色图片)</param>
|
| | | /// <param name="action">单击菜单执行的事件</param>
|
| | | /// <param name="closeOnClick">单击的时候,关闭菜单</param>
|
| | | public void AddRowMenu(string TextValue, string unSelectPic, string selectPic, Action action, bool closeOnClick = true)
|
| | | public void AddRowMenu(string TextValue, string selectPic, string unSelectPic, Action action, bool closeOnClick = true)
|
| | | {
|
| | | var rowFrame = new FrameRowControl();
|
| | | rowFrame.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft;
|
| | | rowFrame.Height = Application.GetRealHeight(RowHeight);
|
| | | listView.AddChidren(rowFrame);
|
| | | rowFrame.MainKeys = listView.ChildrenCount.ToString();
|
| | | //这里特殊,移除掉自身的单击事件
|
| | | rowFrame.RemoveBaseClickEvent();
|
| | | //图标
|
| | | var btnIcon = rowFrame.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = unSelectPic;
|
| | |
| | | btnLine.X = Application.GetRealWidth(81);
|
| | | }
|
| | |
|
| | | if (listView.ChildrenCount == 1)
|
| | | {
|
| | | //第一个菜单默认设置为选择状态
|
| | | this.SetRowSelectStatu(rowFrame, true);
|
| | | this.oldRowFrame = rowFrame;
|
| | | }
|
| | | else
|
| | | {
|
| | | //其他菜单为灰色
|
| | | btnIcon.IsSelected = false;
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | | //初始状态全为非选中状态
|
| | | this.SetRowSelectStatu(rowFrame, false);
|
| | |
|
| | | //选择状态
|
| | | bool happenMove = false;
|
| | | //选择状态(重写底层效果)
|
| | | rowFrame.SelectStatuEvent += (statu) =>
|
| | | {
|
| | | //false为控件自身自动执行,这里不需要还原
|
| | | //false为状态还原,但是状态还原放在鼠标弹起事件里面
|
| | | if (statu == true)
|
| | | {
|
| | | //设置为选择状态
|
| | | this.SetRowSelectStatu(rowFrame, true);
|
| | | this.oldRowFrame = rowFrame;
|
| | | happenMove = false;
|
| | | }
|
| | | };
|
| | |
|
| | | //按键点击
|
| | | rowFrame.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //设置为非选择状态
|
| | | this.SetRowSelectStatu(rowFrame, false);
|
| | |
|
| | | if (closeOnClick == true)
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | }
|
| | | action?.Invoke();
|
| | | };
|
| | |
|
| | | //开始触发移动事件(这个事件会频繁的触发)
|
| | | btnIcon.ButtonHappenMoveEvent += () =>
|
| | | {
|
| | | if (happenMove == false)
|
| | | {
|
| | | //设置为非选择状态
|
| | | this.SetRowSelectStatu(rowFrame, false);
|
| | | }
|
| | | happenMove = true;
|
| | | };
|
| | | }
|
| | | #endregion
|
| | |
| | | var btnText = (NormalViewControl)frame.GetChildren(1);
|
| | | if (btnText != null)
|
| | | {
|
| | | btnText.TextColor = select == true ? UserCenterColor.Current.TextColor1 : UserCenterColor.Current.TextGrayColor1;
|
| | | btnText.IsBold = select;
|
| | | btnText.TextColor = select == true ? UserCenterColor.Current.TextGrayColor1 : UserCenterColor.Current.TextColor1;
|
| | | btnText.IsBold = !select;
|
| | | }
|
| | | //前回选择的菜单为null,或者是相同的东西,则不处理
|
| | | if (this.oldRowFrame == null || this.oldRowFrame.MainKeys == frame.MainKeys)
|
| | | {
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | //前回选择的行还原
|
| | | this.SetRowSelectStatu(this.oldRowFrame, false);
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 重新设置白色部分的坐标
|
| | | /// </summary>
|
| | | /// <param name="XX">真实值(不改变的话填-1)</param>
|
| | | /// <param name="YY">真实值(不改变的话填-1)</param>
|
| | | public void SetLocation(int XX = -1, int YY = -1)
|
| | | {
|
| | | if (XX != -1)
|
| | | {
|
| | | frameBack.X = XX;
|
| | | }
|
| | | if (YY != -1)
|
| | | {
|
| | | frameBack.Y = YY;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|