| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 桌布控件
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private FrameLayout frameTable = null;
|
| | | /// <summary>
|
| | | /// 三角形图标
|
| | | /// </summary>
|
| | | private PicViewControl btnTriangle = null;
|
| | | /// <summary>
|
| | | /// 头部圆角控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnTopRadius = null;
|
| | | /// <summary>
|
| | | /// 底部圆角控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnBottomRadius = null;
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 前回选择的行
|
| | | /// </summary>
|
| | | private FrameLayoutControl oldRowFrame = null;
|
| | | private FrameRowControl oldRowFrame = null;
|
| | | /// <summary>
|
| | | /// 行高度
|
| | | /// </summary>
|
| | |
| | | /// <summary>
|
| | | /// 行宽度
|
| | | /// </summary>
|
| | | //private int RowWidth = 449;
|
| | | private int RowWidth = 395;
|
| | | /// <summary>
|
| | | /// 行数
|
| | | /// </summary>
|
| | | private int RowCount = 0;
|
| | | /// <summary>
|
| | | /// 菜单计数
|
| | | /// </summary>
|
| | | private int menuCount = 0;
|
| | | /// <summary>
|
| | | /// 圆角度
|
| | | /// </summary>
|
| | | private int tableRadius = Application.GetMinRealAverage(12);
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 做成一个存在于右上角的菜单控件
|
| | | /// </summary>
|
| | | /// <param name="frame">父容器控件</param>
|
| | | /// <param name="i_RowCount">一共有几行</param>
|
| | | /// <param name="i_width">这个菜单有多宽</param>
|
| | | public TopRightMenuControl(FrameLayout frame, int i_RowCount, int i_width = 395)
|
| | | /// <param name="titleText">标题文本(如果不为空,菜单模式变更为拥有标题的模式)</param>
|
| | | public TopRightMenuControl(int i_RowCount, int i_width = 395, string titleText = null)
|
| | | {
|
| | | this.RowCount = i_RowCount;
|
| | | this.RowWidth = i_width;
|
| | | //初始化画面的控件
|
| | | this.InitFormControl(frame);
|
| | | this.InitFormControl(titleText);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化画面的控件
|
| | | /// </summary>
|
| | | /// <param name="frame">父容器控件</param>
|
| | | private void InitFormControl(FrameLayout frame)
|
| | | private void InitFormControl(string titleText)
|
| | | {
|
| | | this.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
| | | this.MouseUpEventHandler += (sender2, e2) =>
|
| | |
| | | //关闭自身
|
| | | this.RemoveFromParent();
|
| | | };
|
| | | var frame = (FrameLayout)UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
|
| | | frame.AddChidren(this);
|
| | |
|
| | | //最大显示5个
|
| | | int rowCount = this.RowCount > 5 ? 5 : this.RowCount;
|
| | | //桌布
|
| | | this.frameTable = new FrameLayout();
|
| | | //frameTable.X = Application.GetRealWidth(596);
|
| | | //frameTable.Y = Application.GetRealHeight(184);
|
| | | var frameTable = new FrameLayoutControl(false);
|
| | | frameTable.X = Application.GetRealWidth(662 - (RowWidth - 395));
|
| | | frameTable.Y = Application.GetRealHeight(158 + 15 + 1);
|
| | | frameTable.Width = Application.GetRealWidth(RowWidth);
|
| | | frameTable.Height = Application.GetRealHeight(RowHeight * this.RowCount) + (this.RowCount - 1) * ControlCommonResourse.BottomLineHeight;
|
| | | frameTable.Height = Application.GetRealHeight(RowHeight * rowCount);
|
| | | frameTable.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameTable.Radius = (uint)tableRadius / 2;
|
| | | frameTable.BorderColor = UserCenterColor.Current.Transparent;
|
| | | frameTable.RadiusEx = 6;
|
| | | this.AddChidren(frameTable);
|
| | |
|
| | | //头部圆角控件
|
| | | btnTopRadius = new NormalViewControl(frameTable.Width, tableRadius * 2, false);
|
| | | btnTopRadius.Radius = (uint)tableRadius;
|
| | | //btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
| | | frameTable.AddChidren(btnTopRadius);
|
| | | if (RowCount == 1)
|
| | | if (titleText != null)
|
| | | {
|
| | | btnTopRadius.BackgroundColor = UserCenterColor.Current.White;
|
| | | var btnTitle = new NormalViewControl(frameTable.Width - Application.GetRealWidth(81), Application.GetRealHeight(58), false);
|
| | | btnTitle.X = Application.GetRealWidth(81);
|
| | | btnTitle.Y = Application.GetRealHeight(58);
|
| | | btnTitle.Text = titleText;
|
| | | frameTable.AddChidren(btnTitle);
|
| | | }
|
| | | //底部圆角控件
|
| | | btnBottomRadius = new NormalViewControl(frameTable.Width, tableRadius * 2, false);
|
| | | btnBottomRadius.Y = frameTable.Height - tableRadius * 2;
|
| | | btnBottomRadius.Radius = (uint)tableRadius;
|
| | | btnBottomRadius.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameTable.AddChidren(btnBottomRadius);
|
| | |
|
| | | //列表控件
|
| | | this.listView = new VerticalListControl();
|
| | | listView.Height = frameTable.Height;
|
| | | if (rowCount == 5 && titleText != null)
|
| | | {
|
| | | //连带标题,只能显示5行
|
| | | listView.Height = frameTable.Height - Application.GetRealHeight(RowHeight);
|
| | | listView.Y = Application.GetRealHeight(RowHeight);
|
| | | }
|
| | | listView.Radius = frameTable.Radius;
|
| | | frameTable.AddChidren(listView);
|
| | |
|
| | | //三角形图标
|
| | | btnTriangle = new PicViewControl(31, 15);
|
| | | var btnTriangle = new PicViewControl(31, 15);
|
| | | btnTriangle.X = Application.GetRealWidth(980);
|
| | | //btnTriangle.Y = Application.GetRealHeight(169);
|
| | | btnTriangle.Y = Application.GetRealHeight(158);
|
| | | btnTriangle.Y = Application.GetRealHeight(159);
|
| | | btnTriangle.UnSelectedImagePath = "Item/UpperTriangle.png";
|
| | | this.AddChidren(btnTriangle);
|
| | | }
|
| | |
| | | /// <param name="closeOnClick">单击的时候,关闭菜单</param>
|
| | | public void AddRowMenu(string TextValue, string unSelectPic, string selectPic, Action action, bool closeOnClick = true)
|
| | | {
|
| | | NormalViewControl btnLine = null;
|
| | | if (menuCount > 0)
|
| | | {
|
| | | //画线
|
| | | btnLine = new NormalViewControl(Application.GetRealWidth(RowWidth - 81), ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.X = Application.GetRealWidth(81);
|
| | | btnLine.Y = Application.GetRealHeight(RowHeight * menuCount) + menuCount * ControlCommonResourse.BottomLineHeight;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | frameTable.AddChidren(btnLine);
|
| | | }
|
| | | menuCount++;
|
| | |
|
| | | var rowFrame = new FrameLayoutControl();
|
| | | var rowFrame = new FrameRowControl();
|
| | | rowFrame.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft;
|
| | | rowFrame.Height = Application.GetRealHeight(RowHeight);
|
| | | rowFrame.Name = "Menu" + menuCount;
|
| | | if (btnLine != null)
|
| | | {
|
| | | rowFrame.Y = btnLine.Bottom;
|
| | | }
|
| | | if (this.RowCount == 1)
|
| | | {
|
| | | //只有一个菜单
|
| | | rowFrame.Y = tableRadius;
|
| | | rowFrame.Height = Application.GetRealHeight(RowHeight) - tableRadius * 2;
|
| | | }
|
| | | frameTable.AddChidren(rowFrame);
|
| | | listView.AddChidren(rowFrame);
|
| | | rowFrame.MainKeys = listView.ChildrenCount.ToString();
|
| | | //图标
|
| | | var btnIcon = new IconViewControl(81);
|
| | | btnIcon.X = Application.GetRealWidth(81);
|
| | | btnIcon.Gravity = Gravity.CenterVertical;
|
| | | var btnIcon = rowFrame.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = unSelectPic;
|
| | | btnIcon.SelectedImagePath = selectPic;
|
| | | rowFrame.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);
|
| | | //显示文字
|
| | | var btnText = new NormalViewControl(RowWidth - 173, 58, true);
|
| | | var btnText = rowFrame.AddLeftCaption(TextValue, RowWidth - 173);
|
| | | btnText.X = Application.GetRealWidth(173);
|
| | | btnText.Text = TextValue;
|
| | | btnText.Gravity = Gravity.CenterVertical;
|
| | | rowFrame.AddChidren(btnText, ChidrenBindMode.BindEventOnly);
|
| | | if (menuCount > 1)
|
| | | //底线
|
| | | if (listView.ChildrenCount != this.RowCount)
|
| | | {
|
| | | btnIcon.IsSelected = false;
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | var btnLine = rowFrame.AddBottomLine();
|
| | | btnLine.X = Application.GetRealWidth(81);
|
| | | }
|
| | |
|
| | | if (this.RowCount == 1)
|
| | | if (listView.ChildrenCount == 1)
|
| | | {
|
| | | //如果只有一个菜单
|
| | | }
|
| | | else if (menuCount == 1)
|
| | | {
|
| | | //多个菜单模式的第一个菜单
|
| | | rowFrame.Y = tableRadius;
|
| | | rowFrame.Height -= tableRadius;
|
| | | btnIcon.Y -= tableRadius / 2;
|
| | | btnText.Y -= tableRadius / 2;
|
| | | //第一个菜单默认设置为选择状态
|
| | | this.SetRowSelectStatu(rowFrame, true);
|
| | | this.oldRowFrame = rowFrame;
|
| | | }
|
| | | else if (menuCount == this.RowCount)
|
| | | else
|
| | | {
|
| | | //多个菜单模式的最后一个菜单
|
| | | rowFrame.Height -= tableRadius;
|
| | | btnIcon.Y += tableRadius / 2;
|
| | | btnText.Y += tableRadius / 2;
|
| | | //其他菜单为灰色
|
| | | btnIcon.IsSelected = false;
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | |
|
| | | //选择状态
|
| | |
| | | /// </summary>
|
| | | /// <param name="frame">行控件</param>
|
| | | /// <param name="select">选择的状态</param>
|
| | | private void SetRowSelectStatu(FrameLayoutControl frame, bool select)
|
| | | private void SetRowSelectStatu(FrameRowControl frame, bool select)
|
| | | {
|
| | | //图标
|
| | | var btnIcon = (IconViewControl)frame.GetChildren(0);
|
| | |
| | | var btnText = (NormalViewControl)frame.GetChildren(1);
|
| | | if (btnText != null)
|
| | | {
|
| | | //btnText.TextColor = select == true ? UserCenterColor.Current.TextColor3 : UserCenterColor.Current.TextColor1;
|
| | | btnText.TextColor = select == true ? UserCenterColor.Current.TextColor1 : UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | | //背景色
|
| | | //frame.BackgroundColor = select == true ? UserCenterColor.Current.BlackBackGround : UserCenterColor.Current.White;
|
| | |
|
| | | if (this.RowCount == 1)
|
| | | {
|
| | | //如果只有一个菜单的话
|
| | | //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
| | | //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
| | | return;
|
| | | }
|
| | | //前回选择的菜单为null,或者是相同的东西,则不处理
|
| | | if (this.oldRowFrame == null || this.oldRowFrame.Name == frame.Name)
|
| | | if (this.oldRowFrame == null || this.oldRowFrame.MainKeys == frame.MainKeys)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (frame.Name == "Menu1")
|
| | | {
|
| | | //如果点击的是第一个菜单的话,变黑色
|
| | | //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
| | | }
|
| | | else
|
| | | {
|
| | | //变回白色
|
| | | //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.White;
|
| | | }
|
| | |
|
| | | if (frame.Name == "Menu" + this.RowCount)
|
| | | {
|
| | | //如果点击的是最后一个菜单的话,变黑色
|
| | | //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround;
|
| | | }
|
| | | else
|
| | | {
|
| | | //变回白色
|
| | | //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.White;
|
| | | }
|
| | | //前回选择的行还原
|
| | | this.SetRowSelectStatu(this.oldRowFrame, false);
|
| | | }
|