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

📄 mainform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 5 页
字号:
                    HotKey key = new HotKey(this._hotKey);
                    if (key.IsValid)
                    {
                        key.Register(base.Handle, 0);
                    }
                }
            }
            catch
            {
            }
        }

        private void miFeedback_Click(object sender, EventArgs e)
        {
            try
            {
                FunctionHelper.StartFunc(WebFunction.Feedback, string.Empty);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miForum_Click(object sender, EventArgs e)
        {
            try
            {
                FunctionHelper.StartFunc(WebFunction.Forum, string.Empty);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miHelpAbout_Click(object sender, EventArgs e)
        {
            try
            {
                this.ShowAbout(this);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miHelpTopic_Click(object sender, EventArgs e)
        {
            try
            {
                ImpsHelp.LoadHelp(ImpsHelpSrc.Unspcified);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miOperation_DropDownOpening(object sender, EventArgs e)
        {
            try
            {
                this.ContactManager.OnOperationMenuItemsOpening(this.miOperation);
                this.AccountManager.OnOperationMenuItemsOpening(this.miOperation);
                UserAccountStatus status = this.CurrentUser.Status;
                this.miToolsOptions.Enabled = ((status == UserAccountStatus.None) || (status == UserAccountStatus.Logon)) || (status == UserAccountStatus.Logoff);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miToolOption_Click(object sender, EventArgs e)
        {
            try
            {
                this.InnerOptionsForm.ShowOptions(this, string.Empty);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        private void miWebsite_Click(object sender, EventArgs e)
        {
            try
            {
                FunctionHelper.StartFunc(WebFunction.Website, string.Empty);
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this, exception);
            }
        }

        public bool NavigateToTab(string tabName, string args)
        {
            try
            {
                if (!this.tcMain.TabPages.ContainsKey(tabName))
                {
                    ClientLogger.WriteGeneral(string.Format("Channel({0})不存在!", tabName), string.Empty, 10, 0);
                    return false;
                }
                bool flag = this.tcMain.SelectedTab.Name == tabName;
                ChannelItem index = this.InnerChannelManager.Items.IndexOf(tabName);
                if (index != null)
                {
                    if (!string.IsNullOrEmpty(args))
                    {
                        index.Args = args;
                    }
                    if (flag)
                    {
                        index.Channel.Load(index.StrUri, index.Args);
                    }
                }
                this.tcMain.SelectTab(tabName);
                return true;
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
                return false;
            }
        }

        [MethodImpl(MethodImplOptions.NoInlining)]
        private void on_sens_lock(Imps.Client.Utils.sensmon.sensmon.event_id id, IntPtr context)
        {
            if ((Imps.Client.Utils.sensmon.sensmon.event_id.sens_displayunlock == id) && this._suspended)
            {
                if (this.SuspendRestored != null)
                {
                    FuncDispatcher.InvokeEventHandlerInUiThread(null, this.SuspendRestored, EventArgs.Empty);
                }
                this._suspended = false;
            }
        }

        protected override void OnClosed(EventArgs e)
        {
            try
            {
                this.SaveMainFormSetting();
                this.CurrentUser.Presence.DisposeSensors();
                this.UnRegWndMsg();
                if (this.m_sens_lock_proc != null)
                {
                    lock (this.m_sens_lock_proc)
                    {
                        if (this.m_sens_lock_proc != null)
                        {
                            Imps.Client.Utils.sensmon.sensmon.simple_unsubscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_displayunlock, this.m_sens_lock_proc);
                            this.m_sens_lock_proc = null;
                        }
                    }
                }
            }
            catch
            {
            }
            base.OnClosed(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            base.SizeChanged += new EventHandler(this.MainForm_SizeChanged);
            this.ShowEntryPoint();
            this.DoAfterLoaded(this, e);
        }

        private void ParseArgs(string[] args)
        {
            foreach (string str in args)
            {
                if ((str.Length > 1) && ((str[0] == '-') || (str[0] == '/')))
                {
                    string param = str.Substring(1);
                    if (!this.ParseLogFolderArg(param))
                    {
                        this.ParseDuringDebug(param);
                    }
                }
            }
        }

        private bool ParseDuringDebug(string param)
        {
            string str = param.ToUpper();
            bool flag = (str == "D") || (str == "Debug");
            if (flag)
            {
                Imps.Client.Core.Configuration.FixedClientSetting.DuringDebug = true;
            }
            return flag;
        }

        private bool ParseLogFolderArg(string param)
        {
            string str = param.ToUpper();
            string argsStr = string.Empty;
            if (str.IndexOf("LoggerArgs:".ToUpper()) == 0)
            {
                argsStr = param.Substring("LoggerArgs:".Length);
            }
            else if (str.IndexOf("LA:") == 0)
            {
                argsStr = param.Substring("LA:".Length);
            }
            if (argsStr.Length > 0)
            {
                TryParseLoggerArgs(ClientLogger.Logger, argsStr);
            }
            return (argsStr.Length > 0);
        }

        private bool ProcessPowerWinMessage(ref System.Windows.Forms.Message m)
        {
            int wParam = (int) m.WParam;
            ClientLogger.WriteGeneral("Power", string.Format("Msg:0x{0:x}, WParam=0x{1:x}; UserStatus:{2}", m.Msg, wParam, this.CurrentUser.Status));
            if (m.Msg == 0x218)
            {
                if (this._suspended && (((wParam == 7) || (wParam == 6)) || (wParam == 0x12)))
                {
                    this.InitLogonHook();
                }
                if ((!this._suspended && (wParam == 4)) && (this.CurrentUser.Status == UserAccountStatus.Logon))
                {
                    if (this.BeginSuspend != null)
                    {
                        FuncDispatcher.InvokeEventHandlerInUiThread(this, this.BeginSuspend, EventArgs.Empty);
                    }
                    this._suspended = true;
                    this.InitLogonHook();
                    this.SuspendAre = new AutoResetEvent(false);
                    this.CurrentUser.AsyncLogout(SignoutMode.Standby, this.SuspendAre);
                    this.SuspendAre.WaitOne(0x2710, false);
                }
            }
            return true;
        }

        private void RearrangeUiElements()
        {
            base.StatusBarBox = true;
            base.menubar.BackColor = Color.Transparent;
            base.menubar.Dock = DockStyle.Top;
            base.menubar.Visible = true;
            base.menubar.Controls.Add(this.menuMain);
            this.initComponentRegion();
            base.StatusBar.Logo = ImpsResources.GetImage("Images.carrier_24X24.png");
            base.StatusBar.Text = Imps.Client.Core.CarrierSetting.Instance.AdWord;
            base.StatusBar.Link = AppDictionary.CarrierPortal;
            base.StatusBar.Click += new EventHandler(this.statusLink_Click);
            base.StatusBar.ForeColor = Color.FromArgb(0, 0, 0xff);
            base.StatusBar.Padding = new Padding(0x1c, 0, 0, 0);
            this.tcMain.SelectedIndexChanged += new EventHandler(this.tcMain_SelectedIndexChanged);
            this.tpContactList.ToolTipText = StringTable.Framework.TipContactList;
            base.SuspendLayout();
            this.menuMain.Items.Insert(0, this.ContactManager.MenuItem);
            this.menuMain.Items.Insert(0, this.AccountManager.UserMenuItem);
            this.ReBuildOperationMenus();
            this.trayIcon.ContextMenuStrip = this.AccountManager.TrayIconMenu;
            base.menubar.SendToBack();
            base.ResumeLayout();
            this.initComponentRegion();
        }

        private void ReBuildOperationMenus()
        {
            this.miOperation.DropDownItems.Clear();
            ToolStripItem[] operationMenuItems = this.ContactManager.OperationMenuItems;
            if ((operationMenuItems != null) && (operationMenuItems.Length > 0))
            {
                this.miOperation.DropDownItems.AddRange(operationMenuItems);
            }
            if (this.miOperation.DropDownItems.Count > 0)
            {
                ToolStripSeparator separator = new ToolStripSeparator();
                separator.Enabled = false;
                this.miOperation.DropDownItems.Add(separator);
            }
            operationMenuItems = this.AccountManager.OperationMenuItems;
            if ((operationMenuItems != null) && (operationMenuItems.Length > 0))
            {
                this.miOperation.DropDownItems.AddRange(operationMenuItems);
            }
            if (this.miOperation.DropDownItems.Count > 0)
            {
                ToolStripSeparator separator2 = new ToolStripSeparator();
                separator2.Enabled = false;
                this.miOperation.DropDownItems.Add(separator2);
            }
            this.miOperation.DropDownItems.Add(this.miToolsOptions);
        }

        private void RegisterTaskbarCreatedMessage()
        {
            this.WM_TASKBARCREATED = (int) RegisterWindowMessage("TaskbarCreated");
        }

        [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
        private static extern uint RegisterWindowMessage(string lpString);
        private void RegWndMsg()
        {
            try
            {
                JNativeMethods.WTSRegisterSessionNotification(this.CurHandleRef, 0);
            }
            catch (Exception)
            {
            }
        }

        private void RemoveTabs()
        {
            foreach (ChannelItem item in this.InnerChannelManager.Items)
            {
                this.tcMain.TabPages.RemoveByKey(item.ID);
                this.tcMain.ImageList.Images.RemoveByKey(item.ID);

⌨️ 快捷键说明

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