📄 psgeneralcontrol.cs
字号:
namespace Imps.Client.Pc.Options
{
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Pc.Utils;
using Imps.Client.Pc.WndlessControls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using Imps.Utils;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
internal class PsGeneralControl : OptionsControlBase
{
private WndlessControlCollection _controlCollection;
private bool _duringAgeOrBirthdayChanging;
private IFrameworkWindow _frameworkWnd;
private UButton btnMoodPhrases;
private menu_widget cmMoodPhrases;
private XComboBox comboBoxBloodType;
private XComboBox comboBoxGender;
private IContainer components;
private DateTimeSelectControl ctlBirthdate;
private GroupBox groupBoxMain;
private XLabel label1;
private XLabel labelBirthday;
private XLabel lbBloodType;
private XLabel lbHoroscope;
private XLabel lbLunarAnimal;
private LinkLabel LinkFeike;
private menu_widget m_menu_edit;
private ToolStripMenuItem m_menuitem_cancel;
private ToolStripMenuItem m_menuitem_copy;
private ToolStripMenuItem m_menuitem_cut;
private ToolStripMenuItem m_menuitem_delete;
private ToolStripMenuItem m_menuitem_paste;
private ToolStripMenuItem m_menuitem_selectall;
private ToolStripSeparator m_menuitem_spt1;
private ToolStripSeparator m_menuitem_spt2;
private ChatEditCtrlManager m_textBoxNicknameMng;
private ChatEditCtrlManager m_txtMoodPharseMng;
private XNumericUpDown numericUpDownAge;
private XTextBox textBoxHoroscope;
private XTextBox textBoxLunarAnimal;
private ChatRichTextBox textBoxNickname;
private XTextBox textBoxProfile;
private XTextBox textBoxSid;
private ChatRichTextBox txtMoodPharse;
private XButton xBtnProtrait;
private XComboBox xcbPerBirthday;
private GroupBox xGroupBox1;
private GroupBox xGroupBox2;
private XLabel xLabel2;
private XLabel xLabelFeike;
private XLabel xLabelScore;
private WndlessPortrait xpbProtrait;
private WndlessScorePictureBox xpbScore;
private XTextBox xtbCity;
private XTextBox xtbProvince;
public PsGeneralControl(IFrameworkWindow frameworkWnd)
{
this._frameworkWnd = frameworkWnd;
this.InitializeComponent();
this.InitializeWndlessControl();
this.textBoxProfile.Visible = false;
try
{
this.init_menu();
this.m_txtMoodPharseMng = new ChatEditCtrlManager(this.txtMoodPharse, false);
this.txtMoodPharse.MouseDown += new MouseEventHandler(this.on_richedit_mousedown);
this.m_txtMoodPharseMng.DefaultTextFont = this.Font;
this.m_txtMoodPharseMng.ConvertString = new DelegateConvert(StringHelper.EncodString);
if (EnvHelper.DynamicGifCtlRegistered)
{
this.m_txtMoodPharseMng.ConvertSympol = true;
}
this.m_txtMoodPharseMng.SympolSize = new Size(14, 14);
this.m_textBoxNicknameMng = new ChatEditCtrlManager(this.textBoxNickname, false);
this.textBoxNickname.MouseDown += new MouseEventHandler(this.on_richedit_mousedown);
this.m_textBoxNicknameMng.DefaultTextFont = SystemFonts.get_DefaultFont();
this.txtMoodPharse.Font = this.Font;
this.textBoxNickname.Font = this.Font;
this.m_textBoxNicknameMng.ConvertString = new DelegateConvert(StringHelper.EncodString);
if (EnvHelper.DynamicGifCtlRegistered)
{
this.m_textBoxNicknameMng.ConvertSympol = true;
}
this.m_textBoxNicknameMng.SympolSize = new Size(14, 14);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
this.SetLimitation();
this.ctlBirthdate.MinDateTime = new DateTime(0x76c, 1, 1);
this.ctlBirthdate.MaxDateTime = Imps.Client.Core.User.ServerTime;
this.InitBloodType();
this.InitPermissions();
this.numericUpDownAge.MaxLength = 2;
this.numericUpDownAge.SetAcceptDigitOnly();
this.handleUiEvent();
this.InitScoreValue();
}
public PsGeneralControl(IFrameworkWindow frameworkWnd, bool showPer) : this(frameworkWnd)
{
if (!showPer)
{
this.xcbPerBirthday.Visible = false;
}
}
private void ActiveUser_PersonalInfoChanged(object sender, PropertiesChangedEventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
if (e.ContainsProperty("Portrait"))
{
ControlHelper.FadeinImage(this.xpbProtrait, this.ActiveUser.PersonalInfo.Portrait);
}
});
}
private void btnMoodPhrases_Click(object sender, EventArgs e)
{
this.cmMoodPhrases.Show(this.btnMoodPhrases, 5, 0x1b);
}
private static Horoscope calHoroscope(DateTime date)
{
string sHoroscope;
if (date.Year == PersonalInfoBase.NullBirthDate.Year)
{
return Horoscope.Unknown;
}
ChineseCalendar calendar = new ChineseCalendar(date);
return (Horoscope) calendar.FormatHoroscope(out sHoroscope);
}
private static LunarAnimal calLunarAnimal(DateTime date)
{
ChineseCalendar calendar = new ChineseCalendar(date);
if ((date >= calendar.MinSupportedDateTime) && (date <= calendar.MaxSupportedDateTime))
{
return IMPSEnums.GetEnumByDescription<LunarAnimal>(calendar.LunarAnimal);
}
return LunarAnimal.Unknown;
}
public override bool CheckUserInput()
{
string text = this.m_textBoxNicknameMng.Text.Trim();
if (text.Length <= 0)
{
BalloonHelper.ShowInputErrorBallon(this.textBoxNickname, StringTable.PersonalInfo.MsgNicknameNotEmpty, StringTable.Options.TitleInvalidInput);
return false;
}
int num = 0x40;
if (text.Length > num)
{
BalloonHelper.ShowInputErrorBallon(this.textBoxNickname, string.Format(StringTable.PersonalInfo.MsgNicknameTooLong, num), StringTable.Options.TitleInvalidInput);
return false;
}
if (text == StringTable.PersonalInfo.NicknameGuest)
{
BalloonHelper.ShowInputErrorBallon(this.textBoxNickname, string.Format(StringTable.PersonalInfo.MsgNicknameReserved, StringTable.PersonalInfo.NicknameGuest), StringTable.Options.TitleInvalidInput);
return false;
}
string text2 = this.m_txtMoodPharseMng.Text.Trim();
num = 0x100;
if (text2.Length > num)
{
BalloonHelper.ShowInputErrorBallon(this.txtMoodPharse, string.Format(StringTable.Presence.MsgMoodPhraseTooLong, num), StringTable.Options.TitleInvalidInput);
return false;
}
num = 0x100;
if (this.textBoxProfile.Text.Length > num)
{
BalloonHelper.ShowInputErrorBallon(this.textBoxProfile, string.Format(StringTable.PersonalInfo.MsgTooLongProfile, num), StringTable.Options.TitleInvalidInput);
return false;
}
DateTime? selectedDateTime = this.ctlBirthdate.SelectedDateTime;
if (this.ctlBirthdate.SelectedYearText == "1900")
{
BalloonHelper.ShowInputErrorBallon(this.numericUpDownAge, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
return false;
}
if (!selectedDateTime.get_HasValue())
{
BalloonHelper.ShowInputErrorBallon(this.numericUpDownAge, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
return false;
}
if ((selectedDateTime.get_Value().Year != 0x76c) && !ImpsHelper.IsBirthdayValid(selectedDateTime.get_Value(), 1, 0x63, Imps.Client.Core.User.ServerTime))
{
BalloonHelper.ShowInputErrorBallon(this.numericUpDownAge, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
return false;
}
return true;
}
private void cmMoodPhrases_Opening(object sender, CancelEventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
this.cmMoodPhrases.get_Items().Clear();
MoodPhraseCollection moodPhrases = this._frameworkWnd.AccountManager.CurrentUser.Configuration.UserSetting.MoodPhrases;
for (int j = 0; i < moodPhrases.Count; i++)
{
menu_radioitem _radioitem = new menu_radioitem(StringHelper.GetPaddingStringEndEllipsis(StringHelper.ReplaceCrLfToSpace(moodPhrases[i]), 0x10));
this.cmMoodPhrases.get_Items().Add(_radioitem);
_radioitem.set_ToolTipText(moodPhrases[i]);
if (string.Equals(moodPhrases[i], this.txtMoodPharse.Text))
{
_radioitem.Radioed = true;
}
else
{
_radioitem.add_Click(new EventHandler(this.tiMoodPhrase_Click));
}
}
if (moodPhrases.Count > 0)
{
ToolStripSeparator separator = new ToolStripSeparator();
separator.set_Enabled(false);
this.cmMoodPhrases.get_Items().Add(separator);
}
ToolStripItem item = this.cmMoodPhrases.get_Items().Add(StringTable.User.UI_EraseMoodPhrase);
item.set_ToolTipText(string.Empty);
item.set_Enabled(this.txtMoodPharse.Text.Length > 0);
item.add_Click(new EventHandler(this.tiMoodPhrase_Click));
});
}
public override bool ControlLoad()
{
this.ActiveUser.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this, (IntPtr) this.ActiveUser_PersonalInfoChanged);
this.ActiveUser.ScoreInfo.NewScoreDataArrive += new EventHandler(this.on_score_change);
return base.ControlLoad();
}
public override bool ControlUnload()
{
this.ActiveUser.PersonalInfo.PropertiesChanged -= new EventHandler<PropertiesChangedEventArgs>(this, (IntPtr) this.ActiveUser_PersonalInfoChanged);
this.ActiveUser.ScoreInfo.NewScoreDataArrive -= new EventHandler(this.on_score_change);
return base.ControlUnload();
}
private void ctlBirthdate_SelectedDateTimeChange(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
DateTime? selectedDateTime = this.ctlBirthdate.SelectedDateTime;
this.SetBirthDate(birthday);
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -