📄 mainform.cs
字号:
this.tcMain.HoverImageList.Images.RemoveByKey(item.ID);
}
this.tcMain.SelectedIndex = 0;
this.tcMain.Enabled = false;
}
private void ResetChannels()
{
this.NavigateToTab("ContactList", string.Empty);
}
private void SaveMainFormSetting()
{
try
{
if (base.WindowState == FormWindowState.Normal)
{
Imps.Client.Utils.Win32.RECT rect;
Imps.Client.Core.MainWindowSetting mainWindowSetting = this.CurrentUser.Configuration.UserSetting.MainWindowSetting;
Imps.Client.Utils.Win32.NativeMethods.GetWindowRect(base.Handle, out rect);
mainWindowSetting.LastHeight = rect.Height;
mainWindowSetting.LastWidth = rect.Width;
mainWindowSetting.LastPostionX = rect.Left;
mainWindowSetting.LastPostionY = rect.Top;
this.CurrentUser.Configuration.SaveWndUserCfg();
}
}
catch
{
}
}
private void SetPresenceWhenScreenSaver_TimerTick(object sender, EventArgs e)
{
try
{
if (((Environment.OSVersion.Version >= OS.WindowsVista) && (this.CurrentUser.Configuration.UserSetting.SensorSetting.AwayOnScreenSaver != null)) && (SystemParametersInfo(0x72, 0, ref this.screenSaverRunning, 0) != 0))
{
if (this.screenSaverRunning != 0)
{
this.CurrentUser.Presence.AsyncChangeMainPresence(MainPresence.Away, string.Empty);
this.ChangeOnScreenSaverFlag = true;
}
else
{
if (this.ChangeOnScreenSaverFlag)
{
this.CurrentUser.Presence.AsyncChangeMainPresence(MainPresence.Online, string.Empty);
}
this.ChangeOnScreenSaverFlag = false;
}
}
}
catch
{
}
}
private void SetTrayIconAfterLogon()
{
switch (this.AccountManager.CurrentUser.Presence.MainPresence)
{
case MainPresence.OutToLunch:
case MainPresence.BeRightBack:
case MainPresence.Away:
this.trayIcon.Icon = ImpsTrayIcons.Away;
return;
case MainPresence.Online:
case MainPresence.SmsOnline:
this.trayIcon.Icon = ImpsTrayIcons.Online;
return;
case MainPresence.Offline:
case MainPresence.Invisible:
this.trayIcon.Icon = ImpsTrayIcons.OffLine;
return;
case MainPresence.OnThePhone:
case MainPresence.Busy:
case MainPresence.DoNotDisturb:
case MainPresence.InTheMeeting:
this.trayIcon.Icon = ImpsTrayIcons.Busy;
return;
}
this.trayIcon.Icon = ImpsTrayIcons.OffLine;
}
private void SetTrayIconAndText()
{
switch (this.AccountManager.CurrentUser.Status)
{
case UserAccountStatus.Loginning:
this.SetTrayIconOnPending();
this.SetTrayIconText(AppDictionary.CurrentClientName + "-" + StringTable.User.MsgLoginning);
return;
case UserAccountStatus.Logon:
{
int unreadSysMsgCount = this._mgrSysMsg.UnreadSysMsgCount;
if (unreadSysMsgCount <= 0)
{
this.SetTrayIconAfterLogon();
this.SetTrayIconTextAfterLogon();
return;
}
this.trayIcon.Icon = ImpsTrayIcons.SysMsg;
this.SetTrayIconText(string.Format("您有{0}条未读的系统消息,请点击查看。", unreadSysMsgCount));
return;
}
case UserAccountStatus.Logouting:
this.SetTrayIconOnPending();
this.SetTrayIconText(AppDictionary.CurrentClientName + "-" + StringTable.User.MsgLogouting);
return;
}
this.trayIcon.Icon = ImpsTrayIcons.OffLine;
this.SetTrayIconText(AppDictionary.CurrentClientName + "-" + StringTable.User.MsgNotLogedOn);
}
private void SetTrayIconOnPending()
{
if (this.trayIcon.Icon == ImpsTrayIcons.OffLine)
{
this.trayIcon.Icon = ImpsTrayIcons.Online;
}
else
{
this.trayIcon.Icon = ImpsTrayIcons.OffLine;
}
}
private void SetTrayIconText(string strText)
{
string str = strText.Replace("&", "&&");
string str2 = "";
for (int i = 0; i < (str.Length - 1); i++)
{
if (('&' == str[i]) && ('&' != str[i + 1]))
{
str2 = str2 + "&&";
}
else
{
str2 = str2 + str[i];
}
}
str2 = str2 + str[str.Length - 1];
this.trayIcon.Text = str2;
}
private void SetTrayIconTextAfterLogon()
{
string str = string.Format("({0})", this.AccountManager.CurrentUser.Presence.Text);
int maxlen = ((0x3f - str.Length) - AppDictionary.CurrentClientName.Length) - 1;
this.SetTrayIconText(AppDictionary.CurrentClientName + "-" + StringHelper.GetPaddingString((string) this.AccountManager.CurrentUser.PersonalInfo.Nickname, maxlen, "...") + str);
}
public void ShowAbout(IWin32Window owner)
{
try
{
Imps.Client.Pc.AboutMe form = new Imps.Client.Pc.AboutMe(this);
ControlHelper.ShowDialogCenterOnParent(form, owner);
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this, exception);
}
}
private void ShowEntryPoint()
{
base.SuspendLayout();
if (base.Contains(this.AccountManager.UserInfoControl))
{
this.AccountManager.UserInfoControl.Visible = false;
this.AdBar.Bar.Visible = false;
}
this.tcMain.Visible = false;
this.AccountManager.EntryPointControl.Visible = true;
this.AccountManager.EntryPointControl.Focus();
base.ResumeLayout();
}
public DialogResult ShowOptions(string name)
{
return this.ShowOptions(null, name);
}
public DialogResult ShowOptions(IWin32Window owner, string name)
{
this.InnerOptionsForm.ShowOptions(owner, name);
return DialogResult.OK;
}
private void ShowUserInfo()
{
base.SuspendLayout();
this.AccountManager.EntryPointControl.Visible = false;
this.AccountManager.UserInfoControl.Visible = true;
this.AdBar.Bar.Visible = true;
this.ResetChannels();
this.tcMain.Visible = true;
if (!base.Contains(this.AccountManager.UserInfoControl))
{
this.ContactManager.ContactListControl.Dock = DockStyle.Fill;
this.tpContactList.Controls.Add(this.ContactManager.ContactListControl);
this.ContactManager.ContactListControl.Dock = DockStyle.Fill;
this.tpContactList.Controls.Add(this.ContactManager.ContactListControl);
this.AccountManager.UserInfoControl.Dock = DockStyle.Top;
base.Controls.Add(this.AccountManager.UserInfoControl);
base.Controls.Add(this.AdBar.Bar);
base.menubar.SendToBack();
}
this.TryReplaceContactList();
base.ResumeLayout();
}
private void statusLink_Click(object sender, EventArgs e)
{
if (!(e is MouseEventArgs) || (MouseButtons.Left == (e as MouseEventArgs).Button))
{
try
{
ShellHelper.StartUrl(base.StatusBar.Link);
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this, exception);
}
}
}
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int fuWinIni);
private void tcMain_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.tcMain.SelectedIndex != 0)
{
try
{
XTabPage selectedTab = this.tcMain.SelectedTab;
string name = selectedTab.Name;
ChannelItem index = this.InnerChannelManager.Items.IndexOf(name);
if (index != null)
{
if (selectedTab.Controls.Count == 0)
{
if (index.Channel == null)
{
index.CreateChannel();
}
Control channelControl = index.Channel.ChannelControl;
channelControl.Dock = DockStyle.Fill;
this.tcMain.TabPages[name].Controls.Add(channelControl);
}
index.Channel.Load(index.StrUri, index.Args);
}
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this, exception);
}
}
}
private void timerMain_Tick(object sender, EventArgs e)
{
GlobalTimer.OnTick(sender, e);
this.TryWaitSingletonSingal();
}
private void trayIcon_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (this._mgrSysMsg.Popuped)
{
this._mgrSysMsg.ActivateNotify();
}
else if (this._mgrSysMsg.UnreadSysMsgCount > 0)
{
this._mgrSysMsg.PopMessage();
this._mgrSysMsg.ActivateNotify();
}
else
{
this.ActiveMainWindow();
}
}
}
private void TrayIcon_TimerTick(object sender, EventArgs e)
{
try
{
this.SetTrayIconAndText();
}
catch
{
}
}
private bool TryCheckSingleton()
{
try
{
bool flag;
if (!Imps.Client.Core.Configuration.FixedClientSetting.SingleInstance)
{
return false;
}
this._evSingleton = new EventWaitHandle(false, EventResetMode.AutoReset, @"Local\FetionInstance", out flag);
if (!flag)
{
this._evSingleton.Set();
}
return !flag;
}
catch (Exception)
{
return false;
}
}
private void TryLoadHotKey()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -