using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter.HdlBackup
{
///
/// 自动备份的设置界面
///
public class HdlAutoBackupSettionForm : UserCenterCommonForm
{
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
public void ShowForm()
{
//设置标题信息
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAutoBackupSettion));
//初始化中部控件
this.InitMiddleFrame();
}
///
/// 初始化中部控件
///
private void InitMiddleFrame()
{
bodyFrameLayout.RemoveAll();
//信息行
var msgRow = new FrameLayout();
msgRow.Y = Application.GetRealHeight(40);
msgRow.Height = ControlCommonResourse.NormalControlHeight;
bodyFrameLayout.AddChidren(msgRow);
//检测到数据更新,是否需要备份
var btnMsg = new RowCenterView(false);
btnMsg.TextID = R.MyInternationalizationString.uIsHadNotBackupDataOnScan;
msgRow.AddChidren(btnMsg);
//立即备份(推荐)
var statuBackupRow = new StatuRowLayout();
statuBackupRow.Y = msgRow.Bottom;
bodyFrameLayout.AddChidren(statuBackupRow);
var btnBackup = new RowCenterView(false);
string txtValue = Language.StringByID(R.MyInternationalizationString.uImmediatelyBackup);
txtValue += " (" + Language.StringByID(R.MyInternationalizationString.uRecommendation) + ")";
btnBackup.Text = txtValue;
statuBackupRow.AddChidren(btnBackup);
statuBackupRow.AddRightIconControl();
statuBackupRow.MouseUpEvent += (sender, e) =>
{
//确认是否上传数据到服务器?
string msg = Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceMsg);
this.ShowConfirmMsg(msg, "UpLoadBackupInfo");
};
//暂不提醒
var statuNextRow = new StatuRowLayout();
statuNextRow.Y = statuBackupRow.Bottom;
bodyFrameLayout.AddChidren(statuNextRow);
var btnNext = new RowCenterView(false);
btnNext.TextID = R.MyInternationalizationString.uTemporaryStopRemind;
statuNextRow.AddChidren(btnNext);
statuNextRow.AddRightIconControl();
statuNextRow.MouseUpEvent += (sender, e) =>
{
HdlAutoBackupLogic.SaveBackupNotPrompted(false, 3);
this.CloseForm();
};
//不再提示
var statuNotRow = new StatuRowLayout();
statuNotRow.Y = statuNextRow.Bottom;
bodyFrameLayout.AddChidren(statuNotRow);
var btnNotReminder = new RowCenterView(false);
btnNotReminder.TextID = R.MyInternationalizationString.uNotPrompted;
statuNotRow.AddChidren(btnNotReminder);
statuNotRow.AddRightIconControl();
statuNotRow.MouseUpEvent += (sender, e) =>
{
//确认不再提示?
string msg = Language.StringByID(R.MyInternationalizationString.uConfirmNotPrompted);
this.ShowConfirmMsg(msg, "DoNotPrompted");
};
}
///
/// 上传数据
///
public void UpLoadBackupInfo()
{
//回避界面卡死问题
new System.Threading.Thread(() =>
{
//上传数据
this.UpLoadBackupInfoAsync();
})
{ IsBackground = true }.Start();
}
///
/// 上传数据
///
public async void UpLoadBackupInfoAsync()
{
int result = await HdlAutoBackupLogic.DoUpLoadAutoBackupData();
if (result == -1)
{
//文件上传失败
string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail);
this.ShowErrorMsg(msg);
return;
}
//数据成功上传到服务器
string msg2 = Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceSuccessMsg);
this.ShowTip(msg2);
Application.RunOnMainThread(() =>
{
this.CloseForm();
});
}
///
/// 执行不再提示
///
public void DoNotPrompted()
{
HdlAutoBackupLogic.SaveBackupNotPrompted(true);
this.CloseForm();
}
}
}