old mode 100755
new mode 100644
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 做成一个存在于右上角的楼层菜单控件
|
| | | /// </summary>
|
| | | public class TopRightFloorMenuControl : FrameLayout
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | | /// <summary>
|
| | | /// 前回选择的行
|
| | | /// </summary>
|
| | | private FrameRowControl oldRowFrame = null;
|
| | | /// <summary>
|
| | | /// 背景容器控件
|
| | | /// </summary>
|
| | | private FrameLayout frameBack = null;
|
| | | /// <summary>
|
| | | /// 行高度
|
| | | /// </summary>
|
| | | private int RowHeight = 150;
|
| | | /// <summary>
|
| | | /// 行宽度
|
| | | /// </summary>
|
| | | private int RowWidth = 395;
|
| | | /// <summary>
|
| | | /// 行数
|
| | | /// </summary>
|
| | | private int RowCount = 0;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 做成一个存在于右上角的楼层菜单控件
|
| | | /// </summary>
|
| | | /// <param name="i_RowCount">一共有几行(不含标题)</param>
|
| | | /// <param name="i_widthType">这个菜单的宽度模式,目前只支持
|
| | | /// <para>1: 395宽度</para>
|
| | | /// <para>2: 449宽度</para>
|
| | | /// </param>
|
| | | /// <param name="titleText">标题文本(如果不为空,菜单模式变更为拥有标题的模式)</param>
|
| | | public TopRightFloorMenuControl(int i_RowCount, int i_widthType, string titleText = null)
|
| | | {
|
| | | this.RowCount = i_RowCount;
|
| | | if (i_widthType == 1)
|
| | | {
|
| | | this.RowWidth = 395;
|
| | | }
|
| | | else if (i_widthType == 2)
|
| | | {
|
| | | this.RowWidth = 449;
|
| | | }
|
| | | //初始化画面的控件
|
| | | this.InitFormControl(titleText, i_widthType);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化画面的控件
|
| | | /// </summary>
|
| | | private void InitFormControl(string titleText, int i_widthType)
|
| | | {
|
| | | 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;
|
| | | if (titleText != null)
|
| | | {
|
| | | //449宽度的时候,即使明细已经超过了5个,但是还是可以+1的,因为这个模式多了一张图片
|
| | | if (rowCount < 5 || i_widthType == 2)
|
| | | {
|
| | | //菜单+1
|
| | | rowCount++;
|
| | | }
|
| | | }
|
| | |
|
| | | //背景
|
| | | this.frameBack = new FrameLayout();
|
| | | frameBack.X = Application.GetRealWidth(662 - (RowWidth - 395));
|
| | | frameBack.Y = Application.GetRealHeight(161);
|
| | | frameBack.Width = Application.GetRealWidth(RowWidth);
|
| | | frameBack.Height = Application.GetRealHeight(RowHeight * rowCount + 16);
|
| | | frameBack.BackgroundImagePath = "MenuGroud/TopRightMenu" + i_widthType + "_" + rowCount + ".png";
|
| | | this.AddChidren(frameBack);
|
| | |
|
| | | var frameTable = new FrameLayout();
|
| | | frameTable.Y = Application.GetRealHeight(16);
|
| | | frameTable.Height = Application.GetRealHeight(RowHeight * rowCount);
|
| | | frameBack.AddChidren(frameTable);
|
| | |
|
| | | if (titleText != null)
|
| | | {
|
| | | var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(58), false);
|
| | | btnTitle.X = Application.GetRealWidth(81);
|
| | | btnTitle.Y = Application.GetRealHeight(58 + 16);
|
| | | btnTitle.Text = titleText;
|
| | | frameTable.AddChidren(btnTitle);
|
| | | }
|
| | |
|
| | | //列表控件
|
| | | this.listView = new VerticalListControl();
|
| | | listView.Radius = (uint)Application.GetRealHeight(17);
|
| | | if (titleText != null)
|
| | | {
|
| | | //拥有标题
|
| | | listView.Y = Application.GetRealHeight(RowHeight);
|
| | | listView.Height = frameTable.Height - Application.GetRealHeight(RowHeight);
|
| | | }
|
| | | else
|
| | | {
|
| | | //没有标题
|
| | | listView.Height = frameTable.Height;
|
| | | }
|
| | | frameTable.AddChidren(listView);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 添加菜单___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加菜单行
|
| | | /// </summary>
|
| | | /// <param name="floorId">楼层id</param>
|
| | | /// <param name="action">单击菜单执行的事件</param>
|
| | | /// <param name="closeOnClick">单击的时候,关闭菜单</param>
|
| | | public void AddRowMenu(string floorId, 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();
|
| | | //图标
|
| | | var btnIcon = rowFrame.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = "Floor/Floor.png";
|
| | | btnIcon.SelectedImagePath = "Floor/FloorSelected.png";
|
| | | //显示文字
|
| | | string TextValue = HdlResidenceLogic.Current.GetFloorNameById(floorId);
|
| | | var btnText = rowFrame.AddLeftCaption(TextValue, RowWidth - 173);
|
| | | btnText.X = Application.GetRealWidth(173);
|
| | | //底线
|
| | | if (listView.ChildrenCount != this.RowCount)
|
| | | {
|
| | | var btnLine = rowFrame.AddBottomLine();
|
| | | btnLine.X = Application.GetRealWidth(81);
|
| | | }
|
| | |
|
| | | if (floorId == Common.Config.Instance.Home.CurrentFloorId)
|
| | | {
|
| | | //当前楼层默认设置为选择状态
|
| | | this.SetRowSelectStatu(rowFrame, true);
|
| | | this.oldRowFrame = rowFrame;
|
| | | }
|
| | | else
|
| | | {
|
| | | //其他菜单为灰色
|
| | | btnIcon.IsSelected = false;
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | |
|
| | | //选择状态
|
| | | rowFrame.SelectStatuEvent += (statu) =>
|
| | | {
|
| | | //false为控件自身自动执行,这里不需要还原
|
| | | if (statu == true)
|
| | | {
|
| | | //设置为选择状态
|
| | | this.SetRowSelectStatu(rowFrame, true);
|
| | | this.oldRowFrame = rowFrame;
|
| | | }
|
| | | };
|
| | |
|
| | | //按键点击
|
| | | rowFrame.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (closeOnClick == true)
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | }
|
| | | action?.Invoke();
|
| | | };
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 设置选择状态_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设置选择状态
|
| | | /// </summary>
|
| | | /// <param name="frame">行控件</param>
|
| | | /// <param name="select">选择的状态</param>
|
| | | private void SetRowSelectStatu(FrameRowControl frame, bool select)
|
| | | {
|
| | | //图标
|
| | | var btnIcon = (IconViewControl)frame.GetChildren(0);
|
| | | if (btnIcon != null)
|
| | | {
|
| | | btnIcon.IsSelected = select;
|
| | | }
|
| | | //文本
|
| | | var btnText = (NormalViewControl)frame.GetChildren(1);
|
| | | if (btnText != null)
|
| | | {
|
| | | btnText.TextColor = select == true ? UserCenterColor.Current.TextColor1 : UserCenterColor.Current.TextGrayColor1;
|
| | | 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
|
| | | }
|
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | { |
| | | /// <summary> |
| | | /// 做成一个存在于右上角的楼层菜单控件 |
| | | /// </summary> |
| | | public class TopRightFloorMenuControl : FrameLayout |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 列表控件 |
| | | /// </summary> |
| | | private VerticalListControl listView = null; |
| | | /// <summary> |
| | | /// 前回选择的行 |
| | | /// </summary> |
| | | private FrameRowControl oldRowFrame = null; |
| | | /// <summary> |
| | | /// 背景容器控件 |
| | | /// </summary> |
| | | private FrameLayout frameBack = null; |
| | | /// <summary> |
| | | /// 行高度 |
| | | /// </summary> |
| | | private int RowHeight = 150; |
| | | /// <summary> |
| | | /// 行宽度 |
| | | /// </summary> |
| | | private int RowWidth = 395; |
| | | /// <summary> |
| | | /// 行数 |
| | | /// </summary> |
| | | private int RowCount = 0; |
| | | /// <summary> |
| | | /// 当前楼层id |
| | | /// </summary> |
| | | private string nowFloorId = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 做成一个存在于右上角的楼层菜单控件 |
| | | /// </summary> |
| | | /// <param name="i_RowCount">一共有几行(不含标题)</param> |
| | | /// <param name="i_widthType">这个菜单的宽度模式,目前只支持 |
| | | /// <para>1: 395宽度</para> |
| | | /// <para>2: 449宽度</para> |
| | | /// </param> |
| | | /// <param name="i_floorId">当前选择的楼层ID</param> |
| | | /// <param name="titleText">标题文本(如果不为空,菜单模式变更为拥有标题的模式)</param> |
| | | public TopRightFloorMenuControl(int i_RowCount, int i_widthType,string i_floorId, string titleText = null) |
| | | { |
| | | this.nowFloorId = i_floorId; |
| | | this.RowCount = i_RowCount; |
| | | if (i_widthType == 1) |
| | | { |
| | | this.RowWidth = 395; |
| | | } |
| | | else if (i_widthType == 2) |
| | | { |
| | | this.RowWidth = 449; |
| | | } |
| | | //初始化画面的控件 |
| | | this.InitFormControl(titleText, i_widthType); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化画面的控件 |
| | | /// </summary> |
| | | private void InitFormControl(string titleText, int i_widthType) |
| | | { |
| | | 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; |
| | | if (titleText != null) |
| | | { |
| | | //449宽度的时候,即使明细已经超过了5个,但是还是可以+1的,因为这个模式多了一张图片 |
| | | if (rowCount < 5 || i_widthType == 2) |
| | | { |
| | | //菜单+1 |
| | | rowCount++; |
| | | } |
| | | } |
| | | |
| | | //背景 |
| | | this.frameBack = new FrameLayout(); |
| | | frameBack.X = Application.GetRealWidth(662 - (RowWidth - 395)); |
| | | frameBack.Y = Application.GetRealHeight(161); |
| | | frameBack.Width = Application.GetRealWidth(RowWidth); |
| | | frameBack.Height = Application.GetRealHeight(RowHeight * rowCount + 16); |
| | | frameBack.BackgroundImagePath = "MenuGroud/TopRightMenu" + i_widthType + "_" + rowCount + ".png"; |
| | | this.AddChidren(frameBack); |
| | | |
| | | var frameTable = new FrameLayout(); |
| | | frameTable.Y = Application.GetRealHeight(16); |
| | | frameTable.Height = Application.GetRealHeight(RowHeight * rowCount); |
| | | frameBack.AddChidren(frameTable); |
| | | |
| | | if (titleText != null) |
| | | { |
| | | var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(58), false); |
| | | btnTitle.X = Application.GetRealWidth(81); |
| | | btnTitle.Y = Application.GetRealHeight(58 + 16); |
| | | btnTitle.Text = titleText; |
| | | frameTable.AddChidren(btnTitle); |
| | | } |
| | | |
| | | //列表控件 |
| | | this.listView = new VerticalListControl(); |
| | | listView.Radius = (uint)Application.GetRealHeight(17); |
| | | if (titleText != null) |
| | | { |
| | | //拥有标题 |
| | | listView.Y = Application.GetRealHeight(RowHeight); |
| | | listView.Height = frameTable.Height - Application.GetRealHeight(RowHeight); |
| | | } |
| | | else |
| | | { |
| | | //没有标题 |
| | | listView.Height = frameTable.Height; |
| | | } |
| | | frameTable.AddChidren(listView); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 添加菜单___________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加菜单行 |
| | | /// </summary> |
| | | /// <param name="floorId">楼层id</param> |
| | | /// <param name="action">单击菜单执行的事件</param> |
| | | /// <param name="closeOnClick">单击的时候,关闭菜单</param> |
| | | public void AddRowMenu(string floorId, 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(); |
| | | //图标 |
| | | var btnIcon = rowFrame.AddLeftIcon(81); |
| | | btnIcon.UnSelectedImagePath = "Floor/Floor.png"; |
| | | btnIcon.SelectedImagePath = "Floor/FloorSelected.png"; |
| | | //显示文字 |
| | | string TextValue = HdlResidenceLogic.Current.GetFloorNameById(floorId); |
| | | var btnText = rowFrame.AddLeftCaption(TextValue, RowWidth - 173); |
| | | btnText.X = Application.GetRealWidth(173); |
| | | //底线 |
| | | if (listView.ChildrenCount != this.RowCount) |
| | | { |
| | | var btnLine = rowFrame.AddBottomLine(); |
| | | btnLine.X = Application.GetRealWidth(81); |
| | | } |
| | | |
| | | if (this.nowFloorId == floorId) |
| | | { |
| | | //当前楼层默认设置为选择状态 |
| | | this.SetRowSelectStatu(rowFrame, true); |
| | | this.oldRowFrame = rowFrame; |
| | | } |
| | | else |
| | | { |
| | | //其他菜单为灰色 |
| | | btnIcon.IsSelected = false; |
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1; |
| | | } |
| | | |
| | | //选择状态 |
| | | rowFrame.SelectStatuEvent += (statu) => |
| | | { |
| | | //false为控件自身自动执行,这里不需要还原 |
| | | if (statu == true) |
| | | { |
| | | //设置为选择状态 |
| | | this.SetRowSelectStatu(rowFrame, true); |
| | | this.oldRowFrame = rowFrame; |
| | | } |
| | | }; |
| | | |
| | | //按键点击 |
| | | rowFrame.ButtonClickEvent += (sender, e) => |
| | | { |
| | | if (closeOnClick == true) |
| | | { |
| | | this.RemoveFromParent(); |
| | | } |
| | | action?.Invoke(); |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 设置选择状态_______________________ |
| | | |
| | | /// <summary> |
| | | /// 设置选择状态 |
| | | /// </summary> |
| | | /// <param name="frame">行控件</param> |
| | | /// <param name="select">选择的状态</param> |
| | | private void SetRowSelectStatu(FrameRowControl frame, bool select) |
| | | { |
| | | //图标 |
| | | var btnIcon = (IconViewControl)frame.GetChildren(0); |
| | | if (btnIcon != null) |
| | | { |
| | | btnIcon.IsSelected = select; |
| | | } |
| | | //文本 |
| | | var btnText = (NormalViewControl)frame.GetChildren(1); |
| | | if (btnText != null) |
| | | { |
| | | btnText.TextColor = select == true ? UserCenterColor.Current.TextColor1 : UserCenterColor.Current.TextGrayColor1; |
| | | 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 |
| | | } |
| | | } |