⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 5 页
字号:
                        }
                        break;

                    case UserAccountStatus.Logon:
                    {
                        try
                        {
                            this.AccountManager.UserInfoControl.Enabled = true;
                            this.tcMain.Enabled = true;
                            this.ReBuildOperationMenus();
                            this.ShowUserInfo();
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            if (!this.ChannelEventAttached)
                            {
                                this.InnerChannelManager.OnChannelLogoUpdated += new EventHandler(this.InnerChannelManager_OnChannelLogoUpdated);
                                this.InnerChannelManager.OnChannelRetrived += new EventHandler(this.InnerChannelManager_OnChannelRetrived);
                                this.ChannelEventAttached = true;
                            }
                            this.InnerChannelManager.GetChannelsFromServer();
                        }
                        catch (Exception)
                        {
                        }
                        IConversationManager conversationManager = this.ConversationManager;
                        IIVRManager iVRManager = this.IVRManager;
                        return;
                    }
                    default:
                        return;
                }
                this.ShowEntryPoint();
                EnvHelper.StressMemory();
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void DoAfterLoaded(object sender, EventArgs e)
        {
            try
            {
                GlobalTimer.Unregister(new EventHandler(this.DoAfterLoaded));
                if (!ConnectionFactory.HasRegisteredConnectionManager())
                {
                    IConnectionManager manager = new ConnectionManagerImp(this.CurrentUser);
                    ConnectionFactory.RegisterConnectionManager(manager);
                }
                Imps.Client.Pc.LiveUpdate.Create(this);
                GlobalTimer.Register(new EventHandler(this.TrayIcon_TimerTick), 5, TimerHandlerPriority.Low);
                if (Environment.OSVersion.Version >= OS.WindowsVista)
                {
                    GlobalTimer.Register(new EventHandler(this.SetPresenceWhenScreenSaver_TimerTick), 5, TimerHandlerPriority.Low);
                }
                this.RegisterTaskbarCreatedMessage();
                if (!Imps.Client.Utils.sensmon.sensmon.try_register())
                {
                    this.UnifiedMessageBox.ShowWarning(this, StringTable.Framework.MsgFailedRegSensMon);
                }
                if (!EnvHelper.DynamicGifCtlRegistered)
                {
                    this.UnifiedMessageBox.ShowWarning(this, StringTable.Framework.MsgFailedRegDynamicGifCtl);
                }
                this.TryLoadHotKey();
                FuncDispatcher.OnEventHandler(this, this.MainWindowLoaded, EventArgs.Empty);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
                base.Close();
            }
        }

        private void DoLocalization()
        {
            base.Text = AppDictionary.CurrentClientName;
            this.tpContactList.Name = "ContactList";
        }

        private string GetBuildType()
        {
            return "Release";
        }

        private void HandleExceptions()
        {
            Application.ThreadException += new ThreadExceptionEventHandler(this.Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);
        }

        public void HideMainWindow()
        {
            this.trayIcon.Visible = false;
            base.Hide();
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(MainForm));
            this.trayIcon = new NotifyIcon(this.components);
            this.timerMain = new System.Windows.Forms.Timer(this.components);
            this.tbILHover = new ImageList(this.components);
            this.tbILNomal = new ImageList(this.components);
            this.tcMain = new XTabControl();
            this.tpContactList = new XTabPage();
            this.tcMain.SuspendLayout();
            base.SuspendLayout();
            this.trayIcon.MouseClick += new MouseEventHandler(this.trayIcon_MouseClick);
            this.timerMain.Enabled = true;
            this.timerMain.Tick += new EventHandler(this.timerMain_Tick);
            this.tbILHover.ImageStream = (ImageListStreamer) manager.GetObject("tbILHover.ImageStream");
            this.tbILHover.TransparentColor = Color.Transparent;
            this.tbILHover.Images.SetKeyName(0, "tab_buddy.png");
            this.tbILNomal.ImageStream = (ImageListStreamer) manager.GetObject("tbILNomal.ImageStream");
            this.tbILNomal.TransparentColor = Color.Transparent;
            this.tbILNomal.Images.SetKeyName(0, "tab_buddy_hover.png");
            this.tcMain.Animating = false;
            this.tcMain.BackColor = Color.Transparent;
            this.tcMain.BorderColor = Color.Black;
            this.tcMain.Controls.Add(this.tpContactList);
            this.tcMain.CurrentDirection = ScrollDirection.Up;
            this.tcMain.Dock = DockStyle.Fill;
            this.tcMain.EnableToolTip = true;
            this.tcMain.HoverImageList = this.tbILHover;
            this.tcMain.HoverIndex = -1;
            this.tcMain.HoverTabBackColor = Color.White;
            this.tcMain.ImageList = this.tbILNomal;
            this.tcMain.Location = new Point(3, 1);
            this.tcMain.Name = "tcMain";
            this.tcMain.Padding = new Padding(2, 3, 1, 1);
            this.tcMain.ScrollImageButton = null;
            this.tcMain.ScrollRectA = new Rectangle(0, 0, 0, 0);
            this.tcMain.ScrollRectB = new Rectangle(0, 0, 0, 0);
            this.tcMain.SelectedIndex = 0;
            this.tcMain.SelectedTab = this.tpContactList;
            this.tcMain.SelectedTabBackColor = Color.White;
            this.tcMain.ShowScrollMode = ShowScrollMode.Always;
            this.tcMain.Size = new Size(0x161, 0x254);
            this.tcMain.TabHeight = 0x2d;
            this.tcMain.TabIndex = 2;
            this.tcMain.TabWidth = 0x23;
            this.tpContactList.DisplayIndex = 0;
            this.tpContactList.Hided = false;
            this.tpContactList.Image = (Image) manager.GetObject("tpContactList.Image");
            this.tpContactList.ImageIndex = -1;
            this.tpContactList.ImageKey = "";
            this.tpContactList.Location = new Point(0x25, 5);
            this.tpContactList.Name = "tpContactList";
            this.tpContactList.Padding = new Padding(1);
            this.tpContactList.Selected = false;
            this.tpContactList.Size = new Size(0x139, 590);
            this.tpContactList.TabIndex = 0;
            this.tpContactList.TabRectangle = new Rectangle(2, 3, 0x23, 0x2d);
            this.tpContactList.Text = "好友列表";
            this.tpContactList.ToolTipText = "";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xe7, 0xe7, 0xe7);
            this.BackgroundImageLayout = ImageLayout.Stretch;
            base.ClientSize = new Size(0x166, 0x257);
            base.Controls.Add(this.tcMain);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            this.MinimumSize = new Size(300, 420);
            base.Name = "MainForm";
            base.Padding = new Padding(3, 1, 2, 2);
            base.Text = "Fetion 2006";
            base.Controls.SetChildIndex(this.tcMain, 0);
            base.Controls.SetChildIndex(base.menubar, 0);
            this.tcMain.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void InitLogger()
        {
            string loggerArgs = Imps.Client.Core.FixedClientSetting.Instance.LoggerArgs;
            ImpsLogger logger = new ImpsLogger(this);
            logger.LogHeader.AppEnv.AppName = Imps.Client.Core.Configuration.FixedClientSetting.AppName;
            logger.LogHeader.AppEnv.Version = string.Format("{0}(Build {1}) - {2}", Imps.Client.Core.Configuration.FixedClientSetting.Version, Imps.Client.Core.Configuration.FixedClientSetting.BuildDate, Imps.Client.Core.Configuration.FixedClientSetting.Branch);
            logger.IsLogException = true;
            logger.IsLogInstall = true;
            ClientLogger.Logger = logger;
            TryParseLoggerArgs(logger, loggerArgs);
        }

        private void InitLogonHook()
        {
            try
            {
                if (this.m_sens_lock_proc == null)
                {
                    lock (this._syncObjSensor)
                    {
                        if (this.m_sens_lock_proc == null)
                        {
                            this.m_sens_lock_proc = new Imps.Client.Utils.sensmon.sensmon.sens_simple_notify_proc_type(this.on_sens_lock);
                            Imps.Client.Utils.sensmon.sensmon.simple_subscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_displayunlock, this.m_sens_lock_proc, IntPtr.Zero);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException("Failed to subscribing unlock event", exception);
            }
        }

        private void InitUiComponents()
        {
            this._mgrPersistent = new Imps.Client.Pc.PersistentManager(this);
            this._mgrAccount = new UserAccountManager(this);
            this._mgrAccount.EntryPointControl.Dock = DockStyle.Fill;
            base.Controls.Add(this.AccountManager.EntryPointControl);
            base.menubar.SendToBack();
            this._mgrAccount.CurrentUser.Configuration.LoadWndUserCfg();
            this._mgrAccount.CurrentUser.Configuration.UserSetting.MainWindowSetting.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.MainWindowSetting_PropertiesChanged);
            this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this.CurrentUser_StatusChanged);
            this.CurrentUser.ImpsError += new EventHandler<ImpsErrorEventArgs>(this.CurrentUser_ImpsError);
            this._mgrContact = new Imps.Client.Pc.ContactManager(this);
            this._mgrAccount.CurrentUser.AdManager.AdStatusBarChanged += new EventHandler(this.AdStatusBar_Changed);
            this.CurrentUser.ExServicesStatusChanged += new EventHandler<ExServiceEventArgs>(this.CurrentUser_ExServicesStatusChanged);
            this._mgrSysMsg = new Imps.Client.Pc.SystemMessageManager(this);
            this.AccountManager.CurrentUser.ConversationManager.ReceiveSystemMessage += new EventHandler<ImpsNotifyEventArgs>(this.ConversationManager_ReceiveSystemMessage);
        }

        private void InnerChannelManager_OnChannelLogoUpdated(object sender, EventArgs e)
        {
            try
            {
                ChannelItem item = sender as ChannelItem;
                if ((item != null) && (item.Logo != null))
                {
                    int num = this.tcMain.ImageList.Images.IndexOfKey(item.ID);
                    if (num > 0)
                    {
                        this.tcMain.ImageList.Images[num] = item.Logo;
                    }
                    num = this.tcMain.HoverImageList.Images.IndexOfKey(item.ID);
                    if (num > 0)
                    {
                        this.tcMain.HoverImageList.Images[num] = item.LogoHover;
                    }
                }
                this.tcMain.Invalidate(this.tcMain.TabRectangle);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void InnerChannelManager_OnChannelRetrived(object sender, EventArgs e)
        {
            try
            {
                this.tcMain.SuspendLayout();
                foreach (ChannelItem item in this.InnerChannelManager.Items)
                {
                    this.tcMain.ImageList.Images.Add(item.ID, item.Logo);
                    this.tcMain.HoverImageList.Images.Add(item.ID, item.LogoHover);
                    this.tcMain.TabPages.Add(item.ID, item.Tip, item.ID);
                    this.tcMain.TabPages[item.ID].ToolTipText = item.Tip;
                }
                this.tcMain.ResumeLayout();
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void InnerCloseChildWindows()
        {
            for (int i = base.OwnedForms.Length - 1; i >= 0; i--)
            {
                Form form = base.OwnedForms[i];
                if ((form is IHandleUserStatusSelf) && ((IHandleUserStatusSelf) form).Handled)
                {
                    return;
                }
                if (form.IsHandleCreated && form.Visible)
                {
                    if (form is IHandleUserStatusSelf)
                    {
                        if (!((IHandleUserStatusSelf) form).Handled)
                        {
                            form.Close();
                        }
                    }
                    else
                    {
                        form.Close();
                    }
                }
            }
        }

        private void MainForm_SizeChanged(object sender, EventArgs e)
        {
            this.TryReplaceContactList();
        }

        private void MainWindowSetting_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
        {
            try
            {
                if (e.ContainsProperty("HotKey"))
                {
                    HotKey.Unregister(base.Handle, 0);
                    this._hotKey = this.CurrentUser.Configuration.UserSetting.MainWindowSetting.HotKeyShowMainwindowFinal;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -