using System;
using System.Collections.Generic;
using Shared.Common;
using System.Text;
namespace Shared.Phone.UserView
{
///
/// User page.
///
public class UserPage : FrameLayout
{
#region ◆ 变量_______________________
///
/// The user menu page.
///
static UserPage userMenuPage;
///
/// 底部单独菜单的宽度-360
///
private static readonly int tabBarEnum_Width = CommonPage.AppRealWidth / 3;
///
/// 底部按钮图片的高度
///
private static readonly int tabBarEnumIMG_Height = 98;
///
/// 底部按钮图片的宽度
///
private static readonly int tabBarEnumIMG_Width = 138;
///
/// 底部按钮图片的Y值
///
private static readonly int tabBarEnumIMG_Y = 3;
///
/// 底部按钮文字的高度
///
private static readonly int tabBarEnumName_Height = 40;
///
/// 底部按钮文字的Y值
///
private static readonly int tabBarEnumName_Y = 98;
#endregion
///
/// 用户界面
///
/// The instance.
public static UserPage Instance
{
get
{
if (userMenuPage == null)
{
userMenuPage = new UserPage { };
}
return userMenuPage;
}
}
///
/// Initializes a new instance of the class.
///
public UserPage()
{
BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor;
Shared.Application.LocationAction += (lon, lat) =>
{
Login.AccountLogic.Instance.ReceiveAppLatAndLon(lon.ToString(), lat.ToString());
};
}
///
/// 用户主体界面(中间部分)
///
public FrameLayout BodyView = new FrameLayout
{
Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.TabbarHeight),
BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor,
};
///
/// 用户菜单界面(底部部分)
///
public FrameLayout BottomMenuView = new FrameLayout
{
Y = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.TabbarHeight),
Height = Application.GetRealHeight(CommonPage.TabbarHeight),
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCBottomColor,
};
#region 分割线
private Button bottomLine = new Button
{
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCBottomLineColor
};
#endregion
#region 底部-主页按钮
///
/// 底部-主页按钮
///
public FrameLayout homePageFL = new FrameLayout
{
Width = Application.GetRealWidth(tabBarEnum_Width),
Height = Application.GetRealHeight(CommonPage.TabbarHeight),
};
///
/// The home page image.
///
public Button homePageIMG = new Button
{
Y = Application.GetRealHeight(tabBarEnumIMG_Y),
Height = Application.GetMinRealAverage(tabBarEnumIMG_Height),
Width = Application.GetMinRealAverage(tabBarEnumIMG_Width),
UnSelectedImagePath = "Navigation/Home.png",
SelectedImagePath = "Navigation/HomeSelected.png",
Gravity = Gravity.CenterHorizontal
};
///
/// The name of the home page.
///
public Button homePageName = new Button
{
Y = Application.GetRealHeight(tabBarEnumName_Y),
Height = Application.GetRealHeight(tabBarEnumName_Height),
TextID = R.MyInternationalizationString.HomePage,
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
Gravity = Gravity.CenterHorizontal,
TextSize = 10
};
#endregion
#region 分类-底部按钮
///
/// 分类-底部按钮
///
public FrameLayout categoryFL = new FrameLayout
{
X = Application.GetRealWidth(tabBarEnum_Width),
Width = Application.GetRealWidth(tabBarEnum_Width),
Height = Application.GetRealHeight(CommonPage.TabbarHeight)
};
///
/// The category image.
///
public Button categoryIMG = new Button
{
Y = Application.GetRealHeight(tabBarEnumIMG_Y),
Height = Application.GetMinRealAverage(tabBarEnumIMG_Height),
Width = Application.GetMinRealAverage(tabBarEnumIMG_Width),
UnSelectedImagePath = "Navigation/Category.png",
SelectedImagePath = "Navigation/CategorySelected.png",
Gravity = Gravity.CenterHorizontal
};
///
/// The name of the category.
///
public Button categoryName = new Button
{
Y = Application.GetRealHeight(tabBarEnumName_Y),
Height = Application.GetRealHeight(tabBarEnumName_Height),
TextID = R.MyInternationalizationString.Category,
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
Gravity = Gravity.CenterHorizontal,
TextSize = 10
};
#endregion
#region 个人中心-底部按钮
///
/// 个人中心-底部按钮
///
public FrameLayout settingFL = new FrameLayout
{
X = Application.GetRealWidth(tabBarEnum_Width * 2),
Width = Application.GetRealWidth(tabBarEnum_Width),
Height = Application.GetRealHeight(CommonPage.TabbarHeight)
};
///
/// The setting image.
///
public Button settingIMG = new Button
{
Y = Application.GetRealHeight(tabBarEnumIMG_Y),
Height = Application.GetMinRealAverage(tabBarEnumIMG_Height),
Width = Application.GetMinRealAverage(tabBarEnumIMG_Width),
UnSelectedImagePath = "Navigation/Setting.png",
SelectedImagePath = "Navigation/SettingSelected.png",
Gravity = Gravity.CenterHorizontal
};
///
/// 个人中心
///
public Button settingName = new Button
{
Y = Application.GetRealHeight(tabBarEnumName_Y),
Height = Application.GetRealHeight(tabBarEnumName_Height),
TextID = R.MyInternationalizationString.Me,
TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
Gravity = Gravity.CenterHorizontal,
TextSize = 10
};
#endregion
#region 强制显示自动化界面
///
/// 强制显示自动化列表界面
///
public void ShowCategoryAutoListForm()
{
//关闭全部界面,直到主页为止
UserCenter.UserCenterLogic.CloseAllOpenForm();
//强制显示自动化列表界面
UserCenter.UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 2;
BottomEventHandler(Instance.categoryIMG, null);
}
#endregion
EventHandler BottomEventHandler = (sender, e) =>
{
if (sender == Instance.homePageIMG || sender == Instance.homePageName)
{
if (Instance.homePageName.IsSelected == true && e != null)
{
//只有是手动点击的时候才处理
return;
}
Instance.BodyView.RemoveAll();
//主页
CommonPage.Instance.IsDrawerLockMode = false;
Instance.homePageName.IsSelected = true;
Instance.homePageIMG.IsSelected = true;
Instance.categoryName.IsSelected = false;
Instance.categoryIMG.IsSelected = false;
Instance.settingName.IsSelected = false;
Instance.settingIMG.IsSelected = false;
var home = new MainPage.HomeMainPageForm();
Instance.BodyView.AddChidren(home);
home.ShowForm();
}
else if (sender == Instance.categoryIMG || sender == Instance.categoryName)
{
if (Instance.categoryName.IsSelected == true && e != null)
{
//只有是手动点击的时候才处理
return;
}
Instance.BodyView.RemoveAll();
//分类
CommonPage.Instance.IsDrawerLockMode = true;
Instance.categoryName.IsSelected = true;
Instance.categoryIMG.IsSelected = true;
Instance.homePageName.IsSelected = false;
Instance.homePageIMG.IsSelected = false;
Instance.settingName.IsSelected = false;
Instance.settingIMG.IsSelected = false;
var category = new Category.CategoryMainForm { };
Instance.BodyView.AddChidren(category);
category.ShowForm();
}
else if (sender == Instance.settingIMG || sender == Instance.settingName)
{
if (Instance.settingName.IsSelected == true && e != null)
{
return;
}
Instance.BodyView.RemoveAll();
//个人中心
CommonPage.Instance.IsDrawerLockMode = true;
Instance.settingName.IsSelected = true;
Instance.settingIMG.IsSelected = true;
Instance.homePageName.IsSelected = false;
Instance.homePageIMG.IsSelected = false;
Instance.categoryName.IsSelected = false;
Instance.categoryIMG.IsSelected = false;
var form = new UserCenter.UserMain.UserMainForm();
Instance.BodyView.AddChidren(form);
form.ShowForm();
}
};
///
/// Fresh this instance.
///
public void Fresh()
{
BottomEventHandler(Instance.homePageIMG, null);
}
///
/// Inits the page.
///
public void InitPage()
{
if (0 < ChildrenCount)
{
return;
}
AddChidren(BodyView);
AddChidren(BottomMenuView);
BottomMenuView.AddChidren(Instance.bottomLine);
Instance.homePageFL.AddChidren(Instance.homePageIMG);
Instance.homePageFL.AddChidren(Instance.homePageName);
BottomMenuView.AddChidren(Instance.homePageFL);
Instance.categoryFL.AddChidren(Instance.categoryIMG);
Instance.categoryFL.AddChidren(Instance.categoryName);
BottomMenuView.AddChidren(Instance.categoryFL);
Instance.settingFL.AddChidren(Instance.settingIMG);
Instance.settingFL.AddChidren(Instance.settingName);
BottomMenuView.AddChidren(Instance.settingFL);
homePageIMG.MouseUpEventHandler += BottomEventHandler;
homePageName.MouseUpEventHandler += BottomEventHandler;
categoryIMG.MouseUpEventHandler += BottomEventHandler;
categoryName.MouseUpEventHandler += BottomEventHandler;
settingIMG.MouseUpEventHandler += BottomEventHandler;
settingName.MouseUpEventHandler += BottomEventHandler;
}
}
}