using System;
|
using HDL_ON.Entity;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
|
namespace HDL_ON.UI
|
{
|
public partial class UserPage : FrameLayout
|
{
|
|
#region 控件列表
|
/// <summary>
|
/// 当前区域
|
/// </summary>
|
FrameLayout bodyView;
|
/// <summary>
|
/// 内容区域
|
/// </summary>
|
FrameLayout ContextView;
|
/// <summary>
|
/// 导航栏区域
|
/// </summary>
|
FrameLayout navigationView;
|
/// <summary>
|
/// 导航栏点击区域
|
/// </summary>
|
FrameLayout NavigationSubView;
|
#region 底部区域控件
|
/// <summary>
|
/// 收藏子区域
|
/// </summary>
|
FrameLayout collectionView;
|
/// <summary>
|
/// 收藏图标
|
/// </summary>
|
Button btnCollectionIcon;
|
/// <summary>
|
/// 收藏文本
|
/// </summary>
|
Button btnCollectionText;
|
/// <summary>
|
/// 分类子区域
|
/// </summary>
|
FrameLayout classificationView;
|
/// <summary>
|
/// 分类图标
|
/// </summary>
|
Button btnClassificationIcon;
|
/// <summary>
|
/// 分类文本
|
/// </summary>
|
Button btnClassificationText;
|
/// <summary>
|
/// 智能子区域
|
/// </summary>
|
FrameLayout intellectualizationView;
|
/// <summary>
|
/// 智能图标
|
/// </summary>
|
Button btnIntellectualizationIcon;
|
/// <summary>
|
/// 智能文本
|
/// </summary>
|
Button btnIntellectualizationText;
|
/// <summary>
|
/// 个人中心子区域
|
/// </summary>
|
FrameLayout personalCenterView;
|
/// <summary>
|
/// 个人中心图标
|
/// </summary>
|
Button btnPersonalCenterIcon;
|
/// <summary>
|
/// 个人中心文本
|
/// </summary>
|
Button btnPersonalCenterText;
|
/// <summary>
|
/// 选中区域
|
/// </summary>
|
FrameLayout navigationSelectionView;
|
/// <summary>
|
/// 选中区域图标
|
/// </summary>
|
Button btnNavigationSelectionIcon;
|
#endregion
|
#endregion
|
|
/// <summary>
|
/// 当前动画效果
|
/// 0:收藏
|
/// 1:分类
|
/// 2:智能
|
/// 3:个人
|
/// </summary>
|
int CurAnimationEffect = 0;
|
|
public void LoadPage()
|
{
|
try
|
{
|
bodyView = this;
|
bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
ContextView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(618 + 17),//导航栏底部界限
|
BackgroundColor = CSS_Color.BackgroundColor,
|
};
|
bodyView.AddChidren(ContextView);
|
|
navigationView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(607),
|
Height = Application.GetMinRealAverage(60),
|
//BackgroundColor = CSS_Color.BackgroundColor
|
};
|
bodyView.AddChidren(navigationView);
|
if (MainPage.Increase)
|
{
|
//ContextView.Height = Application.GetRealHeight(618 + 20);
|
navigationView.Y = Application.GetRealHeight(597 + 5);
|
navigationView.Height = Application.GetRealHeight(70 - 5);
|
}
|
InitBottomView();
|
|
LoadEventList();
|
|
var homePage = new HomePage();
|
ContextView.AddChidren(homePage);
|
homePage.LoadPage();
|
|
//刷新功能状态
|
DB_ResidenceData.residenceData.RefreshResidenceFunctionStatus();
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"UserPage error {ex.Message}");
|
}
|
}
|
|
/// <summary>
|
/// 初始化底部区域
|
/// </summary>
|
void InitBottomView()
|
{
|
navigationSelectionView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(0 - 94 * 3),
|
Y = Application.GetMinRealAverage(4),
|
Width = Application.GetRealWidth(94 * 7),
|
Height = Application.GetRealWidth(38),
|
BackgroundImagePath = "Navigation/UserPageNavbg.png",
|
};
|
navigationView.AddChidren(navigationSelectionView);
|
|
btnNavigationSelectionIcon = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealWidth(6),
|
Width = Application.GetRealWidth(22),
|
Height = Application.GetRealWidth(22),
|
UnSelectedImagePath = "Navigation/HomePageIconOn.png",
|
};
|
navigationSelectionView.AddChidren(btnNavigationSelectionIcon);
|
|
NavigationSubView = new FrameLayout()
|
{
|
Y = Application.GetMinRealAverage(11),
|
Height = Application.GetRealHeight(49),
|
//BackgroundColor=0xFF00F0F0
|
};
|
navigationView.AddChidren(NavigationSubView);
|
|
#region 收藏区域
|
collectionView = new FrameLayout() {
|
Width = Application.GetRealWidth(94),
|
};
|
NavigationSubView.AddChidren(collectionView);
|
btnCollectionIcon = new Button() {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(5),
|
Width = Application.GetMinRealAverage(22),
|
Height = Application.GetMinRealAverage(22),
|
UnSelectedImagePath = "Navigation/HomePageIcon.png",
|
SelectedImagePath = "Public/transparent.png",
|
IsSelected = true,
|
};
|
collectionView.AddChidren(btnCollectionIcon);
|
btnCollectionText = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnCollectionIcon.Bottom,
|
Height = Application.GetRealHeight(16),
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor =CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextID = StringId.Collection,
|
TextAlignment = TextAlignment.Center,
|
IsSelected = true,
|
};
|
collectionView.AddChidren(btnCollectionText);
|
#endregion
|
|
#region 分类区域
|
classificationView = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(94),
|
X = collectionView.Right,
|
};
|
NavigationSubView.AddChidren(classificationView);
|
btnClassificationIcon = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(5),
|
Width = Application.GetMinRealAverage(22),
|
Height = Application.GetMinRealAverage(22),
|
UnSelectedImagePath = "Navigation/ClassificationIcon.png",
|
SelectedImagePath = "Public/transparent.png",
|
};
|
classificationView.AddChidren(btnClassificationIcon);
|
btnClassificationText = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnCollectionIcon.Bottom,
|
Height = Application.GetRealHeight(16),
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextID = StringId.Classification,
|
TextAlignment = TextAlignment.Center,
|
};
|
classificationView.AddChidren(btnClassificationText);
|
#endregion
|
|
#region 智能区域
|
intellectualizationView = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(94),
|
X = classificationView.Right,
|
};
|
NavigationSubView.AddChidren(intellectualizationView);
|
btnIntellectualizationIcon = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(5),
|
Width = Application.GetMinRealAverage(22),
|
Height = Application.GetMinRealAverage(22),
|
UnSelectedImagePath = "Navigation/IntellectualizationIcon.png",
|
SelectedImagePath = "Public/transparent.png",
|
};
|
intellectualizationView.AddChidren(btnIntellectualizationIcon);
|
btnIntellectualizationText = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnCollectionIcon.Bottom,
|
Height = Application.GetRealHeight(16),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextID = StringId.Intellectualization,
|
TextAlignment = TextAlignment.Center,
|
};
|
intellectualizationView.AddChidren(btnIntellectualizationText);
|
#endregion
|
|
#region 个人中心
|
personalCenterView = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(94),
|
X = intellectualizationView.Right,
|
};
|
NavigationSubView.AddChidren(personalCenterView);
|
|
btnPersonalCenterIcon = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(5),
|
Width = Application.GetMinRealAverage(22),
|
Height = Application.GetMinRealAverage(22),
|
UnSelectedImagePath = "Navigation/PersonalCenterIcon.png",
|
SelectedImagePath = "Public/transparent.png",
|
};
|
personalCenterView.AddChidren(btnPersonalCenterIcon);
|
|
btnPersonalCenterText = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnCollectionIcon.Bottom,
|
Height = Application.GetRealHeight(16),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextID = StringId.Personal,
|
TextAlignment = TextAlignment.Center,
|
};
|
personalCenterView.AddChidren(btnPersonalCenterText);
|
#endregion
|
|
var homePage = new HomePage();
|
ContextView.AddChidren(homePage);
|
homePage.LoadPage();
|
}
|
|
/// <summary>
|
/// 切换到收藏界面
|
/// </summary>
|
void ChooseCollection()
|
{
|
if (CurAnimationEffect == 0)
|
{
|
return;
|
}
|
btnClassificationIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
#region 移动动画
|
//移动距离
|
var distance = navigationSelectionView.X - collectionView.X + Application.GetRealWidth(94*3);
|
int total = 10;
|
int sleepTime = 300;
|
if (distance > 200)
|
{
|
sleepTime = 400;
|
total = 30;
|
}
|
else if (distance > 100)
|
{
|
total = 20;
|
}
|
distance /= total;
|
new System.Threading.Thread(() => {
|
int index = 0;
|
CurAnimationEffect = 0;
|
while (index < total+1)
|
{
|
if (CurAnimationEffect != 0)
|
{
|
break;
|
}
|
Application.RunOnMainThread(() =>
|
{
|
//移动
|
if (index < total)
|
{
|
navigationSelectionView.X -= distance;
|
}
|
else
|
{
|
navigationSelectionView.X = collectionView.X - Application.GetRealWidth(94 * 3);
|
btnCollectionText.IsSelected = true;
|
btnCollectionIcon.IsSelected = true;
|
btnClassificationIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
}
|
if (index == (total/2))
|
{
|
btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/HomePageIconOn.png";
|
}
|
//旋转
|
btnNavigationSelectionIcon.SetRotation(-36f * index);
|
});
|
System.Threading.Thread.Sleep(sleepTime / total);
|
index++;
|
}
|
|
Application.RunOnMainThread(() =>
|
{
|
btnNavigationSelectionIcon.SetRotation(0f);
|
});
|
}) { IsBackground = true }.Start();
|
#endregion
|
ContextView.RemoveAll();
|
var homePage = new HomePage();
|
ContextView.AddChidren(homePage);
|
homePage.LoadPage();
|
}
|
/// <summary>
|
/// 切换到分类界面
|
/// </summary>
|
void ChooseClassification()
|
{
|
if (CurAnimationEffect == 1)
|
{
|
return;
|
}
|
btnCollectionIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
#region 移动动画
|
var distance = navigationSelectionView.X - classificationView.X + Application.GetRealWidth(94 * 3);
|
int total = 10;
|
int sleepTime = 300;
|
if (distance > 100 || distance < -100)
|
{
|
total = 20;
|
}
|
distance /= total;
|
new System.Threading.Thread(() =>
|
{
|
if (CurAnimationEffect == 1)
|
{
|
return;
|
}
|
CurAnimationEffect = 1;
|
int index = 0;
|
while (index < total+1)
|
{
|
if (CurAnimationEffect != 1)
|
{
|
break;
|
}
|
Application.RunOnMainThread(() =>
|
{
|
//移动
|
if (index < total)
|
{
|
navigationSelectionView.X -= distance;
|
}
|
else
|
{
|
navigationSelectionView.X = classificationView.X - Application.GetRealWidth(94 * 3);
|
btnClassificationText.IsSelected = true;
|
btnClassificationIcon.IsSelected = true;
|
btnCollectionIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
btnCollectionText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
}
|
if (index == (total / 2 ))
|
{
|
btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/ClassificationIconOn.png";
|
}
|
//旋转
|
if (distance < 0)
|
{
|
btnNavigationSelectionIcon.SetRotation(36f * index);
|
}
|
else
|
{
|
btnNavigationSelectionIcon.SetRotation(-36f * index);
|
}
|
});
|
System.Threading.Thread.Sleep(sleepTime / total);
|
index++;
|
}
|
|
Application.RunOnMainThread(() =>
|
{
|
btnNavigationSelectionIcon.SetRotation(0f);
|
});
|
})
|
{ IsBackground = true }.Start();
|
#endregion
|
ContextView.RemoveAll();
|
var classificaitionView = new ClassificationPage();
|
ContextView.AddChidren(classificaitionView);
|
classificaitionView.LoadPage();
|
|
|
}
|
/// <summary>
|
/// 切换到智能界面
|
/// </summary>
|
void ChooseIntellectualization()
|
{
|
if (CurAnimationEffect == 2)
|
{
|
return;
|
}
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
btnCollectionIcon.IsSelected = false;
|
btnClassificationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
#region 移动动画
|
var distance = navigationSelectionView.X - intellectualizationView.X + Application.GetRealWidth(94 * 3);
|
int total = 10;
|
int sleepTime = 300;
|
if (distance > 100 || distance < -100)
|
{
|
total = 20;
|
}
|
distance /= total;
|
new System.Threading.Thread(() => {
|
if (CurAnimationEffect == 2)
|
{
|
return;
|
}
|
CurAnimationEffect = 2;
|
int index = 0;
|
while (index < total+1)
|
{
|
if(CurAnimationEffect!=2)
|
{
|
break;
|
}
|
Application.RunOnMainThread(() =>
|
{
|
//移动
|
if (index < total)
|
{
|
navigationSelectionView.X -= distance;
|
}
|
else
|
{
|
navigationSelectionView.X = intellectualizationView.X - Application.GetRealWidth(94 * 3);
|
btnIntellectualizationText.IsSelected = true;
|
btnIntellectualizationIcon.IsSelected = true;
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
btnCollectionIcon.IsSelected = false;
|
btnClassificationIcon.IsSelected = false;
|
btnPersonalCenterIcon.IsSelected = false;
|
}
|
if (index == (total / 2 ))
|
{
|
btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/IntellectualizationIconOn.png";
|
}
|
//旋转
|
if (distance < 0)
|
{
|
btnNavigationSelectionIcon.SetRotation(36f * index);
|
}
|
else
|
{
|
btnNavigationSelectionIcon.SetRotation(-36f * index);
|
}
|
});
|
System.Threading.Thread.Sleep(sleepTime / total);
|
index++;
|
}
|
|
Application.RunOnMainThread(() =>
|
{
|
btnNavigationSelectionIcon.SetRotation(0f);
|
});
|
})
|
{ IsBackground = true }.Start();
|
#endregion
|
ContextView.RemoveAll();
|
var intelligenceView = new IntelligencePage();
|
ContextView.AddChidren(intelligenceView);
|
intelligenceView.LoadPage();
|
|
|
}
|
|
/// <summary>
|
/// 切换到个人中心界面
|
/// </summary>
|
void ChoosePersonalCenter()
|
{
|
#if DEBUG
|
if(MainPage.LocalMode)
|
{
|
return;
|
}
|
#endif
|
if (CurAnimationEffect == 3)
|
{
|
return;
|
}
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnPersonalCenterText.IsSelected = false;
|
btnCollectionIcon.IsSelected = false;
|
btnClassificationIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
#region 移动动画
|
var distance = navigationSelectionView.X - personalCenterView.X + Application.GetRealWidth(94 * 3);
|
int total = 10;
|
int sleepTime = 300;
|
if (distance < -200)
|
{
|
sleepTime = 400;
|
total = 30;
|
}
|
else if (distance < -100)
|
{
|
total = 20;
|
}
|
distance /= total;
|
new System.Threading.Thread(() => {
|
CurAnimationEffect = 3;
|
int index = 0;
|
while (index < total+1)
|
{
|
if (CurAnimationEffect != 3)
|
{
|
break;
|
}
|
Application.RunOnMainThread(() =>
|
{
|
//移动
|
if (index < total)
|
{
|
navigationSelectionView.X -= distance;
|
}
|
else
|
{
|
navigationSelectionView.X = personalCenterView.X - Application.GetRealWidth(94 * 3);
|
btnPersonalCenterText.IsSelected = true;
|
btnPersonalCenterIcon.IsSelected = true;
|
btnCollectionText.IsSelected = false;
|
btnClassificationText.IsSelected = false;
|
btnIntellectualizationText.IsSelected = false;
|
btnCollectionIcon.IsSelected = false;
|
btnClassificationIcon.IsSelected = false;
|
btnIntellectualizationIcon.IsSelected = false;
|
}
|
if (index == (total / 2 ))
|
{
|
btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/PersonalCenterIconOn.png";
|
}
|
//旋转
|
btnNavigationSelectionIcon.SetRotation(36f * index);
|
});
|
System.Threading.Thread.Sleep(sleepTime / total);
|
index++;
|
}
|
Application.RunOnMainThread(() =>
|
{
|
btnNavigationSelectionIcon.SetRotation(0f);
|
});
|
})
|
{ IsBackground = true }.Start();
|
#endregion
|
|
ContextView.RemoveAll();
|
var personalCenterPage = new UI.PersonalCenterPage();
|
ContextView.AddChidren(personalCenterPage);
|
personalCenterPage.LoadView();
|
}
|
}
|
}
|