using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter.HdlBackup
{
///
/// 自动备份的界面
///
public class HdlAutoBackupForm : EditorCommonForm
{
#region ■ 变量声明___________________________
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
public void ShowForm()
{
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//清空bodyFrame
this.ClearBodyFrame();
//body占完整个屏幕
bodyFrameLayout.Y = 0;
bodyFrameLayout.Height = ControlCommonResourse.TopMenuFrameHeight + ControlCommonResourse.TopFrameHeight
+ ControlCommonResourse.BodyFrameHeight;
var btnPic = new NormalViewControl(991, 438, true);
btnPic.UnSelectedImagePath = "Item/AutoBackup.png";
btnPic.Y = Application.GetRealHeight(374);
bodyFrameLayout.AddChidren(btnPic);
//自动备份
var btnAuto = new NormalViewControl(400, 85, true);
btnAuto.Y = Application.GetRealHeight(876);
btnAuto.Gravity = Gravity.CenterHorizontal;
btnAuto.TextID = R.MyInternationalizationString.uAutoBackup;
btnAuto.TextSize = 20;
btnAuto.TextAlignment = TextAlignment.Center;
bodyFrameLayout.AddChidren(btnAuto);
//检测到数据更新,是否需要备份
var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false);
btnMsg.Y = btnAuto.Bottom + Application.GetRealHeight(23);
btnMsg.TextID = R.MyInternationalizationString.uIsHadNotBackupDataOnScan;
btnMsg.TextAlignment = TextAlignment.Center;
btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1;
bodyFrameLayout.AddChidren(btnMsg);
//立即备份(推荐)
var frameback = new FrameLayoutStatuControl();
frameback.UseClickStatu = false;
frameback.Y = Application.GetRealHeight(1201);
frameback.Gravity = Gravity.CenterHorizontal;
frameback.Width = Application.GetRealWidth(746);
frameback.Height = Application.GetRealHeight(184);
frameback.BackgroundImagePath = "Item/BottomButtonGround.png";
bodyFrameLayout.AddChidren(frameback);
var btnBackup = new NormalViewControl(400, 65, true);
btnBackup.IsBold = true;
btnBackup.TextColor = UserCenterColor.Current.White;
btnBackup.TextSize = 16;
btnBackup.Y = Application.GetRealHeight(49);
btnBackup.Gravity = Gravity.CenterHorizontal;
btnBackup.TextAlignment = TextAlignment.Center;
btnBackup.Text = Language.StringByID(R.MyInternationalizationString.uImmediatelyBackup) + "(" + Language.StringByID(R.MyInternationalizationString.uRecommendation) + ")";
frameback.AddChidren(btnBackup, ChidrenBindMode.BindEvent);
frameback.ButtonClickEvent += (sender, e) =>
{
HdlThreadLogic.Current.RunThread(() =>
{
//上传数据
this.UpLoadBackupInfo();
});
};
//暂不提醒
var btnRemind = new NormalViewControl(688, 127, true);
btnRemind.Y = frameback.Bottom + Application.GetRealHeight(52);
btnRemind.Gravity = Gravity.CenterHorizontal;
btnRemind.Radius = (uint)Application.GetRealHeight(127) / 2;
btnRemind.BorderWidth = 1;
btnRemind.BorderColor = UserCenterColor.Current.TextOrangeColor;
btnRemind.TextAlignment = TextAlignment.Center;
btnRemind.TextSize = 16;
btnRemind.TextColor = UserCenterColor.Current.TextGrayColor3;
btnRemind.TextID = R.MyInternationalizationString.uTemporaryStopRemind;
bodyFrameLayout.AddChidren(btnRemind);
btnRemind.ButtonClickEvent += (sender, e) =>
{
HdlAutoBackupLogic.SaveBackupNotPrompted(false, 3);
this.CloseForm();
};
}
#endregion
#region ■ 上传数据___________________________
///
/// 上传数据
///
private void UpLoadBackupInfo()
{
int result = HdlAutoBackupLogic.DoUpLoadAutoBackupData();
if (result == -1)
{
//文件上传失败
string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail);
this.ShowMassage(ShowMsgType.Error, msg);
return;
}
//数据成功上传到服务器
string msg2 = Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceSuccessMsg);
this.ShowMassage(ShowMsgType.Tip, msg2);
Application.RunOnMainThread(() =>
{
this.CloseForm();
});
}
#endregion
}
}