📄 mobileemaillinkcontrol.cs
字号:
namespace Imps.Client.Pc.Options
{
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Utils;
using System;
using System.ComponentModel;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
public class MobileEmailLinkControl : LinkLabel
{
private IFrameworkWindow _iFrameWin;
private IContainer components;
public event EventHandler BindInfoChanged;
public MobileEmailLinkControl()
{
this.InitializeComponent();
}
private void displayMobileEmailLabel()
{
if (FuncLimitedSetting.MobileEmailFuncLimited)
{
base.Visible = false;
}
else
{
bool? isInRunningProvince = this.User.MobileMailInfo.IsInRunningProvince;
if (!isInRunningProvince.GetValueOrDefault() || !isInRunningProvince.get_HasValue())
{
base.Visible = false;
}
else
{
base.Visible = true;
int valueOrDefault = this.User.MobileMailInfo.Binding_Status.GetValueOrDefault();
if (this.User.MobileMailInfo.Binding_Status.get_HasValue())
{
switch (valueOrDefault)
{
case 0:
base.Visible = true;
this.Text = "取消绑定手机邮箱";
return;
case 1:
base.Visible = true;
this.Text = "绑定手机邮箱";
return;
}
}
base.Visible = false;
}
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
public void Init(IFrameworkWindow iFrameworkWin)
{
if (this._iFrameWin == null)
{
this._iFrameWin = iFrameworkWin;
this.displayMobileEmailLabel();
this._iFrameWin.AccountManager.CurrentUser.MobileMailInfo.BindInfoChanged += new EventHandler(this.mobileMailInfo_BindInfoChanged);
base.LinkClicked += new LinkLabelLinkClickedEventHandler(this.MobileEmailLinkControl_LinkClicked);
this._iFrameWin.AccountManager.CurrentUser.MobileMailInfo.OperateReturn += new EventHandler<MobileEmailOperateEventArgs>(this, (IntPtr) this.MobileMailInfo_OperateReturn);
}
}
private void InitializeComponent()
{
this.components = new Container();
}
private void MobileEmailLinkControl_LinkClicked(object sender, EventArgs e)
{
bool? isInRunningProvince = this._iFrameWin.AccountManager.CurrentUser.MobileMailInfo.IsInRunningProvince;
if (!isInRunningProvince.GetValueOrDefault() || !isInRunningProvince.get_HasValue())
{
if (!this._iFrameWin.AccountManager.CurrentUser.MobileMailInfo.IsInRunningProvince.get_HasValue())
{
this._iFrameWin.UnifiedMessageBox.ShowInfo(this, "对不起。目前无法获取手机邮箱状态。\r\n请在下次登录客户端后重试。");
}
else
{
this._iFrameWin.UnifiedMessageBox.ShowInfo(this, "对不起。您所在的省份目前无法通过飞信\r\n使用手机邮箱业务。");
}
}
else if (!MobileMailCommandHelper.CheckMailStatus(this.User))
{
MobileEmailApplyForm form = new MobileEmailApplyForm(this._iFrameWin);
ControlHelper.ShowDialogCenterOnParent(form, this, true);
}
else
{
int valueOrDefault = this.User.MobileMailInfo.Binding_Status.GetValueOrDefault();
if (this.User.MobileMailInfo.Binding_Status.get_HasValue())
{
switch (valueOrDefault)
{
case 0:
if (this._iFrameWin.UnifiedMessageBox.ShowConfirmation(this, "确认要解除飞信与手机邮箱的绑定吗?") == DialogResult.Yes)
{
MobileMailCommandHelper.SendCancelBindRequestAsync(this.User);
}
return;
case 1:
{
MobileEmailBindForm form2 = new MobileEmailBindForm(this._iFrameWin);
ControlHelper.ShowDialogCenterOnParent(form2, this, true);
return;
}
default:
return;
}
}
}
}
private void mobileMailInfo_BindInfoChanged(object sender, EventArgs e)
{
this.displayMobileEmailLabel();
if (this.BindInfoChanged != null)
{
this.BindInfoChanged(sender, e);
}
}
private void MobileMailInfo_OperateReturn(object sender, MobileEmailOperateEventArgs e)
{
if (e.Result)
{
this._iFrameWin.UnifiedMessageBox.ShowInfo(this, "手机邮箱取消绑定成功!");
}
else
{
WebException exception = e.InnerException as WebException;
if (exception != null)
{
if (Convert.ToInt32(((HttpWebResponse) exception.Response).StatusCode) == 0x195)
{
this._iFrameWin.UnifiedMessageBox.ShowWarning("手机邮箱已经取消绑定!");
}
else
{
this._iFrameWin.UnifiedMessageBox.ShowError(this, "手机邮箱取消绑定失败!");
}
}
else
{
this._iFrameWin.UnifiedMessageBox.ShowError(this, "手机邮箱取消绑定失败!");
}
}
}
private Imps.Client.Core.User User
{
get
{
return this._iFrameWin.AccountManager.CurrentUser;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -